pydoc - generating HTML docs from string input

G

gregpinero

Has anyone ever tried mucking with pydoc to the point where you can
get it to give you output from a string input? For example I'd like
to give it a whole module to generate documentation for but all within
a string:

#little sample

module_code='''
"""Module docstring"""

def func1():
""" some docstring"""
pass

....

'''

pydoc.html(module_code) -> HTML output as a string

Any ideas?

-Greg
 
L

Laszlo Nagy

Has anyone ever tried mucking with pydoc to the point where you can
get it to give you output from a string input? For example I'd like
to give it a whole module to generate documentation for but all within
a string:

#little sample

module_code='''
"""Module docstring"""

def func1():
""" some docstring"""
pass

...

'''

pydoc.html(module_code) -> HTML output as a string

Any ideas?
The problem with this is that your module can do relative imports, and
it DOES matter where your module is located in the filesystem.

In the very unlikely case when you store your modules in an external
system (e.g in a database), and you use __import__ hacks to run your
code, I would recommend to write a program that exports your stored
modules into a real filesystem and run pydoc there.

Regards,

Laszlo
 
G

gregpinero

The problem with this is that your module can do relative imports, and
it DOES matter where your module is located in the filesystem.

In the very unlikely case when you store your modules in an external
system (e.g in a database), and you use __import__ hacks to run your
code, I would recommend to write a program that exports your stored
modules into a real filesystem and run pydoc there.

Regards,

Laszlo


That's a good point. I was mainly thinking about the case of simple
modules with no other imports. But looking at pydoc's code, it looks
like it would be quite a bit of work to make it work at all.

-Greg
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,271
Latest member
BuyAtenaLabsCBD

Latest Threads

Top