lukasgeiter / mkdocs-awesome-pages-plugin

An MkDocs plugin that simplifies configuring page titles and their order
MIT License
472 stars 36 forks source link

KeyError: SectionPage #46

Closed ghost closed 2 years ago

ghost commented 2 years ago

Probably something silly, but I'm having problems with this:

INFO     -  Cleaning site directory
INFO     -  Building documentation to directory: /builds/docs/sandbox/sandbox-project/site
Traceback (most recent call last):
  File "/usr/local/bin/mkdocs", line 8, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 1137, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 1062, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 1668, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.8/site-packages/click/core.py", line 763, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/mkdocs/__main__.py", line 183, in build_command
    build.build(config.load_config(**kwargs), dirty=not clean)
  File "/usr/local/lib/python3.8/site-packages/mkdocs/commands/build.py", line 279, in build
    nav = config['plugins'].run_event('nav', nav, config=config, files=files)
  File "/usr/local/lib/python3.8/site-packages/mkdocs/plugins.py", line 94, in run_event
    result = method(item, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/mkdocs_awesome_pages_plugin/plugin.py", line 45, in on_nav
    return AwesomeNavigation(nav.items, Options(**self.config), config['docs_dir'], explicit_sections).to_mkdocs()
  File "/usr/local/lib/python3.8/site-packages/mkdocs_awesome_pages_plugin/navigation.py", line 51, in __init__
    self.items = self._process_children(
  File "/usr/local/lib/python3.8/site-packages/mkdocs_awesome_pages_plugin/navigation.py", line 65, in _process_children
    item = self._process_section(item, collapse)
  File "/usr/local/lib/python3.8/site-packages/mkdocs_awesome_pages_plugin/navigation.py", line 127, in _process_section
    meta = self.meta.sections[section]
KeyError: SectionPage(title='About', url='/about/')

Apparently I'm doing something wrong with the setup somewhere?

tspthomas commented 2 years ago

@moronic , can you share how you solved that? I'm seeing a similar issue in one specific documentation I have.

ghost commented 2 years ago

It suddenly went away and I don't know why.

I still have section-index enabled, but it is the last plugin in the list.

tspthomas commented 2 years ago

It looks like that is the case. I believe for some reason if section-index comes before this plugin in the list, it doesn't work. I also changed the order and it worked just fine.

Thanks for answering it here :)