|
47 | 47 | 'sphinx.ext.mathjax', |
48 | 48 | 'sphinx.ext.viewcode', |
49 | 49 | 'sphinx.ext.napoleon', |
| 50 | + 'jupyter_sphinx.execute', |
50 | 51 | ] |
51 | 52 |
|
52 | 53 | source_parsers = {} |
|
113 | 114 | # Output file base name for HTML help builder. |
114 | 115 | htmlhelp_basename = 'adaptivedoc' |
115 | 116 |
|
| 117 | + |
116 | 118 | # -- Extension configuration ------------------------------------------------- |
117 | 119 |
|
118 | 120 | default_role = 'autolink' |
119 | 121 |
|
120 | | -intersphinx_mapping = {'python': ('https://docs.python.org/3', None), |
121 | | - 'distributed': ('https://distributed.readthedocs.io/en/stable/', None), |
122 | | - 'holoviews': ('https://holoviews.org/', None), |
123 | | - 'ipyparallel': ('https://ipyparallel.readthedocs.io/en/stable/', None), |
124 | | - 'scipy': ('https://docs.scipy.org/doc/scipy/reference', None), |
| 122 | +intersphinx_mapping = { |
| 123 | + 'python': ('https://docs.python.org/3', None), |
| 124 | + 'distributed': ('https://distributed.readthedocs.io/en/stable/', None), |
| 125 | + 'holoviews': ('https://holoviews.org/', None), |
| 126 | + 'ipyparallel': ('https://ipyparallel.readthedocs.io/en/stable/', None), |
| 127 | + 'scipy': ('https://docs.scipy.org/doc/scipy/reference', None), |
125 | 128 | } |
| 129 | + |
| 130 | + |
| 131 | +# -- Add Holoviews js and css ------------------------------------------------ |
| 132 | + |
| 133 | +def setup(app): |
| 134 | + from holoviews.plotting import Renderer |
| 135 | + |
| 136 | + hv_js, hv_css = Renderer.html_assets( |
| 137 | + extras=False, backends=[], script=True) |
| 138 | + |
| 139 | + fname_css = 'holoviews.css' |
| 140 | + fname_js = 'holoviews.js' |
| 141 | + static_dir = 'source/_static' |
| 142 | + |
| 143 | + os.makedirs(static_dir, exist_ok=True) |
| 144 | + |
| 145 | + with open(f'{static_dir}/{fname_css}', 'w') as f: |
| 146 | + hv_css = hv_css.split('<style>')[1].replace('</style>', '') |
| 147 | + f.write(hv_css) |
| 148 | + |
| 149 | + with open(f'{static_dir}/{fname_js}', 'w') as f: |
| 150 | + f.write(hv_js) |
| 151 | + |
| 152 | + app.add_stylesheet(fname_css) |
| 153 | + app.add_javascript(fname_js) |
| 154 | + |
| 155 | + dependencies = {**Renderer.core_dependencies, **Renderer.extra_dependencies} |
| 156 | + for name, type_url in dependencies.items(): |
| 157 | + if name in ['bootstrap']: |
| 158 | + continue |
| 159 | + |
| 160 | + for url in type_url.get('js', []): |
| 161 | + app.add_javascript(url) |
| 162 | + for url in type_url.get('css', []): |
| 163 | + app.add_stylesheet(url) |
| 164 | + |
| 165 | + app.add_javascript("https://unpkg.com/@jupyter-widgets/html-manager@0.14.4/dist/embed-amd.js") |
0 commit comments