[Tutor] Making pretty web pages from python code examples?
Martin A. Brown
martin at linux-ip.net
Tue Apr 13 17:08:09 CEST 2010
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hello,
: Is there an easy way to get a docstring from a python file,
: without first importing it?
:
: Basically, I'm trying to read python code examples from files on
: disk and generate pretty little web pages from them. I invision
: the docstring appearing as the main text on the page, with the
: rest of the code in HTML code or pre tags. That way I could just
: write up a bunch of python samples, without having to do anything
: more but upload them. Maybe something like this exists already? I
: don't know. I just figured it would be pretty easy to write, but
: getting the docstrings without trying to parse the files was a
: rut.
I think you may want sphinx [0] which is available in PyPI [1].
It understands reStrucTured text and adds a few Sphinx-specific
directives/features for pulling the docstrings from your python
modules. Much easier than building your own.
Good luck,
- -Martin
[0] http://sphinx.pocoo.org/
http://sphinx.pocoo.org/contents.html
http://pypi.python.org/pypi/Sphinx
- --
Martin A. Brown
http://linux-ip.net/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
Comment: pgf-0.72 (http://linux-ip.net/sw/pine-gpg-filter/)
iD8DBQFLxIjeHEoZD1iZ+YcRAmNbAJ4kteAHzm6b7sSkLFn1w4Tbk5z3YQCgqtnE
1BsohLC9e8FIL/hpwvnKBWs=
=wKJ5
-----END PGP SIGNATURE-----
More information about the Tutor
mailing list