pdoc icon indicating copy to clipboard operation
pdoc copied to clipboard

Warning generated for `__pdoc__[submodule] = False`, but behaviour correct

Open MPvHarmelen opened this issue 5 years ago • 4 comments

Expected Behavior

I expect no warnings.

Actual Behavior

<some path>/python3.8/site-packages/pdoc/__init__.py:706: UserWarning: __pdoc__-overriden key 'module' does not exist in module 'mwe'
  warn('__pdoc__-overriden key {!r} does not exist '

Steps to Reproduce

mkdir mwe
mkvirtualenv mwe
pip install pdoc3
echo "__pdoc__ = {
    'module': False
}
" > mwe/__init__.py
echo '"""Some documentation"""
' > mwe/module.py
pdoc3 --html mwe

Additional info

  • MarkupSafe-1.1.1
  • mako-1.1.3
  • markdown-3.2.2
  • pdoc3-0.8.1

MPvHarmelen avatar Jun 03 '20 15:06 MPvHarmelen

The issue is we already skip mwe.module when iterating over submodules: https://github.com/pdoc3/pdoc/blob/1de51a9d7c2f80412d877066f62c57d4100226c7/pdoc/init.py#L655-L656 I guess the warning might try to account for that ...

kernc avatar Jun 26 '20 13:06 kernc

Hi!

Many thanks for this great tool!

The fix to this issue does not seem to work (i.e. a warning is generated) when the module is a sub-sub-module.

A related question: would it be possible to support the feature where objects/modules can simply set __pdoc__ = False and then they themselves (as well as their members) don't get documented ?

patnr avatar Dec 21 '20 15:12 patnr

(i.e. a warning is generated) when the module is a sub-sub-module.

Can you show a mwe?

where objects/modules can simply set __pdoc__ = False

Simply setting:

__pdoc__ = {__name__: False}

# or

class C:
    __pdoc__ = {__qualname__: False}

does not work?

kernc avatar Dec 21 '20 17:12 kernc

Yes, here it is:

"""Contents of package/__init__.py"""

# Two ways to exclude subpack1.
# The 2nd version produces the warning.
# __pdoc__ = {"subpack1": False}
# __pdoc__ = {"package.subpack1": False}

# For subpack2, there is only this way (AFAICT).
# And it produces the warning.
__pdoc__ = {"package.subpack1.subpack2": False}
"""Contents of package.subpack1/__init__.py"""
...
"""Contents of package.subpack1.subpack2/__init__.py"""

# This does not seem to work at all?
__pdoc__ = {__name__: False}

patnr avatar Dec 22 '20 13:12 patnr