[Zope3-dev] ReST

Phil Ruggera pruggera at san.rr.com
Sun Jul 11 17:18:56 EDT 2004


I did not find a tool in Zope3 to process the docstrings of a module so I
threw one together:

"""Get the ReStructured Text from the doc strings of a module and render it
into HTML"""
from zope.app.renderer.rest import ReStructuredTextToHTMLRenderer
from zope.publisher.browser import TestRequest
import symtable
from pydoc import importfile

path = 'g:\\Python\\Dev\\zope\\src\\zope\\app\\adapter\\adapter.py'

print path
syms = symtable.symtable(file(path).read(), path, "exec")

outFile = file('g:\\My Documents\\ReST doc check.html','w')
object = importfile(path)
for sym in syms.get_symbols():
    if sym.is_namespace() and getattr(object,sym.get_name()).__doc__ !=
None:
        renderer =
ReStructuredTextToHTMLRenderer(getattr(object,sym.get_name()).__doc__,
TestRequest())
        outFile.write(renderer.render())

outFile.close()

I will be using this to verify the correctness of the ReST docstrings.

Phil



More information about the Zope3-dev mailing list