classification
Title: Make pydoc list submodules
Type: feature request Stage:
Components: Demos and Tools Versions: Python 2.6
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: georg.brandl Nosy List: georg.brandl, gustavo, pitrou (3)
Priority: normal Keywords patch

Created on 2007-12-31 23:52 by gustavo, last changed 2008-01-21 21:06 by georg.brandl.

Files
File name Uploaded Description Edit Remove
pydoc-submodules.diff gustavo, 2007-12-31 23:52
pydocsubmodules.patch pitrou, 2008-01-20 15:42
Messages (6)
msg59067 - (view) Author: Gustavo J. A. M. Carneiro (gustavo) Date: 2007-12-31 23:52
Often python extension modules define submodules like this:

static PyObject *
initfoo_xpto(void)
{
    PyObject *m;
    m = Py_InitModule3("foo.xpto", foo_xpto_functions, NULL);
    [...]
    return m;
}

PyMODINIT_FUNC
initfoo(void)
{
    PyObject *m;
    PyObject *submodule;
    m = Py_InitModule3("foo", foo_functions, NULL);
    [...]
    submodule = initfoo_xpto();
    Py_INCREF(submodule);
    PyModule_AddObject(m, "xpto", submodule);
}

Unfortunately pydoc does not list these submodules.  Attached patch
fixes it.
msg59399 - (view) Author: Georg Brandl (georg.brandl) Date: 2008-01-06 17:46
This patch duplicates entries for "package contents" and "submodules";
this is not good. (E.g. for help(email):

NAME
    email - A package for parsing, handling, and generating email messages.

FILE
    /home/gbr/devel/python/Lib/email/__init__.py

PACKAGE CONTENTS
    _parseaddr
    base64mime
    charset
    encoders
    errors
    feedparser
    generator
    header
    iterators
    message
    mime (package)
    parser
    quoprimime
    test (package)
    utils

SUBMODULES
    _parseaddr
    base64mime
    charset
    email
    encoders
    errors
    feedparser
    generator
    header
    iterators
    message
    mime
    parser
    quoprimime
    sys
    utils
)
msg61307 - (view) Author: Antoine Pitrou (pitrou) Date: 2008-01-20 15:42
This should be a better patch, although it only applies to the text
formatter of pydoc, not the HTML one (I'm too lazy for this :-)).
msg61408 - (view) Author: Georg Brandl (georg.brandl) Date: 2008-01-21 16:44
The patch only amends TextDoc -- what about HtmlDoc?
msg61446 - (view) Author: Antoine Pitrou (pitrou) Date: 2008-01-21 20:52
Actually, HtmlDoc already lists all module members in the inspected
module (regardless of whether they are modules imported from outside or
submodules defined inline). You can try it with the updated pydocfodder:

>>> import pydoc
>>> from test import pydocfodder
>>> pydoc.writedoc(pydocfodder)
wrote test.pydocfodder.html

... and check that test.pydocfodder.html contains a reference to
test.pydocfodder.submodule.
msg61449 - (view) Author: Georg Brandl (georg.brandl) Date: 2008-01-21 21:06
Well, I believe you. :)

Committed r60178.
History
Date User Action Args
2008-01-21 21:06:03georg.brandlsetstatus: open -> closed
resolution: accepted
messages: + msg61449
2008-01-21 20:52:54pitrousetmessages: + msg61446
2008-01-21 16:44:38georg.brandlsetmessages: + msg61408
2008-01-20 15:42:22pitrousetfiles: + pydocsubmodules.patch
nosy: + pitrou
messages: + msg61307
2008-01-06 17:46:32georg.brandlsetmessages: + msg59399
2008-01-01 14:46:53christian.heimessetpriority: normal
assignee: georg.brandl
keywords: + patch
nosy: + georg.brandl
2007-12-31 23:52:12gustavocreate