daizutabi/pheasant

mkdocs fails to build documentation with pheasant if 'nav' isn't specified

devakker opened this issue · 2 comments

INFO    -  Building documentation...
INFO    -  [Pheasant] Converter configured.
[E 190430 12:41:12 ioloop:909] Exception in callback <bound method LiveReloadHandler.poll_tasks of <class 'livereload.handlers.LiveReloadHandler'>>
    Traceback (most recent call last):
      File "c:\users\devakker\.virtualenvs\mkdocs-0c6u1w8u\lib\site-packages\tornado\ioloop.py", line 907, in _run
        return self.callback()
      File "c:\users\devakker\.virtualenvs\mkdocs-0c6u1w8u\lib\site-packages\livereload\handlers.py", line 66, in poll_tasks
        filepath, delay = cls.watcher.examine()
      File "c:\users\devakker\.virtualenvs\mkdocs-0c6u1w8u\lib\site-packages\livereload\watcher.py", line 93, in examine
        func()
      File "c:\users\devakker\.virtualenvs\mkdocs-0c6u1w8u\lib\site-packages\mkdocs\commands\serve.py", line 114, in builder
        build(config, live_server=live_server, dirty=dirty)
      File "c:\users\devakker\.virtualenvs\mkdocs-0c6u1w8u\lib\site-packages\mkdocs\commands\build.py", line 240, in build
        config = config['plugins'].run_event('config', config)
      File "c:\users\devakker\.virtualenvs\mkdocs-0c6u1w8u\lib\site-packages\mkdocs\plugins.py", line 94, in run_event
        result = method(item, **kwargs)
      File "c:\users\devakker\.virtualenvs\mkdocs-0c6u1w8u\lib\site-packages\pheasant\plugins\mkdocs.py", line 46, in on_config
        config["nav"] = build_nav(config["nav"], config["docs_dir"])
      File "c:\users\devakker\.virtualenvs\mkdocs-0c6u1w8u\lib\site-packages\pheasant\plugins\mkdocs.py", line 117, in build_nav
        for index, entry in enumerate(nav):
    TypeError: 'NoneType' object is not iterable

The bug only appears when the nav field in my mkdocs.yml is left empty. I always leave it empty because I prefer the default option:

default: By default nav will contain an alphanumerically sorted, nested list of all the Markdown files found within the docs_dir and its sub-directories. If none are found it will be [] (an empty list).

My site builds just fine without pheasant and the nav gets populated as it is supposed to.

minimal mkdocs.yml file:

site_name: test
site_author: me

plugins:
  - pheasant

If I add a basic nav in the config file it works fine.

site_name: test
site_author: me

plugins:
  - pheasant

nav:
  - Home: index.md

The bug was fixed in Version 2.2.22.

Thank you info about the nav default option.

Thanks a lot for fixing it!