NiklasRosenstein / pydoc-markdown

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

Bug: can't use filter.expression. "NameError: name '_check' is not defined" #161

Closed thomasnal closed 4 years ago

thomasnal commented 4 years ago
$ pydoc-markdown --package myprj pydoc-markdown.yml
Traceback (most recent call last):
  File ".../bin/pydoc-markdown", line 8, in <module>
    sys.exit(cli())
  File ".../lib/python3.8/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File ".../lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File ".../lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File ".../lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File ".../lib/python3.8/site-packages/pydoc_markdown/main.py", line 337, in cli
    session.render(pydocmd)
  File ".../lib/python3.8/site-packages/pydoc_markdown/main.py", line 135, in render
    config.process(modules)
  File ".../lib/python3.8/site-packages/pydoc_markdown/__init__.py", line 147, in process
    processor.process(modules, self.resolver)
  File ".../lib/python3.8/site-packages/pydoc_markdown/contrib/processors/filter.py", line 72, in process
    docspec.filter_visit(modules, m, order='post')
  File ".../lib/python3.8/site-packages/docspec/__init__.py", line 223, in filter_visit
    filter_visit(getattr(objects[index - offset], 'members', []), predicate, order)
  File ".../lib/python3.8/site-packages/docspec/__init__.py", line 223, in filter_visit
    filter_visit(getattr(objects[index - offset], 'members', []), predicate, order)
  File ".../lib/python3.8/site-packages/docspec/__init__.py", line 225, in filter_visit
    if not predicate(objects[index - offset]):
  File ".../lib/python3.8/site-packages/pydoc_markdown/contrib/processors/filter.py", line 71, in m
    return self._match(obj)
  File ".../lib/python3.8/site-packages/pydoc_markdown/contrib/processors/filter.py", line 90, in _match
    scope = {'name': obj.name, 'obj': obj, 'default': _check}
NameError: name '_check' is not defined
# pydoc-markdown.yml:
loaders:
  - type: python
processors:
  - type: filter
    expression: not name.contains("Test")
    skip_empty_modules: true
  - type: smart
  - type: crossref
NiklasRosenstein commented 4 years ago

Thanks for reporting @thomasnal, fixed in 3.7.0

Note that the behaviour of FilterProcessor.expression is slightly changed, if you want to apply the default logic additionally to your own you need to call default() as well.