2626# list see the documentation:
2727# https://www.sphinx-doc.org/en/master/usage/configuration.html
2828
29- # -- Path setup --------------------------------------------------------------
30-
3129import datetime
3230import os
31+ import pathlib
3332import sys
3433
3534sys .path .insert (0 , os .path .abspath ("." ))
3635
37- import cebra # noqa: E402
38-
3936
4037def get_years (start_year = 2021 ):
4138 year = datetime .datetime .now ().year
@@ -49,8 +46,17 @@ def get_years(start_year=2021):
4946project = "cebra"
5047copyright = f"""{ get_years (2021 )} """
5148author = "See AUTHORS.md"
52- # The full version, including alpha/beta/rc tags
53- release = cebra .__version__
49+ version_file = pathlib .Path (
50+ __file__ ).parent .parent .parent / "cebra" / "__init__.py"
51+ assert version_file .exists (), f"Could not find version file: { version_file } "
52+ with version_file .open ("r" ) as f :
53+ for line in f :
54+ if line .startswith ("__version__" ):
55+ version = line .split ("=" )[1 ].strip ().strip ('"' ).strip ("'" )
56+ print ("Building docs for version:" , version )
57+ break
58+ else :
59+ raise ValueError ("Could not find version in __init__.py" )
5460
5561# -- General configuration ---------------------------------------------------
5662
@@ -60,8 +66,7 @@ def get_years(start_year=2021):
6066
6167#https://github.com/spatialaudio/nbsphinx/issues/128#issuecomment-1158712159
6268html_js_files = [
63- "require.min.js" , # Add to your _static
64- "custom.js" ,
69+ "https://cdn.plot.ly/plotly-latest.min.js" , # Add Plotly.js
6570]
6671
6772extensions = [
@@ -122,7 +127,8 @@ def get_years(start_year=2021):
122127
123128autodoc_member_order = "bysource"
124129autodoc_mock_imports = [
125- "torch" , "nlb_tools" , "tqdm" , "h5py" , "pandas" , "matplotlib" , "plotly"
130+ "torch" , "nlb_tools" , "tqdm" , "h5py" , "pandas" , "matplotlib" , "plotly" ,
131+ "joblib" , "scikit-learn" , "scipy" , "requests" , "sklearn"
126132]
127133# autodoc_typehints = "none"
128134
@@ -134,7 +140,8 @@ def get_years(start_year=2021):
134140# This pattern also affects html_static_path and html_extra_path.
135141exclude_patterns = [
136142 "**/todo" , "**/src" , "cebra-figures/figures.rst" , "cebra-figures/*.rst" ,
137- "*/cebra-figures/*.rst" , "demo_notebooks/README.rst"
143+ "*/cebra-figures/*.rst" , "*/demo_notebooks/README.rst" ,
144+ "demo_notebooks/README.rst"
138145]
139146
140147# -- Options for HTML output -------------------------------------------------
@@ -185,23 +192,26 @@ def get_years(start_year=2021):
185192 "icon" : "fas fa-graduation-cap" ,
186193 },
187194 ],
188- "external_links" : [
189- # {"name": "Mathis Lab", "url": "http://www.mackenziemathislab.org/"},
190- ],
191195 "collapse_navigation" : False ,
192- "navigation_depth" : 4 ,
196+ "navigation_depth" : 1 ,
193197 "show_nav_level" : 2 ,
194198 "navbar_align" : "content" ,
195199 "show_prev_next" : False ,
200+ "navbar_end" : ["theme-switcher" , "navbar-icon-links.html" ],
201+ "navbar_persistent" : [],
202+ "header_links_before_dropdown" : 7
196203}
197204
198- html_context = {"default_mode" : "dark " }
205+ html_context = {"default_mode" : "light " }
199206html_favicon = "_static/img/logo_small.png"
200207html_logo = "_static/img/logo_large.png"
201208
202- # Remove the search field for now
209+ # Replace with this configuration to enable "on this page" navigation
203210html_sidebars = {
204- "**" : ["search-field.html" , "sidebar-nav-bs.html" ],
211+ "**" : ["search-field.html" , "sidebar-nav-bs" , "page-toc.html" ],
212+ "demos" : ["search-field.html" , "sidebar-nav-bs" ],
213+ "api" : ["search-field.html" , "sidebar-nav-bs" ],
214+ "figures" : ["search-field.html" , "sidebar-nav-bs" ],
205215}
206216
207217# Disable links for embedded images
@@ -289,3 +299,12 @@ def get_years(start_year=2021):
289299"""
290300# fmt: on
291301# flake8: enable=E501
302+
303+ # Configure nbsphinx to properly render Plotly plots
304+ nbsphinx_execute = 'auto'
305+ nbsphinx_allow_errors = True
306+ nbsphinx_requirejs_path = 'https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.7/require.js'
307+ nbsphinx_execute_arguments = [
308+ "--InlineBackend.figure_formats={'png', 'svg', 'pdf'}" ,
309+ "--InlineBackend.rc=figure.dpi=96" ,
310+ ]
0 commit comments