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

'NoneType' object has no attribute 'walk' #51

Closed
danwos opened this issue Mar 24, 2022 · 3 comments · Fixed by #52
Closed

'NoneType' object has no attribute 'walk' #51

danwos opened this issue Mar 24, 2022 · 3 comments · Fixed by #52

Comments

@danwos
Copy link
Contributor

danwos commented Mar 24, 2022

I get the following error if I try to use sphinx-immaterial with a fresh sphinx project, created by sphinx-quickstart.

Extension error (sphinx_immaterial.nav_adapt):
Handler <function _html_page_context at 0x7f47a41e1c60> for event 'html-page-context' threw an exception (exception: 'NoneType' object has no attribute 'walk')

The reason is, that you need a toctree directive and at least one additional rst-file, which must be mentioned in the toctree directive.

So this does not work (index.rst):

Project
=======
Test me

This does also not work:

Project
=======
Test me

.. toctree::

but this works:

Project
=======
Test me

.. toctree::

   page.rst

The problematic code is inside nav_adapt.py:

def _get_mkdocs_toc(
    toc_node: docutils.nodes.Node, builder: sphinx.builders.Builder
) -> List[MkdocsNavEntry]:
    """Converts a docutils toc node into a mkdocs-format JSON toc."""
    visitor = _TocVisitor(sphinx.util.docutils.new_document(""), builder)
    toc_node.walk(visitor)
    return visitor._children

and there toc_node can be None for small documentation projects.

danwos added a commit to danwos/sphinx-immaterial that referenced this issue Mar 24, 2022
If there are no toctree elements, no deeper node-walk
is performed anymore.

Fixes jbms#51
@danwos
Copy link
Contributor Author

danwos commented Mar 24, 2022

Added really small PR to fix this issue: #52

@2bndy5
Copy link
Collaborator

2bndy5 commented Mar 24, 2022

Could this be related to #41 ?

@jbms jbms closed this as completed in #52 Mar 24, 2022
jbms pushed a commit that referenced this issue Mar 24, 2022
If there are no toctree elements, no deeper node-walk
is performed anymore.

Fixes #51
@jbms
Copy link
Owner

jbms commented Mar 24, 2022

Thanks -- I merged your PR.

I don't think it is related to #41.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants