|
14 | 14 | import os |
15 | 15 | import sys |
16 | 16 |
|
| 17 | +from docutils import nodes |
| 18 | +from docutils.parsers.rst import Directive |
| 19 | + |
17 | 20 | package_path = os.path.abspath("../..") |
18 | 21 | # Insert into sys.path so that we can import adaptive here |
19 | 22 | sys.path.insert(0, package_path) |
20 | 23 | # Insert into PYTHONPATH so that jupyter-sphinx will pick it up |
21 | 24 | os.environ["PYTHONPATH"] = ":".join((package_path, os.environ.get("PYTHONPATH", ""))) |
| 25 | +# Insert `docs/` such that we can run the logo scripts |
| 26 | +docs_path = os.path.abspath("..") |
| 27 | +sys.path.insert(1, docs_path) |
22 | 28 |
|
23 | 29 | import adaptive # noqa: E402, isort:skip |
24 | 30 |
|
|
154 | 160 | html_logo = "logo_docs.png" |
155 | 161 |
|
156 | 162 |
|
| 163 | +class RunLogoAnimated(Directive): |
| 164 | + def run(self): |
| 165 | + fname = "_static/logo_docs.mp4" |
| 166 | + if not os.path.exists(fname): |
| 167 | + import logo_animated |
| 168 | + |
| 169 | + print(f"{fname} does not exist.") |
| 170 | + logo_animated.main(fname) |
| 171 | + style = "width: 400px; max-width: 100%; margin: 0 auto; display:block;" |
| 172 | + opts = f'autoplay loop muted style="{style}"' |
| 173 | + html = f"""<video {opts}><source src="{fname}" type="video/mp4"></video><br>""" |
| 174 | + return [nodes.raw(text=html, format="html")] |
| 175 | + |
| 176 | + |
157 | 177 | def setup(app): |
158 | 178 | app.add_css_file("custom.css") # For the `live_info` widget |
| 179 | + app.add_directive("animated-logo", RunLogoAnimated) |
0 commit comments