|
75 | 75 |
|
76 | 76 | # Sphinx Book Theme configuration |
77 | 77 | html_theme_options = { |
78 | | - "use_repository_button": False, |
79 | | - "use_issues_button": False, |
| 78 | + "repository_url": "https://github.com/anyoptimization/pymoo", |
| 79 | + "repository_branch": "main", |
| 80 | + "path_to_docs": "docs/source", |
| 81 | + "use_repository_button": True, |
| 82 | + "use_issues_button": True, |
80 | 83 | "use_download_button": False, |
81 | | - "use_edit_page_button": False, |
| 84 | + "use_edit_page_button": True, |
| 85 | + "use_source_button": True, |
82 | 86 | "show_navbar_depth": 1, |
83 | 87 | "collapse_navigation": True, |
84 | 88 | "navigation_depth": 1, |
|
232 | 236 | # Disable RequireJS to avoid conflicts with clipboard.min.js |
233 | 237 | nbsphinx_requirejs_path = "" |
234 | 238 |
|
| 239 | +# =========================================================================== |
| 240 | +# Custom Source File Mapping for Edit Button |
| 241 | +# =========================================================================== |
| 242 | + |
| 243 | +def setup(app): |
| 244 | + """ |
| 245 | + Custom setup function to modify the source file mapping. |
| 246 | + This ensures that the "Edit Source" button links to .md files instead of .ipynb files. |
| 247 | + """ |
| 248 | + def html_page_context(app, pagename, templatename, context, doctree): |
| 249 | + """ |
| 250 | + Add JavaScript to fix edit button URLs to point to .md files. |
| 251 | + """ |
| 252 | + # Add JavaScript that will fix the edit button URLs after page load |
| 253 | + fix_edit_urls_js = """ |
| 254 | + <script> |
| 255 | + document.addEventListener('DOMContentLoaded', function() { |
| 256 | + // Find all edit and source buttons and fix their URLs |
| 257 | + const editButtons = document.querySelectorAll('a[href*="/edit/"], a[href*="/blob/"]'); |
| 258 | + editButtons.forEach(button => { |
| 259 | + if (button.href.includes('.ipynb')) { |
| 260 | + button.href = button.href.replace('.ipynb', '.md'); |
| 261 | + } |
| 262 | + }); |
| 263 | + }); |
| 264 | + </script> |
| 265 | + """ |
| 266 | + |
| 267 | + # Add the JavaScript to the page context |
| 268 | + context['fix_edit_urls_js'] = fix_edit_urls_js |
| 269 | + |
| 270 | + # Connect the function to the html-page-context event |
| 271 | + app.connect('html-page-context', html_page_context) |
| 272 | + |
| 273 | + return { |
| 274 | + 'version': '1.0', |
| 275 | + 'parallel_read_safe': True, |
| 276 | + 'parallel_write_safe': True, |
| 277 | + } |
| 278 | + |
235 | 279 |
|
0 commit comments