Skip to content

Commit bad3fc0

Browse files
authored
Merge pull request #332 from python-adaptive/simplify-logo-animated
use jupyter-sphinx instead of custom Sphinx directive
1 parent 527ae60 commit bad3fc0

File tree

3 files changed

+15
-20
lines changed

3 files changed

+15
-20
lines changed

docs/logo_animated.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import os
2+
13
import matplotlib.tri as mtri
24
import numpy as np
35
from matplotlib import animation
@@ -96,4 +98,6 @@ def main(fname="source/_static/logo_docs.mp4"):
9698

9799

98100
if __name__ == "__main__":
99-
main()
101+
fname = "_static/logo_docs.mp4"
102+
if not os.path.exists(fname):
103+
main(fname)

docs/source/conf.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414
import os
1515
import sys
1616

17-
from docutils import nodes
18-
from docutils.parsers.rst import Directive
19-
2017
package_path = os.path.abspath("../..")
2118
# Insert into sys.path so that we can import adaptive here
2219
sys.path.insert(0, package_path)
@@ -160,20 +157,5 @@
160157
html_logo = "_static/logo_docs.png"
161158

162159

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 playsinline webkit-playsinline 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-
177160
def setup(app):
178161
app.add_css_file("custom.css") # For the `live_info` widget
179-
app.add_directive("animated-logo", RunLogoAnimated)

docs/source/logo.rst

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,10 @@
1-
.. animated-logo::
1+
.. jupyter-execute:: ../logo_animated.py
2+
:hide-code:
3+
:hide-output:
4+
5+
.. raw:: html
6+
7+
<video autoplay loop muted playsinline webkit-playsinline
8+
style="width: 400px; max-width: 100%; margin: 0 auto; display:block;">
9+
<source src="_static/logo_docs.mp4" type="video/mp4">
10+
</video><br>

0 commit comments

Comments
 (0)