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

6.1 breaks sphinx-argparse-cli #11091

Closed
gaborbernat opened this issue Jan 5, 2023 · 5 comments
Closed

6.1 breaks sphinx-argparse-cli #11091

gaborbernat opened this issue Jan 5, 2023 · 5 comments

Comments

@gaborbernat
Copy link
Contributor

Describe the bug

#11061 raises a hard error for missing nodes, but then #4193 workaround now does not work if the source cannot be found:

>       app.build()

test_logic.py:39: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../.tox/dev/lib/python3.10/site-packages/sphinx/testing/util.py:161: in build
    super().build(force_all, filenames)
../.tox/dev/lib/python3.10/site-packages/sphinx/application.py:347: in build
    self.builder.build_update()
../.tox/dev/lib/python3.10/site-packages/sphinx/builders/__init__.py:311: in build_update
    self.build(to_build,
../.tox/dev/lib/python3.10/site-packages/sphinx/builders/__init__.py:327: in build
    updated_docnames = set(self.read())
../.tox/dev/lib/python3.10/site-packages/sphinx/builders/__init__.py:434: in read
    self._read_serial(docnames)
../.tox/dev/lib/python3.10/site-packages/sphinx/builders/__init__.py:455: in _read_serial
    self.read_doc(docname)
../.tox/dev/lib/python3.10/site-packages/sphinx/builders/__init__.py:511: in read_doc
    publisher.publish()
../.tox/dev/lib/python3.10/site-packages/docutils/core.py:226: in publish
    self.apply_transforms()
../.tox/dev/lib/python3.10/site-packages/docutils/core.py:206: in apply_transforms
    self.document.transformer.apply_transforms()
../.tox/dev/lib/python3.10/site-packages/sphinx/transforms/__init__.py:80: in apply_transforms
    super().apply_transforms()
../.tox/dev/lib/python3.10/site-packages/docutils/transforms/__init__.py:173: in apply_transforms
    transform.apply(**kwargs)
../.tox/dev/lib/python3.10/site-packages/sphinx/transforms/__init__.py:206: in apply
    apply_source_workaround(node)
../.tox/dev/lib/python3.10/site-packages/sphinx/util/nodes.py:155: in apply_source_workaround
    node.source = get_node_source(node)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

node = <literal_block: <#text: 'basic [-h]'>>

    def get_node_source(node: Element) -> str:
        for pnode in traverse_parent(node):
            if pnode.source:
                return pnode.source
>       raise ValueError("node source not found")
E       ValueError: node source not found

../.tox/dev/lib/python3.10/site-packages/sphinx/util/nodes.py:271: ValueError

How to Reproduce

Clone and run the test suite for https://github.com/tox-dev/sphinx-argparse-cli

Environment Information

Latest.

Sphinx extensions

No response

Additional context

No response

@AA-Turner
Copy link
Member

If you have the reST source that generated the error it would be useful to add as a regression test to Sphinx.

A

@martinvonk
Copy link

Getting the same error when building readthedocs: https://readthedocs.org/projects/pastas/builds/19084935/

File "/home/docs/checkouts/readthedocs.org/user_builds/pastas/envs/433/lib/python3.10/site-packages/sphinx/util/nodes.py", line 155, in apply_source_workaround
node.source = get_node_source(node)
File "/home/docs/checkouts/readthedocs.org/user_builds/pastas/envs/433/lib/python3.10/site-packages/sphinx/util/nodes.py", line 271, in get_node_source
raise ValueError("node source not found")
ValueError: node source not found

Exception occurred:
File "/home/docs/checkouts/readthedocs.org/user_builds/pastas/envs/433/lib/python3.10/site-packages/sphinx/util/nodes.py", line 271, in get_node_source
raise ValueError("node source not found")
ValueError: node source not found

@gaborbernat
Copy link
Contributor Author

I only get it in the context of code generated by sphinx-argparse-cli https://github.com/tox-dev/sphinx-argparse-cli/blob/main/roots/test-basic/index.rst, so no minimal repro from me 😢

@AA-Turner
Copy link
Member

Added this as a fairly basic test:

    literal_block = nodes.literal_block('', '')
    list_item = nodes.list_item('', literal_block)
    bullet_list = nodes.bullet_list('', list_item)

    assert literal_block.source is None
    assert list_item.source is None
    assert bullet_list.source is None

    apply_source_workaround(literal_block)

    assert literal_block.source is None
    assert list_item.source is None
    assert bullet_list.source is None

A

@AA-Turner
Copy link
Member

Fixed in Sphinx 6.1.1, released at 5pm today.

A

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants