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

References not resolved correctly for orphan pages #424

Open
1 task done
mason3k opened this issue Jan 16, 2024 · 2 comments
Open
1 task done

References not resolved correctly for orphan pages #424

mason3k opened this issue Jan 16, 2024 · 2 comments
Labels
bug crash rinohtype aborts due to an uncaught exception

Comments

@mason3k
Copy link

mason3k commented Jan 16, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Sphinx or rinoh output

Traceback (most recent call last):
  File "/Users/sjones/Code/ADI/.venv/lib/python3.9/site-packages/sphinx/events.py", line 96, in emit
    results.append(listener.handler(self.app, *args))
  File "/Users/sjones/Code/ADI/docs/source/_ext/directives/properties.py", line 32, in add_references
    make_refnode(
  File "/Users/sjones/Code/ADI/.venv/lib/python3.9/site-packages/sphinx/util/nodes.py", line 551, in make_refnode
    node['refuri'] = (builder.get_relative_uri(fromdocname, todocname) +
  File "/Users/sjones/Code/ADI/.venv/lib/python3.9/site-packages/rinoh/frontend/sphinx/__init__.py", line 175, in get_relative_uri
    return self.get_target_uri(to, typ)
  File "/Users/sjones/Code/ADI/.venv/lib/python3.9/site-packages/rinoh/frontend/sphinx/__init__.py", line 169, in get_target_uri
    raise NoUri(docname, typ)
sphinx.errors.NoUri: ('shared/terms', None)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/sjones/Code/ADI/.venv/lib/python3.9/site-packages/sphinx/cmd/build.py", line 290, in build_main
    app.build(args.force_all, args.filenames)
  File "/Users/sjones/Code/ADI/.venv/lib/python3.9/site-packages/sphinx/application.py", line 347, in build
    self.builder.build_all()
  File "/Users/sjones/Code/ADI/.venv/lib/python3.9/site-packages/sphinx/builders/__init__.py", line 249, in build_all
    self.build(None, summary=__('all source files'), method='all')
  File "/Users/sjones/Code/ADI/.venv/lib/python3.9/site-packages/sphinx/builders/__init__.py", line 360, in build
    self.write(docnames, list(updated_docnames), method)
  File "/Users/sjones/Code/ADI/.venv/lib/python3.9/site-packages/rinoh/frontend/sphinx/__init__.py", line 257, in write
    self.write_document(entry)
  File "/Users/sjones/Code/ADI/.venv/lib/python3.9/site-packages/rinoh/frontend/sphinx/__init__.py", line 263, in write_document
    rinoh_document = self.construct_rinohtype_document(data)
  File "/Users/sjones/Code/ADI/.venv/lib/python3.9/site-packages/rinoh/frontend/sphinx/__init__.py", line 276, in construct_rinohtype_document
    doctree, docnames = self.assemble_doctree(doc, toctree_only)
  File "/Users/sjones/Code/ADI/.venv/lib/python3.9/site-packages/rinoh/frontend/sphinx/__init__.py", line 210, in assemble_doctree
    self.env.resolve_references(largetree, indexfile, self)
  File "/Users/sjones/Code/ADI/.venv/lib/python3.9/site-packages/sphinx/environment/__init__.py", line 658, in resolve_references
    self.apply_post_transforms(doctree, fromdocname)
  File "/Users/sjones/Code/ADI/.venv/lib/python3.9/site-packages/sphinx/environment/__init__.py", line 675, in apply_post_transforms
    self.events.emit('doctree-resolved', doctree, docname)
  File "/Users/sjones/Code/ADI/.venv/lib/python3.9/site-packages/sphinx/events.py", line 107, in emit
    raise ExtensionError(__("Handler %r for event %r threw an exception") %
sphinx.errors.ExtensionError: Handler <function add_references at 0x1097abf70> for event 'doctree-resolved' threw an exception (exception: ('shared/terms', None))

Extension error (directives.properties):
Handler <function add_references at 0x1097abf70> for event 'doctree-resolved' threw an exception (exception: ('shared/terms', None))

Source files

rinoh/frontend/sphinx/__init__.py get_target_uri

Versions

rinohtype 0.5.4 (2022-06-17)
Sphinx 7.1.1
Python 3.9.6 (default, Nov 10 2023, 13:38:27) 
[Clang 15.0.0 (clang-1500.1.0.2.5)]
macOS-14.2.1-arm64-arm-64bit
@mason3k mason3k added bug crash rinohtype aborts due to an uncaught exception labels Jan 16, 2024
@mason3k
Copy link
Author

mason3k commented Jan 16, 2024

I think this is because the page in question is an orphan. Thus, it will not be located when traversing the table of contents. I suggest the following change:

    def get_target_uri(self, docname, typ=None):
        if docname not in self.env.all_docs: # this is my code replacing the line below
        # if docname not in self._docnames:
            raise NoUri(docname, typ)
        else:
            return '%' + docname

@brechtm
Copy link
Owner

brechtm commented Jan 17, 2024

Thanks for the bug report and suggested fix!

Can you provide a (preferably minimal) Sphinx project that triggers the bug?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug crash rinohtype aborts due to an uncaught exception
Projects
None yet
Development

No branches or pull requests

2 participants