Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Account for nodes without children in Texinfo's ignores #12389

Merged
merged 2 commits into from
May 22, 2024

Conversation

quotuva
Copy link
Contributor

@quotuva quotuva commented May 20, 2024

Subject: Account for nodes without children in Texinfo's ignores

Feature or Bugfix

  • Bugfix

Purpose

  • This prevented compilation of the Pytorch tutorial at https://github.com/pytorch/tutorials, with the latest master.
  • It requires the environment for the above repo, detailed there.

Detail

  • Incidentally, this also required the following patch to the above repo (to get it compiling):
diff --git a/custom_directives.py b/custom_directives.py
index 388aa262e..3b22ec2d8 100644
--- a/custom_directives.py
+++ b/custom_directives.py
@@ -88,7 +88,7 @@ class GalleryItemDirective(Directive):
             if 'intro' in self.options:
                 intro = self.options['intro'][:195] + '...'
             else:
-                _, blocks = sphinx_gallery.gen_rst.split_code_and_text_blocks(abs_fname)
+                _, blocks = sphinx_gallery.py_source_parser.split_code_and_text_blocks(abs_fname)
                 intro, _ = sphinx_gallery.gen_rst.extract_intro_and_title(abs_fname, blocks[0][1])
 
             thumbnail_rst = ''

Relates

  • (NA)

This prevented compilation of the pytorch tutorial at
https://github.com/pytorch/tutorials, with the latest master.
@picnixz
Copy link
Member

picnixz commented May 21, 2024

Incidentally, this also required the following patch to the above repo (to get it compiling):

I assume that this is something unrelated to us. In which case did pytorch create reference nodes without children? (I would like to know whether it's an assumption on the references nodes, because a reference node usually have a content (to display) but I don't remember if we had "fake" nodes for location-only purposes).

@quotuva
Copy link
Contributor Author

quotuva commented May 22, 2024

Here's the trace:

writing... /home/user/code/tutorials/beginner/basics/data_tutorial.rst:: WARNING: unknown node type: <imgsgnode: >
/home/user/code/tutorials/beginner/basics/data_tutorial.rst:: WARNING: unknown node type: <imgsgnode: >
/home/user/code/tutorials/beginner/introyt/introyt1_tutorial.rst:: WARNING: unknown node type: <imgsgnode: >
/home/user/code/tutorials/beginner/introyt/introyt1_tutorial.rst:: WARNING: unknown node type: <imgsgnode: >
/home/user/code/tutorials/beginner/introyt/autogradyt_tutorial.rst:: WARNING: unknown node type: <imgsgnode: >
/home/user/code/tutorials/beginner/introyt/autogradyt_tutorial.rst:: WARNING: unknown node type: <imgsgnode: >
/home/user/code/tutorials/beginner/introyt/tensorboardyt_tutorial.rst:: WARNING: unknown node type: <imgsgnode: >
/home/user/code/tutorials/beginner/introyt/trainingyt.rst:: WARNING: unknown node type: <imgsgnode: >
/home/user/code/tutorials/beginner/blitz/cifar10_tutorial.rst:: WARNING: unknown node type: <imgsgnode: >
/home/user/code/tutorials/beginner/blitz/cifar10_tutorial.rst:: WARNING: unknown node type: <imgsgnode: >
failed

Traceback (most recent call last):
  File "/home/user/code/tutorials/venv/src/sphinx/sphinx/cmd/build.py", line 337, in build_main
    app.build(args.force_all, args.filenames)
  File "/home/user/code/tutorials/venv/src/sphinx/sphinx/application.py", line 348, in build
    self.builder.build_update()
  File "/home/user/code/tutorials/venv/src/sphinx/sphinx/builders/__init__.py", line 290, in build_update
    self.build(['__all__'], to_build)
  File "/home/user/code/tutorials/venv/src/sphinx/sphinx/builders/__init__.py", line 362, in build
    self.write(docnames, list(updated_docnames), method)
  File "/home/user/code/tutorials/venv/src/sphinx/sphinx/builders/texinfo.py", line 132, in write
    docwriter.write(doctree, destination)
  File "/home/user/code/tutorials/venv/lib/python3.10/site-packages/docutils/writers/__init__.py", line 80, in write
    self.translate()
  File "/home/user/code/tutorials/venv/src/sphinx/sphinx/writers/texinfo.py", line 134, in translate
    self.document.walkabout(visitor)
  File "/home/user/code/tutorials/venv/lib/python3.10/site-packages/docutils/nodes.py", line 186, in walkabout
    if child.walkabout(visitor):
  File "/home/user/code/tutorials/venv/lib/python3.10/site-packages/docutils/nodes.py", line 186, in walkabout
    if child.walkabout(visitor):
  File "/home/user/code/tutorials/venv/lib/python3.10/site-packages/docutils/nodes.py", line 186, in walkabout
    if child.walkabout(visitor):
  [Previous line repeated 8 more times]
  File "/home/user/code/tutorials/venv/lib/python3.10/site-packages/docutils/nodes.py", line 178, in walkabout
    visitor.dispatch_visit(self)
  File "/home/user/code/tutorials/venv/src/sphinx/sphinx/util/docutils.py", line 568, in dispatch_visit
    method(node)
  File "/home/user/code/tutorials/venv/src/sphinx/sphinx/writers/texinfo.py", line 694, in visit_reference
    if isinstance(node[0], nodes.image):
  File "/home/user/code/tutorials/venv/lib/python3.10/site-packages/docutils/nodes.py", line 598, in __getitem__
    return self.children[key]
IndexError: list index out of range

Exception occurred:
  File "/home/user/code/tutorials/venv/lib/python3.10/site-packages/docutils/nodes.py", line 598, in __getitem__
    return self.children[key]
IndexError: list index out of range
The full traceback has been saved in /tmp/sphinx-err-prxtzghp.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: *** [Makefile:28: info] Error 1

I confess I don't know much about the Sphinx code, but would it make sense to leave this in in the interest of robustness?

@picnixz
Copy link
Member

picnixz commented May 22, 2024

would it make sense to leave this in in the interest of robustness

I've checked other builders and the LaTeX builder for instance checks that the child exists before checking its type. So I agree that it's an issue for the TexInfo builder, unless the latter must assume that reference nodes must have children which I don't think it is.

@picnixz picnixz merged commit 9cc0ea1 into sphinx-doc:master May 22, 2024
23 checks passed
@picnixz
Copy link
Member

picnixz commented May 22, 2024

Thank you!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 23, 2024
@AA-Turner AA-Turner added this to the 7.4.0 milestone Jul 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants