pdoc icon indicating copy to clipboard operation
pdoc copied to clipboard

No way to globally include private identifiers

Open jkugler opened this issue 5 years ago • 6 comments

PyDoc is wonderful! I had it up and running in minutes, and it produced beautiful docs.

But I hit an issue. We would like to use this both for docs for our developer team, as well as producing external-facing documentation. If we want to include private identifiers in our docs, we have to update add a __pdoc__ to every file. But...if we want to produce user-facing docs, we would have to remove that.

It would be really nice if there was a command-line flag to say "include all private identifiers."

Since pdoc3 is so procedural (and not class/hierarchy based) it appears this would require quite the re-architecting of the project.

jkugler avatar Aug 06 '20 22:08 jkugler

Listing absolute refnames only in the top-level module should work. This maybe alleviates part of your issue?

# project/__init__.py:
try:
    from _private_build import __pdoc__
except ImportError:
    pass  # Public build
...
# _private_build.py:
__pdoc__ = {} 
__pdoc__['project._private_module'] = True
__pdoc__['project._private_module2'] = True
__pdoc__['project._private_module2._something'] = True

kernc avatar Aug 06 '20 22:08 kernc

Ah, I see what is done there. Yeah, that might work. That does, however, require the developers to basically keep a catalog of all the private methods, which could get onerous in a hurry.

Thanks for the tip!

I'm reading over the Sphinx docs https://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html#skipping-members

(yes, I know, huge project, much more complex), but it allows you to catch an event of autodoc-skip-member(app, what, name, obj, skip, options) which you then can use to decide, at run time, whether to include or not. Something like that in pdoc3 would be neat, but I understand it would still take quite the restructuring to make happen.

jkugler avatar Aug 06 '20 22:08 jkugler

Yeah, I guess the exceptions are explicit. __pdoc__ can be constructed in Python code, though. Something like this should work:

# _private_build.py
...
import _private_module
_private_module.__pdoc__ = {refname: True
                            for refname in something
                            if condition} 

kernc avatar Aug 06 '20 23:08 kernc

I'll have to keep that in mind.

jkugler avatar Aug 07 '20 00:08 jkugler

Any updates here?

Same issue occurs.

DjangoPeng avatar Apr 23 '21 04:04 DjangoPeng

Bump attention to this

daniele-niero avatar Oct 26 '22 12:10 daniele-niero