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

TypeError: 'NoneType' object is not iterable #9

Closed
Amber1990Zhang opened this issue Nov 27, 2019 · 8 comments
Closed

TypeError: 'NoneType' object is not iterable #9

Amber1990Zhang opened this issue Nov 27, 2019 · 8 comments
Labels
bug Something isn't working
Milestone

Comments

@Amber1990Zhang
Copy link

Amber1990Zhang commented Nov 27, 2019

Some errors happened when I run mkdocs serve. The errors as follow:

INFO    -  Building documentation...
Unable to revert mtime: /Library/Fonts
INFO    -  Cleaning site directory
WARNING -  A relative path to '../' is included in the 'nav' configuration, which is not found in the documentation files
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.7/bin/mkdocs", line 10, in <module>
    sys.exit(cli())
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/mkdocs/__main__.py", line 134, in serve_command
    livereload=livereload
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/mkdocs/commands/serve.py", line 119, in serve
    config = builder()
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/mkdocs/commands/serve.py", line 114, in builder
    build(config, live_server=live_server, dirty=dirty)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/mkdocs/commands/build.py", line 270, in build
    nav = config['plugins'].run_event('nav', nav, config=config, files=files)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/mkdocs/plugins.py", line 94, in run_event
    result = method(item, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/mkpdfs_mkdocs/mkpdfs.py", line 44, in on_nav
    self.generator.add_nav(nav)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/mkpdfs_mkdocs/generator.py", line 66, in add_nav
    self.addToOrder(p)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/mkpdfs_mkdocs/generator.py", line 89, in addToOrder
    for child in page.children:
TypeError: 'NoneType' object is not iterable

This is my yaml file:

site_name: mkdocs versions
repo_url: https://github.com/Amber1990Zhang/versions
repo_name: versions
theme: 'material'
edit_uri: ''
plugins:
  - mkdocs-versioning:
      version: 1.1.0
  # - mkpdfs
nav:
  - Home : 'index.md'
  - Circle: 'circle.md'
  - Triangle: 'triangle.md'
  - Version: '../'

Please help, thanks.

@kruzfuz
Copy link

kruzfuz commented Jan 15, 2020

I'm having the same issue. Have there been any findings on your side in the meantime?

@kruzfuz
Copy link

kruzfuz commented Jan 16, 2020

If it's of any help to anybody: we realized that the build process fails if mkpdfs cannot find a file where an item in the nav configuration is declared. For you @Amber1990Zhang, that means it is possible that mkpdfs is looking for a file for the "Version" entry in your nav section but cannot find one, and that's why you receive the error message. I hope that helps!

@Amber1990Zhang
Copy link
Author

@kruzfuz thanks for your reply, I removed version information this time but it's not working either.

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.7/bin/mkdocs", line 10, in <module>
    sys.exit(cli())
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/mkdocs/__main__.py", line 163, in build_command
    ), dirty=not clean)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/mkdocs/commands/build.py", line 298, in build
    config['plugins'].run_event('post_build', config)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/mkdocs/plugins.py", line 94, in run_event
    result = method(item, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/mkpdfs_mkdocs/mkpdfs.py", line 64, in on_post_build
    self.generator.write()
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/mkpdfs_mkdocs/generator.py", line 53, in write
    self.gen_articles()
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/mkpdfs_mkdocs/generator.py", line 168, in gen_articles
    self.add_tocs()
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/mkpdfs_mkdocs/generator.py", line 154, in add_tocs
    self._gen_toc_section(n)
  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/mkpdfs_mkdocs/generator.py", line 186, in _gen_toc_section
    stoc = self._gen_toc_for_section(p.file.url, p)
AttributeError: 'Section' object has no attribute 'file'

@comwes
Copy link
Owner

comwes commented Feb 3, 2020

Hello @kruzfuz and @Amber1990Zhang,

Currently I'm quite busy at work and will look into this issue as soon as possible.

KR,
Gerry N

@comwes comwes added the bug Something isn't working label Feb 3, 2020
@jwaschkau
Copy link
Contributor

jwaschkau commented Mar 24, 2020

I think the plugin has a problem with mkdocs>=1.1.

I am using mkdocs < 1.1 without a problem.

@igordejanovic
Copy link

I'm having the same issue. Did a quick debugging session and found out that the break occurs if the page is given in the mkdocs nav configuration is a URL. Are links supported in the nav?

@jwaschkau
Copy link
Contributor

I'm having the same issue. Did a quick debugging session and found out that the break occurs if the page is given in the mkdocs nav configuration is a URL. Are links supported in the nav?

I opened a PR ( #26 ) which excludes external links. I think this is the best solution for now as i am not sure how to represent external links in the generated pdf.

@comwes
Copy link
Owner

comwes commented May 18, 2021

This should be fixed in the upcoming version. Probably fixed by #8

@comwes comwes closed this as completed May 18, 2021
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

No branches or pull requests

5 participants