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

Error when including apidoc generated files #73

Closed
nunupeke opened this issue Aug 26, 2021 · 2 comments
Closed

Error when including apidoc generated files #73

nunupeke opened this issue Aug 26, 2021 · 2 comments
Labels
bug Something isn't working

Comments

@nunupeke
Copy link

Describe the problem

If I include sphinx apidoc generated files which contain :toctree: directives themselves, I get

File "site-packages\sphinx_jupyterbook_latex\transforms.py", line 300, in apply
KeyError: 'hidden'

when I run

jb build

I wonder why that line is ever called since I don't build anything latex related.

Link to your repository or website

No response

Steps to reproduce

  1. add sphinx apidoc generated rst-files like

    API Reference
    =============
    
    .. rubric:: Modules
    
    .. autosummary::
        :toctree: _generate
    
        module1
        module2
    

    to the docs folder.

  2. run jb build

The version of Python you're using

No response

Your operating system

No response

Versions of your packages

Jupyter Book : 0.11.2
External ToC : 0.2.2
MyST-Parser : 0.13.7
MyST-NB : 0.12.3
Sphinx Book Theme : 0.1.1
Jupyter-Cache : 0.4.3
NbClient : 0.5.4

Additional context

My current workaround is to change

if tocnode.attributes["hidden"]:

into

if "hidden" in tocnode.attributes and tocnode.attributes["hidden"]:
    continue

The error first occurred when updating to jupyter-book v0.11, which uses sphinx-external-toc. Therefore executablebooks/sphinx-external-toc#36 may be related.

@nunupeke nunupeke added the bug Something isn't working label Aug 26, 2021
@welcome
Copy link

welcome bot commented Aug 26, 2021

Thanks for opening your first issue here! Engagement like this is essential for open source projects! 🤗

If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.

If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).

Welcome to the EBP community! 🎉

Jegp added a commit to Jegp/sphinx-jupyterbook-latex that referenced this issue Aug 29, 2021
@tlambert03
Copy link

I'm also having this issue (preventing docs from building on CI at the moment)

jupyter-book 0.11.3
Sphinx 3.5.4
docutils 0.16

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!
Traceback (most recent call last):
  File "/Users/talley/miniconda3/envs/docs/lib/python3.9/site-packages/jupyter_book/sphinx.py", line 167, in build_sphinx
    app.build(force_all, filenames)
  File "/Users/talley/miniconda3/envs/docs/lib/python3.9/site-packages/sphinx/application.py", line 352, in build
    self.builder.build_update()
  File "/Users/talley/miniconda3/envs/docs/lib/python3.9/site-packages/sphinx/builders/__init__.py", line 296, in build_update
    self.build(to_build,
  File "/Users/talley/miniconda3/envs/docs/lib/python3.9/site-packages/sphinx/builders/__init__.py", line 310, in build
    updated_docnames = set(self.read())
  File "/Users/talley/miniconda3/envs/docs/lib/python3.9/site-packages/sphinx/builders/__init__.py", line 417, in read
    self._read_serial(docnames)
  File "/Users/talley/miniconda3/envs/docs/lib/python3.9/site-packages/sphinx/builders/__init__.py", line 438, in _read_serial
    self.read_doc(docname)
  File "/Users/talley/miniconda3/envs/docs/lib/python3.9/site-packages/sphinx/builders/__init__.py", line 478, in read_doc
    doctree = read_doc(self.app, self.env, self.env.doc2path(docname))
  File "/Users/talley/miniconda3/envs/docs/lib/python3.9/site-packages/sphinx/io.py", line 221, in read_doc
    pub.publish()
  File "/Users/talley/miniconda3/envs/docs/lib/python3.9/site-packages/docutils/core.py", line 219, in publish
    self.apply_transforms()
  File "/Users/talley/miniconda3/envs/docs/lib/python3.9/site-packages/docutils/core.py", line 200, in apply_transforms
    self.document.transformer.apply_transforms()
  File "/Users/talley/miniconda3/envs/docs/lib/python3.9/site-packages/sphinx/transforms/__init__.py", line 86, in apply_transforms
    super().apply_transforms()
  File "/Users/talley/miniconda3/envs/docs/lib/python3.9/site-packages/docutils/transforms/__init__.py", line 171, in apply_transforms
    transform.apply(**kwargs)
  File "/Users/talley/miniconda3/envs/docs/lib/python3.9/site-packages/sphinx_jupyterbook_latex/transforms.py", line 300, in apply
    if tocnode.attributes["hidden"]:
KeyError: 'hidden'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants