Python Forum
how to suppress not to display the package contents from pydoc! - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: how to suppress not to display the package contents from pydoc! (/thread-32943.html)



how to suppress not to display the package contents from pydoc! - maiya - Mar-18-2021

Hi All,

Below is my sample code, where I do not want to display the PACKAGE CONTENTS section (means I wanted to suppress this, as not to display it) while issuing the command as pydoc3 -w mymodule

NAME
    whatever - This is whatever help info.

FILE
    /home/el/whatever/__init__.py

DESCRIPTION
    This is whatever description

    EXAMPLES:
        ...

PACKAGE CONTENTS
    nothing (package)
    something

DATA
    __version__ = '1.0'
    variable = 'variable'

VERSION
    1.0
any suggestion on this? thanks a lot.
Regards,
maiya


RE: how to suppress not to display the package contents from pydoc! - Larz60+ - Mar-18-2021

what you are showing is not sample code.
It looks more like a document header.
Please post your code.


RE: how to suppress not to display the package contents from pydoc! - maiya - Mar-19-2021

(Mar-18-2021, 10:19 AM)Larz60+ Wrote: what you are showing is not sample code.
It looks more like a document header.
Please post your code.

Quote:No Sir, actually when I issue pydoc3 -w mymodule
where in the document PACKAGE CONTENTS section also display, but I do not want pydoc3 to display the PACKAGE CONTENTS section. So suppress this section.
Is there any command to do so? or in my code possible to do so? or in pydoc code is possible to do so? or it is pydoc feature and we cannot do anything with this pydoc feature.?



RE: how to suppress not to display the package contents from pydoc! - bowlofred - Mar-19-2021

Looks like pydoc simply sees if the module has a __path__ attribute. If it does, it creates the section and adds all the objects inside to the section. So I assume you have a multi-file module? Are you using a __init__.py file?

Maybe if you had one you could try deleting the path variable if it thought that pydoc was being run. That doesn't seem very safe, but it might work. Something like:

import sys
if "pydoc" in sys.argv[0]:
    del __path__