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

Type error in plugin.py #72

Closed
michaelkjohnston opened this issue Apr 2, 2020 · 9 comments
Closed

Type error in plugin.py #72

michaelkjohnston opened this issue Apr 2, 2020 · 9 comments
Labels
bug Something isn't working

Comments

@michaelkjohnston
Copy link

michaelkjohnston commented Apr 2, 2020

This is the error I'm getting trying to run mkdocs build. I had everything working in a previous version (prior to removal of documenter.py).

C:\Users\u609587\Desktop\oompa>mkdocs build
INFO    -  Cleaning site directory
INFO    -  Building documentation to directory: C:\Users\u609587\Desktop\oompa\site
ERROR   -  Error reading page 'index.md': unsupported operand type(s) for +: 'NoneType' and 'str'
Traceback (most recent call last):
  File "c:\users\u609587\appdata\local\continuum\anaconda3\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\users\u609587\appdata\local\continuum\anaconda3\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\u609587\AppData\Local\Continuum\anaconda3\Scripts\mkdocs.exe\__main__.py", line 9, in <module>
  File "c:\users\u609587\appdata\local\continuum\anaconda3\lib\site-packages\click\core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "c:\users\u609587\appdata\local\continuum\anaconda3\lib\site-packages\click\core.py", line 717, in main
    rv = self.invoke(ctx)
  File "c:\users\u609587\appdata\local\continuum\anaconda3\lib\site-packages\click\core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "c:\users\u609587\appdata\local\continuum\anaconda3\lib\site-packages\click\core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "c:\users\u609587\appdata\local\continuum\anaconda3\lib\site-packages\click\core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "c:\users\u609587\appdata\local\continuum\anaconda3\lib\site-packages\mkdocs\__main__.py", line 159, in build_command
    build.build(config.load_config(**kwargs), dirty=not clean)
  File "c:\users\u609587\appdata\local\continuum\anaconda3\lib\site-packages\mkdocs\commands\build.py", line 274, in build
    _populate_page(file.page, config, files, dirty)
  File "c:\users\u609587\appdata\local\continuum\anaconda3\lib\site-packages\mkdocs\commands\build.py", line 178, in _populate_page
    'page_content', page.content, page=page, config=config, files=files
  File "c:\users\u609587\appdata\local\continuum\anaconda3\lib\site-packages\mkdocs\plugins.py", line 94, in run_event
    result = method(item, **kwargs)
  File "c:\users\u609587\appdata\local\continuum\anaconda3\lib\site-packages\mkdocstrings\plugin.py", line 160, in on_page_content
    self.map_urls(page.canonical_url, item)
  File "c:\users\u609587\appdata\local\continuum\anaconda3\lib\site-packages\mkdocstrings\plugin.py", line 173, in map_urls
    self.url_map[anchor.id] = base_url + anchor.url
TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'

This is what index.md looks like:

# Welcome to OOMPA Documentation

This site documents the OOMPA Library.

Supported model classes:

- [Error Correction / Auto Regressive Distributed Lag](ardl.md)
- [Double/Debiased Machine Learning](dml.md)

Supporting utilities and superclasses:

- [Comments](comment.md)
- [Pandas Extras](pandas_extras.md)

any advice?

@pawamoy
Copy link
Member

pawamoy commented Apr 2, 2020

Did you define a site_url in mkdocs.yml? It seems page.canonical gives None.

@michaelkjohnston
Copy link
Author

I had not defined site_url but after doing so, the error goes away. Thank you very much!

Now it gives a new error, relating to Windows. I know there were some Windows compatibility issues in previous versions, but seems like those path issues #42 have been fixed.

The issue I have now is the same as in #67 but you mention the conda environment is not supported? For the previous version I fixed the path issues in #42 manually and I was able to get things to run at the Anaconda prompt on Windows. I have Gow installed so there is some basic POSIX compatibility. Any tips? Should I use another shell?

Current error:

(base) C:\Users\u609587\Desktop\oompa>mkdocs build
INFO    -  Cleaning site directory
INFO    -  Building documentation to directory: C:\Users\u609587\Desktop\oompa\site
ERROR   -  Error reading page 'ardl.md': 'WindowsPath' object is not iterable
Traceback (most recent call last):
  File "c:\users\u609587\appdata\local\continuum\anaconda3\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\users\u609587\appdata\local\continuum\anaconda3\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\u609587\AppData\Local\Continuum\anaconda3\Scripts\mkdocs.exe\__main__.py", line 9, in <module>
  File "c:\users\u609587\appdata\local\continuum\anaconda3\lib\site-packages\click\core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "c:\users\u609587\appdata\local\continuum\anaconda3\lib\site-packages\click\core.py", line 717, in main
    rv = self.invoke(ctx)
  File "c:\users\u609587\appdata\local\continuum\anaconda3\lib\site-packages\click\core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "c:\users\u609587\appdata\local\continuum\anaconda3\lib\site-packages\click\core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "c:\users\u609587\appdata\local\continuum\anaconda3\lib\site-packages\click\core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "c:\users\u609587\appdata\local\continuum\anaconda3\lib\site-packages\mkdocs\__main__.py", line 159, in build_command
    build.build(config.load_config(**kwargs), dirty=not clean)
  File "c:\users\u609587\appdata\local\continuum\anaconda3\lib\site-packages\mkdocs\commands\build.py", line 274, in build
    _populate_page(file.page, config, files, dirty)
  File "c:\users\u609587\appdata\local\continuum\anaconda3\lib\site-packages\mkdocs\commands\build.py", line 174, in _populate_page
    page.render(config, files)
  File "c:\users\u609587\appdata\local\continuum\anaconda3\lib\site-packages\mkdocs\structure\pages.py", line 183, in render
    self.content = md.convert(self.markdown)
  File "c:\users\u609587\appdata\local\continuum\anaconda3\lib\site-packages\markdown\core.py", line 265, in convert
    root = self.parser.parseDocument(self.lines).getroot()
  File "c:\users\u609587\appdata\local\continuum\anaconda3\lib\site-packages\markdown\blockparser.py", line 90, in parseDocument
    self.parseChunk(self.root, '\n'.join(lines))
  File "c:\users\u609587\appdata\local\continuum\anaconda3\lib\site-packages\markdown\blockparser.py", line 105, in parseChunk
    self.parseBlocks(parent, text.split('\n\n'))
  File "c:\users\u609587\appdata\local\continuum\anaconda3\lib\site-packages\markdown\blockparser.py", line 123, in parseBlocks
    if processor.run(parent, blocks) is not False:
  File "c:\users\u609587\appdata\local\continuum\anaconda3\lib\site-packages\mkdocstrings\extension.py", line 118, in run
    handler = get_handler(handler_name, self._config["theme_name"])
  File "c:\users\u609587\appdata\local\continuum\anaconda3\lib\site-packages\mkdocstrings\handlers\__init__.py", line 231, in get_handler
    HANDLERS_CACHE[name] = module.get_handler(theme)
  File "c:\users\u609587\appdata\local\continuum\anaconda3\lib\site-packages\mkdocstrings\handlers\python.py", line 244, in get_handler
    return PythonHandler(collector=PythonCollector(), renderer=PythonRenderer("python", theme))
  File "c:\users\u609587\appdata\local\continuum\anaconda3\lib\site-packages\mkdocstrings\handlers\__init__.py", line 124, in __init__
    self.env = Environment(autoescape=True, loader=FileSystemLoader(theme_dir))
  File "c:\users\u609587\appdata\local\continuum\anaconda3\lib\site-packages\jinja2\loaders.py", line 163, in __init__
    self.searchpath = list(searchpath)
TypeError: 'WindowsPath' object is not iterable

@michaelkjohnston
Copy link
Author

Also thank you for your help :) 👍 🥇

@pawamoy
Copy link
Member

pawamoy commented Apr 3, 2020

You're welcome! I see it's the same WindowsPath error as before. I'll debug this today :)

@pawamoy
Copy link
Member

pawamoy commented Apr 3, 2020

I cannot reproduce. I tried on Windows with Python 3.8 (classic install) and Python 3.7 (miniconda install, though not in a conda env because I cannot get it to work, it's error on error, damn windows), and it was working correctly. What's your version of:

  • mkdocstrings?
  • python?
  • jinja2?

Could you try in a classic venv (not a conda env) to see if the issue happens there as well?

@pawamoy pawamoy added the bug Something isn't working label Apr 3, 2020
@michaelkjohnston
Copy link
Author

This was with jinja2 2.10.3. Upgrading to Jinja2-2.11.1 fixed the issue. Thank you so much!!

@pawamoy
Copy link
Member

pawamoy commented Apr 3, 2020

Great, good to know 🎉 ! I'll add a paragraph in the troubleshooting section.

@pawamoy
Copy link
Member

pawamoy commented Apr 3, 2020

Actually I should maybe also add jinja2 = "^2.11.1" as a dependency.

EDIT: or simply convert the Path to str before passing it to the Env constructor 😅

pawamoy added a commit that referenced this issue Apr 3, 2020
Versions of Jinja2 before 2.11 (or 2.11.1)
crash when a Path-like object is given
to the `FileSystemLoader` constructor.

We fix this simply by casting the Path object
to a string.

See issues #67 and #72.
@michaelkjohnston
Copy link
Author

Okay, great. Thanks again. Seems like this should help a few people :) Appreciate your project, it's helping me create some really slick documentation.

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

2 participants