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

Impossible to run mkdocstrings example #67

Closed
Acruve15 opened this issue Mar 29, 2020 · 4 comments
Closed

Impossible to run mkdocstrings example #67

Acruve15 opened this issue Mar 29, 2020 · 4 comments
Labels
bug Something isn't working

Comments

@Acruve15
Copy link

Hi there,
I've been trying to use mkdocstrings, but when I run mkdocs serve this is the error I have:

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

My requirements are:
mkdocs==1.1
mkdocs-material==4.6.3
mkdocstrings==0.10.0

Basically, it seems that my searchpath is a WindowsPath type and not a list. But I have no clue how to solve this. Could you help me with this please ?

(I tried to run mkdocs on the mkdocstrings library locally)

Thanks :)

@Acruve15
Copy link
Author

incompatible with conda virtualenv

@pawamoy
Copy link
Member

pawamoy commented Mar 29, 2020

What's your Jinja2 version? It seems a WindowsPath is recognized as iterable while a PosixPath is not 😕 ?

I've got this in my installed jinja2, 2.11.1:

        if not isinstance(searchpath, abc.Iterable) or isinstance(
            searchpath, string_types
        ):
            searchpath = [searchpath]

This is jinja2's master branch:

        if not isinstance(searchpath, abc.Iterable) or isinstance(searchpath, str):
            searchpath = [searchpath]

@pawamoy pawamoy reopened this Mar 29, 2020
@pawamoy
Copy link
Member

pawamoy commented Mar 29, 2020

incompatible with conda virtualenv

What's incompatible exactly 🙂 ?

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

pawamoy commented Apr 3, 2020

Based on this comment, it seems you can fix this by upgrading Jinja2.

@pawamoy pawamoy closed this as completed Apr 3, 2020
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.
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