mkdocs-multirepo-plugin icon indicating copy to clipboard operation
mkdocs-multirepo-plugin copied to clipboard

multirepo-plugin 0.6.0 exception when edit_uri is not explicitly set

Open hjoukl opened this issue 2 years ago • 0 comments

v0.6.0: When neither importing nor imported mkdocs projects have edit_uri set multirepo-plugin fails with this exception:

mkdocs build
INFO     -  Multirepo plugin importing docs...
Traceback (most recent call last):
  File ".venv/python3.8/dev/bin/mkdocs", line 8, in <module>
    sys.exit(cli())
  File ".venv/python3.8/dev/lib64/python3.8/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File ".venv/python3.8/dev/lib64/python3.8/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File ".venv/python3.8/dev/lib64/python3.8/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File ".venv/python3.8/dev/lib64/python3.8/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File ".venv/python3.8/dev/lib64/python3.8/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File ".venv/python3.8/dev/lib64/python3.8/site-packages/mkdocs/__main__.py", line 250, in build_command
    build.build(cfg, dirty=not clean)
  File ".venv/python3.8/dev/lib64/python3.8/site-packages/mkdocs/commands/build.py", line 270, in build
    config = config.plugins.run_event('config', config)
  File ".venv/python3.8/dev/lib64/python3.8/site-packages/mkdocs/plugins.py", line 520, in run_event
    result = method(item, **kwargs)
  File ".venv/python3.8/dev/lib64/python3.8/site-packages/mkdocs_multirepo_plugin/plugin.py", line 315, in on_config
    return self.handle_repos_import(config, repos)
  File ".venv/python3.8/dev/lib64/python3.8/site-packages/mkdocs_multirepo_plugin/plugin.py", line 224, in handle_repos_import
    DocsRepo(
  File ".venv/python3.8/dev/lib64/python3.8/site-packages/mkdocs_multirepo_plugin/structure.py", line 274, in __init__
    self.edit_uri = self._fix_edit_uri(edit_uri)
  File ".venv/python3.8/dev/lib64/python3.8/site-packages/mkdocs_multirepo_plugin/structure.py", line 241, in _fix_edit_uri
    edit_uri_parts = edit_uri.strip("/").split("/")
AttributeError: 'NoneType' object has no attribute 'strip'

This didn't happen for multirepo-plugin v0.4.12 so I suspect the edit_uri changed in #75 might have introduced the problem.

Workaround: Set e.g. edit_uri to the same value as repo_url in the importing repo's mkdocs.yml. While normally edit_uri is supposed to be a relative path an absolute path is also possible. Seems like this reproduces 0.4.12-behaviour but I've not fully understood the mkdocs edit_uri stuff yet.

Maybe the simple fix might also be to fall back to repo_url as the edit_uri default value?

Best regards, Holger

hjoukl avatar Feb 24 '23 16:02 hjoukl