Re: [Epydoc-devel] Documentation not associated with a particular module, function, class, or metho
Brought to you by:
edloper
|
From: Edward L. <ed...@se...> - 2008-02-27 01:01:41
|
If you just want to convert stand-alone epytext to html, it's not too
hard. But if you want it to include links into the documentation
generated by epydoc, then things get a bit trickier.
The code following this email should do basically what you want -- it
runs the epydoc command line interface (with options taken from
sys.argv), and then has some code at the end to parse a text file
containing epytext material (linking it to the docs), and write it as
html to the output directory. It's a bit hackish, though, I'm afraid.
A better solution would probably be to add the ability for epydoc to
read files containing epytext (or rst) and convert them natively..
something like:
% epydoc my_package/ --rst-file my_docfile.rst --epytext-file
my_other_docfile.txt
Some issues might have to be worked out though, such as what files
they would be written to in the output, whether they could get
referenced by docstrings in python code, etc.
-Edward
========================================================
import epydoc.cli, os.path
from epydoc.markup.epytext import ParsedEpytextDocstring, pparse
from epydoc.docwriter.html import HTMLWriter
# Run epydoc.
options = epydoc.cli.parse_arguments()
docindex = epydoc.cli.main(options)
html_writer = HTMLWriter(docindex, **options.__dict__)
html_writer._directory = options.target['html']
TEMPLATE = "<html><head>Hello</head><body>%s</body></html>"
# Convert my own file.
doc = ParsedEpytextDocstring(pparse(open('foo.txt').read()))
out = open(os.path.join(options.target['html'], 'foo.html'), 'w')
out.write(TEMPLATE % html_writer.docstring_to_html(doc))
out.close()
|