Skip to content

Commit

Permalink
Merge pull request #332 from python-adaptive/simplify-logo-animated
Browse files Browse the repository at this point in the history
use jupyter-sphinx instead of custom Sphinx directive
  • Loading branch information
basnijholt committed Sep 24, 2021
1 parent 527ae60 commit bad3fc0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 20 deletions.
6 changes: 5 additions & 1 deletion docs/logo_animated.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import os

import matplotlib.tri as mtri
import numpy as np
from matplotlib import animation
Expand Down Expand Up @@ -96,4 +98,6 @@ def main(fname="source/_static/logo_docs.mp4"):


if __name__ == "__main__":
main()
fname = "_static/logo_docs.mp4"
if not os.path.exists(fname):
main(fname)
18 changes: 0 additions & 18 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
import os
import sys

from docutils import nodes
from docutils.parsers.rst import Directive

package_path = os.path.abspath("../..")
# Insert into sys.path so that we can import adaptive here
sys.path.insert(0, package_path)
Expand Down Expand Up @@ -160,20 +157,5 @@
html_logo = "_static/logo_docs.png"


class RunLogoAnimated(Directive):
def run(self):
fname = "_static/logo_docs.mp4"
if not os.path.exists(fname):
import logo_animated

print(f"{fname} does not exist.")
logo_animated.main(fname)
style = "width: 400px; max-width: 100%; margin: 0 auto; display:block;"
opts = f'autoplay loop muted playsinline webkit-playsinline style="{style}"'
html = f'<video {opts}><source src="{fname}" type="video/mp4"></video><br>'
return [nodes.raw(text=html, format="html")]


def setup(app):
app.add_css_file("custom.css") # For the `live_info` widget
app.add_directive("animated-logo", RunLogoAnimated)
11 changes: 10 additions & 1 deletion docs/source/logo.rst
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
.. animated-logo::
.. jupyter-execute:: ../logo_animated.py
:hide-code:
:hide-output:

.. raw:: html

<video autoplay loop muted playsinline webkit-playsinline
style="width: 400px; max-width: 100%; margin: 0 auto; display:block;">
<source src="_static/logo_docs.mp4" type="video/mp4">
</video><br>

0 comments on commit bad3fc0

Please sign in to comment.