NiklasRosenstein / pydoc-markdown

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

Command invocation fails on `4.x` #196

Closed ReubenFrankel closed 3 years ago

ReubenFrankel commented 3 years ago

Hello! 😄

I have been running pydoc-markdown as part of a CI/CD pipeline for a while now, which has been working great! Since the 4.x update, however, the same usage of pydoc-markdown has started failing with AttributeError: 'MarkdownReferenceResolver' object has no attribute 'update'.

In my case, downgrading to the latest 3.x version (pip install 'pydoc-markdown==3.x') resolved the issue, but I thought I should bring this to your attention anyway.

Script

pip install pydoc-markdown

echo "Generating SDK documentation"
OUTPUT_DIR=target/generated-snippets/sdk

mkdir -p $OUTPUT_DIR

pydoc-markdown -m my_module \
'
{
    renderer: {
        type: markdown,
        insert_header_anchors: false,
        code_headers: true,
        header_level_by_type: {
            Module: 2,
            Class: 2,
            Method: 3
        }
    }
}
' \
> $OUTPUT_DIR/library.md

Task Output

Collecting pydoc-markdown
2021-07-23T10:31:59.2178777Z   Downloading pydoc_markdown-4.1.2-py3-none-any.whl (59 kB)
2021-07-23T10:31:59.2180199Z Requirement already satisfied: toml<1.0.0,>=0.10.1 in /usr/lib/python3.9/site-packages (from pydoc-markdown) (0.10.2)
2021-07-23T10:31:59.2225977Z Collecting databind.json<2.0.0,>=1.0.0
2021-07-23T10:31:59.2277317Z   Downloading databind.json-1.0.1-py3-none-any.whl (16 kB)
2021-07-23T10:31:59.2325003Z Requirement already satisfied: click<8.0.0,>=7.0.0 in /usr/lib/python3.9/site-packages (from pydoc-markdown) (7.1.2)
2021-07-23T10:31:59.3367559Z Collecting databind.core<2.0.0,>=1.0.0
2021-07-23T10:31:59.3419621Z   Downloading databind.core-1.0.1-py3-none-any.whl (37 kB)
2021-07-23T10:31:59.4218238Z Collecting watchdog
2021-07-23T10:31:59.4277555Z   Downloading watchdog-2.1.3.tar.gz (109 kB)
2021-07-23T10:31:59.8467791Z Collecting nr.fs<2.0.0,>=1.6.0
2021-07-23T10:31:59.8518564Z   Downloading nr.fs-1.6.3-py2.py3-none-any.whl (13 kB)
2021-07-23T10:31:59.8568778Z Requirement already satisfied: PyYAML<6.0.0,>=5.3.0 in /usr/lib/python3.9/site-packages (from pydoc-markdown) (5.3.1)
2021-07-23T10:31:59.9503157Z Collecting nr.stream<1.0.0,>=0.1.2
2021-07-23T10:31:59.9554195Z   Downloading nr.stream-0.1.2-py3-none-any.whl (6.3 kB)
2021-07-23T10:31:59.9602333Z Requirement already satisfied: six<2.0.0,>=1.11.0 in /usr/lib/python3.9/site-packages (from pydoc-markdown) (1.15.0)
2021-07-23T10:32:00.0490075Z Collecting nr.collections<0.2.0,>=0.1.1
2021-07-23T10:32:00.0544663Z   Downloading nr.collections-0.1.1-py2.py3-none-any.whl (16 kB)
2021-07-23T10:32:00.0597832Z Requirement already satisfied: requests<3.0.0,>=2.23.0 in /usr/lib/python3.9/site-packages (from pydoc-markdown) (2.24.0)
2021-07-23T10:32:00.0784794Z Collecting docspec<2.0.0,>=1.0.0
2021-07-23T10:32:00.0838451Z   Downloading docspec-1.0.1-py3-none-any.whl (7.2 kB)
2021-07-23T10:32:00.1798343Z Collecting nr.pylang.utils<1.0.0,>=0.1.1
2021-07-23T10:32:00.1849202Z   Downloading nr.pylang.utils-0.1.3-py3-none-any.whl (12 kB)
2021-07-23T10:32:00.2070224Z Collecting docspec-python<2.0.0,>=1.0.0
2021-07-23T10:32:00.2129814Z   Downloading docspec_python-1.0.1-py3-none-any.whl (17 kB)
2021-07-23T10:32:00.3150807Z Collecting nr.optional<1.0.0,>=0.1.1
2021-07-23T10:32:00.3199652Z   Downloading nr.optional-0.1.1-py3-none-any.whl (3.0 kB)
2021-07-23T10:32:00.4152137Z Collecting nr.preconditions<1.0.0,>=0.0.4
2021-07-23T10:32:00.4200709Z   Downloading nr.preconditions-0.0.4-py3-none-any.whl (3.5 kB)
2021-07-23T10:32:00.5228079Z Collecting nr.parsing.date<2.0.0,>=1.0.1
2021-07-23T10:32:00.5281379Z   Downloading nr.parsing.date-1.0.2-py3-none-any.whl (12 kB)
2021-07-23T10:32:00.5489184Z Collecting typing-extensions<4.0.0,>=3.10.0
2021-07-23T10:32:00.5533589Z   Downloading typing_extensions-3.10.0.0-py3-none-any.whl (26 kB)
2021-07-23T10:32:00.6693787Z Collecting nr.metaclass<0.1.0,>=0.0.1
2021-07-23T10:32:00.6743021Z   Downloading nr.metaclass-0.0.6-py2.py3-none-any.whl (9.3 kB)
2021-07-23T10:32:00.7782987Z Collecting nr.utils.re<1.0.0,>=0.2.0
2021-07-23T10:32:00.7830715Z   Downloading nr.utils.re-0.3.1-py3-none-any.whl (4.3 kB)
2021-07-23T10:32:00.8186769Z Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in /usr/lib/python3.9/site-packages (from requests<3.0.0,>=2.23.0->pydoc-markdown) (1.25.11)
2021-07-23T10:32:00.8200746Z Requirement already satisfied: chardet<4,>=3.0.2 in /usr/lib/python3.9/site-packages (from requests<3.0.0,>=2.23.0->pydoc-markdown) (3.0.4)
2021-07-23T10:32:00.8217401Z Requirement already satisfied: idna<3,>=2.5 in /usr/lib/python3.9/site-packages (from requests<3.0.0,>=2.23.0->pydoc-markdown) (2.10)
2021-07-23T10:32:00.8228979Z Requirement already satisfied: certifi>=2017.4.17 in /usr/lib/python3.9/site-packages (from requests<3.0.0,>=2.23.0->pydoc-markdown) (2020.12.5)
2021-07-23T10:32:00.8636998Z Using legacy 'setup.py install' for watchdog, since package 'wheel' is not installed.
2021-07-23T10:32:01.1386663Z Installing collected packages: nr.utils.re, nr.pylang.utils, typing-extensions, nr.stream, nr.preconditions, nr.parsing.date, nr.optional, databind.core, databind.json, nr.metaclass, docspec, watchdog, nr.fs, nr.collections, docspec-python, pydoc-markdown
2021-07-23T10:32:01.3209550Z     Running setup.py install for watchdog: started
2021-07-23T10:32:01.7044765Z     Running setup.py install for watchdog: finished with status 'done'
2021-07-23T10:32:01.8400288Z WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
2021-07-23T10:32:01.8402064Z Successfully installed databind.core-1.0.1 databind.json-1.0.1 docspec-1.0.1 docspec-python-1.0.1 nr.collections-0.1.1 nr.fs-1.6.3 nr.metaclass-0.0.6 nr.optional-0.1.1 nr.parsing.date-1.0.2 nr.preconditions-0.0.4 nr.pylang.utils-0.1.3 nr.stream-0.1.2 nr.utils.re-0.3.1 pydoc-markdown-4.1.2 typing-extensions-3.10.0.0 watchdog-2.1.3
2021-07-23T10:32:01.9156560Z Generating SDK documentation
2021-07-23T10:32:02.3023228Z Traceback (most recent call last):
2021-07-23T10:32:02.3025300Z   File "/usr/bin/pydoc-markdown", line 8, in <module>
2021-07-23T10:32:02.3032091Z     sys.exit(cli())
2021-07-23T10:32:02.3032871Z   File "/usr/lib/python3.9/site-packages/click/core.py", line 829, in __call__
2021-07-23T10:32:02.3036039Z     return self.main(*args, **kwargs)
2021-07-23T10:32:02.3039328Z   File "/usr/lib/python3.9/site-packages/click/core.py", line 782, in main
2021-07-23T10:32:02.3049198Z     rv = self.invoke(ctx)
2021-07-23T10:32:02.3049973Z   File "/usr/lib/python3.9/site-packages/click/core.py", line 1066, in invoke
2021-07-23T10:32:02.3050469Z     return ctx.invoke(self.callback, **ctx.params)
2021-07-23T10:32:02.3051089Z   File "/usr/lib/python3.9/site-packages/click/core.py", line 610, in invoke
2021-07-23T10:32:02.3051717Z     return callback(*args, **kwargs)
2021-07-23T10:32:02.3052349Z   File "/usr/lib/python3.9/site-packages/pydoc_markdown/main.py", line 344, in cli
2021-07-23T10:32:02.3052744Z     session.render(pydocmd)
2021-07-23T10:32:02.3053357Z   File "/usr/lib/python3.9/site-packages/pydoc_markdown/main.py", line 139, in render
2021-07-23T10:32:02.3053768Z     config.render(modules)
2021-07-23T10:32:02.3054365Z   File "/usr/lib/python3.9/site-packages/pydoc_markdown/__init__.py", line 179, in render
2021-07-23T10:32:02.3054910Z     self.renderer.render(modules)
2021-07-23T10:32:02.3055599Z   File "/usr/lib/python3.9/site-packages/pydoc_markdown/contrib/renderers/markdown.py", line 385, in render
2021-07-23T10:32:02.3056054Z     self._resolver.update(modules)
2021-07-23T10:32:02.3056662Z AttributeError: 'MarkdownReferenceResolver' object has no attribute 'update'
NiklasRosenstein commented 3 years ago

Thanks for raising the issue @ReubenFrankel A line I accidentally left in there triggered this, should probably have a test case for it at some point 🙃 Anyway, this should be fixed in 4.1.3.