pydoc - generating HTML docs from string input

Laszlo Nagy gandalf at shopzeus.com
Wed Nov 7 16:47:12 EST 2007


gregpinero at gmail.com wrote:
> 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




More information about the Python-list mailing list