divi255 / sphinxcontrib.asciinema

Easily embed asciinema videos into Sphinx documentation
MIT License
17 stars 11 forks source link

Fails when manpages are built #3

Closed charego closed 4 years ago

charego commented 4 years ago

Thanks for the extension, it works great for HTML. I'm trying to build the fish-shell docs (https://github.com/charego/fish-shell/commit/85ff7f89a56abb963a53efcf4c5667fe0051ebd9) and it builds fine when manpages are excluded.

But when manpages are enabled again, I get this error:

~/sandbox/fish-shell/build (docs/asciinema) > make doc
[ 21%] Built target pcre2-32
[ 21%] Built target CHECK-FISH-BUILD-VERSION-FILE
[ 94%] Built target fishlib
[ 97%] Built target fish_indent
[ 98%] Building man pages with Sphinx

Exception occurred:
  File "/usr/local/lib/python3.7/site-packages/sphinx/writers/manpage.py", line 459, in unknown_visit
    raise NotImplementedError('Unknown node: ' + node.__class__.__name__)
NotImplementedError: Unknown node: Asciinema
The full traceback has been saved in /var/folders/j6/5pd6brws00n7k_6l6j_v8v840000gy/T/sphinx-err-qj3ipsl5.log, if you want to report the issue to the developers.
Please also report this if it was a user error, so that a better error message can be provided next time.
A bug report can be filed in the tracker at <https://github.com/sphinx-doc/sphinx/issues>. Thanks!
make[3]: *** [CMakeFiles/sphinx-manpages] Error 2
make[2]: *** [CMakeFiles/sphinx-manpages.dir/all] Error 2
make[1]: *** [CMakeFiles/doc.dir/rule] Error 2
make: *** [doc] Error 2

Full error:

> cat /var/folders/j6/5pd6brws00n7k_6l6j_v8v840000gy/T/sphinx-err-qj3ipsl5.log
# Sphinx version: 2.4.4
# Python version: 3.7.7 (CPython)
# Docutils version: 0.16 release
# Jinja2 version: 2.11.2
# Last messages:
#   cmds/vared
#   cmds/wait
#   cmds/while
#   design
#   tutorial
#   completions
#   faq
#   license
#   }
#   failed
# Loaded extensions:
#   sphinx.ext.mathjax (2.4.4) from /usr/local/lib/python3.7/site-packages/sphinx/ext/mathjax.py
#   sphinxcontrib.applehelp (1.0.2) from /usr/local/lib/python3.7/site-packages/sphinxcontrib/applehelp/__init__.py
#   sphinxcontrib.devhelp (1.0.2) from /usr/local/lib/python3.7/site-packages/sphinxcontrib/devhelp/__init__.py
#   sphinxcontrib.htmlhelp (1.0.3) from /usr/local/lib/python3.7/site-packages/sphinxcontrib/htmlhelp/__init__.py
#   sphinxcontrib.serializinghtml (1.1.4) from /usr/local/lib/python3.7/site-packages/sphinxcontrib/serializinghtml/__init__.py
#   sphinxcontrib.qthelp (1.0.3) from /usr/local/lib/python3.7/site-packages/sphinxcontrib/qthelp/__init__.py
#   alabaster (0.7.12) from /usr/local/lib/python3.7/site-packages/alabaster/__init__.py
#   sphinxcontrib.asciinema (unknown version) from /usr/local/lib/python3.7/site-packages/sphinxcontrib/asciinema/__init__.py
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/sphinx/cmd/build.py", line 276, in build_main
    app.build(args.force_all, filenames)
  File "/usr/local/lib/python3.7/site-packages/sphinx/application.py", line 349, in build
    self.builder.build_update()
  File "/usr/local/lib/python3.7/site-packages/sphinx/builders/__init__.py", line 294, in build_update
    self.build(['__all__'], to_build)
  File "/usr/local/lib/python3.7/site-packages/sphinx/builders/__init__.py", line 361, in build
    self.write(docnames, list(updated_docnames), method)
  File "/usr/local/lib/python3.7/site-packages/sphinx/util/__init__.py", line 686, in wrapper
    return f(*args, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/sphinx/builders/manpage.py", line 100, in write
    docwriter.write(largetree, destination)
  File "/usr/local/lib/python3.7/site-packages/docutils/writers/__init__.py", line 78, in write
    self.translate()
  File "/usr/local/lib/python3.7/site-packages/sphinx/writers/manpage.py", line 45, in translate
    self.document.walkabout(visitor)
  File "/usr/local/lib/python3.7/site-packages/docutils/nodes.py", line 214, in walkabout
    if child.walkabout(visitor):
  File "/usr/local/lib/python3.7/site-packages/docutils/nodes.py", line 214, in walkabout
    if child.walkabout(visitor):
  File "/usr/local/lib/python3.7/site-packages/docutils/nodes.py", line 214, in walkabout
    if child.walkabout(visitor):
  [Previous line repeated 3 more times]
  File "/usr/local/lib/python3.7/site-packages/docutils/nodes.py", line 206, in walkabout
    visitor.dispatch_visit(self)
  File "/usr/local/lib/python3.7/site-packages/sphinx/util/docutils.py", line 486, in dispatch_visit
    super().dispatch_visit(node)
  File "/usr/local/lib/python3.7/site-packages/docutils/nodes.py", line 1995, in dispatch_visit
    return method(node)
  File "/usr/local/lib/python3.7/site-packages/sphinx/writers/manpage.py", line 459, in unknown_visit
    raise NotImplementedError('Unknown node: ' + node.__class__.__name__)
NotImplementedError: Unknown node: Asciinema
charego commented 4 years ago

The same problem is not seen with other extensions. For example when I add sphinxcontrib-blockdiag to the build, the manpage output contains "[image]", which is acceptable and definitely preferred to failing the build. I believe that output comes from sphinx/writers/manpage.py.

But neither this extension nor sphinxcontrib-blockdiag refers directly to that function (visit_image), so I'm not sure how it all works. Any idea?

divi255 commented 4 years ago

will look into this in a couple of days

divi255 commented 4 years ago

I've added empty visit method for mans. It works, but asciinema tag in man files is currently simply removed.

charego commented 4 years ago

Thanks! With v0.1.8 it works with a hosted video like .. asciinema:: 261648.

Now I get this error on manpages with .. asciinema:: local_file.cast:

> make doc
[ 21%] Built target pcre2-32
[ 21%] Built target CHECK-FISH-BUILD-VERSION-FILE
[ 94%] Built target fishlib
[ 97%] Built target fish_indent
[ 98%] Building man pages with Sphinx

Exception occurred:
  File "/usr/local/lib/python3.7/site-packages/sphinx/builders/manpage.py", line 56, in get_target_uri
    raise NoUri(docname, typ)
sphinx.errors.NoUri: ('tutorial', None)
The full traceback has been saved in /var/folders/j6/5pd6brws00n7k_6l6j_v8v840000gy/T/sphinx-err-3gy7dzlc.log, if you want to report the issue to the developers.
Please also report this if it was a user error, so that a better error message can be provided next time.
A bug report can be filed in the tracker at <https://github.com/sphinx-doc/sphinx/issues>. Thanks!
make[3]: *** [CMakeFiles/sphinx-manpages] Error 2
make[2]: *** [CMakeFiles/sphinx-manpages.dir/all] Error 2
make[1]: *** [CMakeFiles/doc.dir/rule] Error 2
make: *** [doc] Error 2

I don't understand what's different about this extension. The blockdiag one doesn't reference manpages, so why should yours need to?

divi255 commented 4 years ago

sphinx man builder is different from HTML builder, I've added a couple of fixes. should work now, check 0.1.9

charego commented 4 years ago

Just re-tested .. asciinema:: local_file.cast and while the NoUri problem is fixed for the man pages (thank you), now the generated HTML is

<script id="asciicast-None" src="https://asciinema.org/a/None.js" async>
divi255 commented 4 years ago

sorry can't reproduce this. "asciicast-None" can appear only if sphinx raises NoUri exception for some reason. It's raised for man files (that's fine) but it shouldn't for HTML. could you please give a full example? (repo+branch+build command)

charego commented 4 years ago

The directory structure for fish is like this:

.
├── build
│   ├── Makefile
│   └── user_doc
├── doc_src
│   ├── _static      <-- on my branch, local_file.cast is here
│   ├── conf.py
│   └── tutorial.rst

I'm testing out the directive in tutorial.rst.

With valid path .. asciicast:: _static/local_file.cast:

<script id="asciicast-None"  src="https://asciinema.org/a/None.js" async></script>

With invalid path .. asciicast:: _static/invalid_file.cast:

<script id="asciicast-_static/invalid_file.cast"  src="https://asciinema.org/a/_static/invalid_file.cast.js" async>

Here's the full info you requested:

divi255 commented 4 years ago

Just tried, got

<asciinema-player  src="_casts/72dda36451c97b022e1eb358f22444fe/_static/local_file.cast"></asciinema-player>

sphinxcontrib.asciinema 0.1.9 sphinx 3.0.2 Python 3.8.2

divi255 commented 4 years ago
    <link rel="stylesheet" type="text/css" href="_static/asciinema-player_2.6.1.css" />
    <link rel="stylesheet" type="text/css" href="_static/asciinema-custom.css" />
    <script src="_static/asciinema-player_2.6.1.js"></script>
<asciinema-player  src="_casts/72dda36451c97b022e1eb358f22444fe/_static/local_file.cast"></asciinema-player><p>Once installed, just type in <code class="docutils literal notranslate"><span class="pre">fish</span></code> into your current shell to try it out!</p>

that's inserted

charego commented 4 years ago

Weird, ok. Let's close this. I'll open a new one if I figure out my problem.

Thanks for the help!