8000 Unable to configure pdoc3 to ignore tests directory · Issue #368 · pdoc3/pdoc · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Unable to configure pdoc3 to ignore tests directory #368

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

Closed
gvwilson opened this issue Nov 14, 2021 · 1 comment
Closed

Unable to configure pdoc3 to ignore tests directory #368

gvwilson opened this issue Nov 14, 2021 · 1 comment

Comments

@gvwilson
Copy link

I want pdoc3 to skip everything in my project's the tests directory, but even after reading #99 I am unable to get it to do so. Steps taken:

  • Create new directory mwe and cd into it.

  • Create ./main.py with:

"""Main program."""

def main(): pass
  • Create ./tests directory.

  • Create ./tests/test.py with:

"""Test code."""

def test(): pass
  • Run pdoc --force --html . to generate docs:
$ tree --charset unicode html
html
`-- mwe
    |-- index.html
    |-- main.html
    `-- tests
        |-- index.html
        `-- test.html
  • Add an file ./tests/__init__.py, re-run pdoc --force --html ., get error message:
/Users/gvwilson/miniforge3/lib/python3.9/site-packages/pdoc/__init__.py:239: UserWarning: Couldn't read PEP-224 variable docstrings from <Module 'mwe.tests'>: could not get source code
  warn("Couldn't read PEP-224 variable docstrings from {!r}: {}".format(doc_obj, exc))
  • Add this to ./tests/__init__.py
__pdoc__ = {
    'tests': False
}

produces a different error message:

/Users/gvwilson/miniforge3/lib/python3.9/site-packages/pdoc/__init__.py:706: UserWarning: __pdoc__-overriden key 'tests' does not exist in module 'mwe.tests'
  warn('__pdoc__-overriden key {!r} does not exist '
  • Creating an __init__.py file in the project's root directory with this content produces the same error message:
__pdoc__ = {
    'tests': False
}
  • Modify ./__init__.py to contain mwe.tests as shown below also produces this error message:
__pdoc__ = {
    'mwe.tests': False
}

I'd be grateful for the correct incantation (or if one doesn't exist, I'd be happy to PR a --ignore dir [dir] option).

@kernc
Copy link
Member
kernc commented Nov 14, 2021

The first "error message" is just a warning; CPython issue bpo27578, PR python/cpython#20809 (please upvote).

__pdoc__ = {'tests': False} inside mwe.tests is obviously wrong (results in the path mwe.tests.tests). But __pdoc__ = {'tests': False} in the main mwe/__init__.py absoltely should work. If it doesn't, it might be a bug related to #306 or some other issue. 😬 If you would take the time to investigate it, that would certainly be appreciated! 😅

Another workaround that might work is to prefix tests dir with an underscore (i.e. _tests).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants
0