NiklasRosenstein / pydoc-markdown

Create Python API documentation in Markdown format.
http://niklasrosenstein.github.io/pydoc-markdown/
Other
460 stars 105 forks source link

GithubSourceLinker error on 4.6.0+ #250

Closed MilesCranmer closed 2 years ago

MilesCranmer commented 2 years ago

Environment

Describe the bug

Starting on v4.6.0, when I run pydoc-markdown --build --site-dir build -vv on the base of my library PySR, I see the following error:

[INFO - pydoc_markdown]: Loading configuration file "pydoc-markdown.yml".
[DEBUG - pydoc_markdown]: Initializing plugins with context <pydoc_markdown.interfaces.Context object at 0x1057123d0>
[DEBUG - pydoc_markdown.contrib.source_linkers.git]: project_root = '/Users/mcranmer/Documents/PySR'
[DEBUG - pydoc_markdown.contrib.source_linkers.git]: sha = '1669536965d55685099d5cf72c4dee520f3bcae4'
Traceback (most recent call last):
  File "/Users/mcranmer/venvs/main/bin/pydoc-markdown", line 8, in <module>
    sys.exit(cli())
  File "/Users/mcranmer/venvs/main/lib/python3.8/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/Users/mcranmer/venvs/main/lib/python3.8/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/Users/mcranmer/venvs/main/lib/python3.8/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/mcranmer/venvs/main/lib/python3.8/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/Users/mcranmer/venvs/main/lib/python3.8/site-packages/pydoc_markdown/main.py", line 331, in cli
    pydocmd = session.load()
  File "/Users/mcranmer/venvs/main/lib/python3.8/site-packages/pydoc_markdown/main.py", line 124, in load
    config.init(Context(directory=os.path.dirname(os.path.abspath(self.config))))
  File "/Users/mcranmer/venvs/main/lib/python3.8/site-packages/pydoc_markdown/__init__.py", line 139, in init
    self.renderer.init(context)
  File "/Users/mcranmer/venvs/main/lib/python3.8/site-packages/pydoc_markdown/contrib/renderers/hugo.py", line 352, in init
    self.markdown.init(context)
  File "/Users/mcranmer/venvs/main/lib/python3.8/site-packages/pydoc_markdown/contrib/renderers/markdown.py", line 470, in init
    self.source_linker.init(context)
  File "/Users/mcranmer/venvs/main/lib/python3.8/site-packages/pydoc_markdown/contrib/source_linkers/git.py", line 140, in init
    logger.debug('branch = %r', self._branch)
AttributeError: 'GithubSourceLinker' object has no attribute '_branch'

If I force the installation of pydoc-markdown to 4.5.0, this error goes away.

My configuration file can be seen here: https://github.com/MilesCranmer/PySR/blob/1669536965d55685099d5cf72c4dee520f3bcae4/pydoc-markdown.yml

NiklasRosenstein commented 2 years ago

Hey, thanks for reporting. In trying to fix an issue if your worktree doesn't point to a branch, I introduced another bug.

I'm AFK until EOW, but if you want to create a PR I can review it from my phone.

NiklasRosenstein commented 2 years ago

Fixed in 4.6.2

MilesCranmer commented 2 years ago

Thanks!