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

[Bug] mkdocstrings unable to parse custom theme directory configuration #120

Closed
abhiTronix opened this issue Jun 5, 2020 · 0 comments · Fixed by #121
Closed

[Bug] mkdocstrings unable to parse custom theme directory configuration #120

abhiTronix opened this issue Jun 5, 2020 · 0 comments · Fixed by #121

Comments

@abhiTronix
Copy link
Contributor

abhiTronix commented Jun 5, 2020

Hello,

mkdocstrings is incompatible with mkdocs-material's custom_dir configuration:

theme:
  name: null
  custom_dir: mkdocs-material/material

and thereby fails with following error:

DEBUG   -  Reading: api.md 
DEBUG   -  mkdocstrings.extension: Matched '::: vidgear.gears' 
DEBUG   -  mkdocstrings.extension: Using handler 'python' 
DEBUG   -  mkdocstrings.handlers.python: Opening 'pytkdocs' subprocess 
ERROR   -  Error reading page 'api.md': expected str, bytes or os.PathLike object, not NoneType 
Traceback (most recent call last):
  File "/usr/local/bin/mkdocs", line 8, in <module>
    sys.exit(cli())
  File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.6/dist-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/mkdocs/__main__.py", line 136, in serve_command
    **kwargs
  File "/usr/local/lib/python3.6/dist-packages/mkdocs/commands/serve.py", line 141, in serve
    config = builder()
  File "/usr/local/lib/python3.6/dist-packages/mkdocs/commands/serve.py", line 136, in builder
    build(config, live_server=live_server, dirty=dirty)
  File "/usr/local/lib/python3.6/dist-packages/mkdocs/commands/build.py", line 271, in build
    _populate_page(file.page, config, files, dirty)
  File "/usr/local/lib/python3.6/dist-packages/mkdocs/commands/build.py", line 171, in _populate_page
    page.render(config, files)
  File "/usr/local/lib/python3.6/dist-packages/mkdocs/structure/pages.py", line 175, in render
    self.content = md.convert(self.markdown)
  File "/usr/local/lib/python3.6/dist-packages/markdown/core.py", line 265, in convert
    root = self.parser.parseDocument(self.lines).getroot()
  File "/usr/local/lib/python3.6/dist-packages/markdown/blockparser.py", line 90, in parseDocument
    self.parseChunk(self.root, '\n'.join(lines))
  File "/usr/local/lib/python3.6/dist-packages/markdown/blockparser.py", line 105, in parseChunk
    self.parseBlocks(parent, text.split('\n\n'))
  File "/usr/local/lib/python3.6/dist-packages/markdown/blockparser.py", line 123, in parseBlocks
    if processor.run(parent, blocks) is not False:
  File "/usr/local/lib/python3.6/dist-packages/mkdocstrings/extension.py", line 140, in run
    **handler_config,
  File "/usr/local/lib/python3.6/dist-packages/mkdocstrings/handlers/__init__.py", line 233, in get_handler
    HANDLERS_CACHE[name] = module.get_handler(theme, custom_templates, **config)  # type: ignore
  File "/usr/local/lib/python3.6/dist-packages/mkdocstrings/handlers/python.py", line 249, in get_handler
    renderer=PythonRenderer("python", theme, custom_templates),
  File "/usr/local/lib/python3.6/dist-packages/mkdocstrings/handlers/__init__.py", line 118, in __init__
    paths.append(themes_dir / theme)
  File "/usr/lib/python3.6/pathlib.py", line 899, in __truediv__
    return self._make_child((key,))
  File "/usr/lib/python3.6/pathlib.py", line 686, in _make_child
    drv, root, parts = self._parse_args(args)
  File "/usr/lib/python3.6/pathlib.py", line 640, in _parse_args
    a = os.fspath(a)
TypeError: expected str, bytes or os.PathLike object, not NoneType
@abhiTronix abhiTronix changed the title [Bug] mkdocstrings unable to parse custom theme in Material for MkDocs [Bug] mkdocstrings unable to parse custom theme directory configuration Jun 5, 2020
abhiTronix added a commit to abhiTronix/mkdocstrings that referenced this issue Jun 5, 2020
This fixes the mkdocs-material's custom_dir configuration, where theme `name` is set to null in mkdocs.yaml.
Thereby, this fix adds support to automatically read theme_name from `dirs` attribute, if `name` attribute is None(null), otherwise default behaviour will occur.

Fixes mkdocstrings#120.
pawamoy pushed a commit that referenced this issue Jun 7, 2020
This fixes the mkdocs-material's `custom_dir` configuration,
where theme `name` is set to null in mkdocs.yaml.
Thereby, this fix adds support to automatically read `theme_name` from `dirs` attribute,
if `name` attribute is None (null), otherwise default behaviour will occur.

Fixes #120.
PR #121.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant