Package epydoc :: Package docwriter :: Module html |
[hide private]
[frames] | no frames]

# Module html

source code

The HTML output generator for epydoc. The main interface provided by this module is the HTMLWriter class.

To Do: Add a cache to HTMLWriter.url()?

Classes | [hide private]
| HTMLWriter
| _HTMLDocstringLinker

Functions | [hide private]
compile_template(docstring, template_string, output_function=`'``out``'`, debug=True) Given a template string containing inline python source code, return a python function that will fill in the template, and output the result. | source code call graph
Call Graph
strip_indent(s) Given a multiline string `s`, find the minimum indentation for all non-blank lines, and return a new string formed by stripping that amount of indentation from all lines in `s`. | source code call graph
Call Graph

Function Details | [hide private]

### compile_template(docstring, template_string, output_function=`'``out``'`, debug=True) | source code call graph
Call Graph
Given a template string containing inline python source code, return a python function that will fill in the template, and output the result. The signature for this function is taken from the first line of `docstring`. Output is generated by making repeated calls to the output function with the given name (which is typically one of the function's parameters). The templating language used by this function passes through all text as-is, with three exceptions: If every line in the template string is indented by at least x spaces, then the first x spaces are stripped from each line. Any line that begins with '>>>' (with no indentation) should contain python code, and will be inserted as-is into the template-filling function. If the line begins a control block (such as 'if' or 'for'), then the control block will be closed by the first '>>>'-marked line whose indentation is less than or equal to the line's own indentation (including lines that only contain comments.) In any other line, any expression between two '$' signs will be evaluated and inserted into the line (using `str()` to convert the result to a string). Here is a simple example:
    >>> TEMPLATE = '''
    ... <book>
    ...   <title>$book.title$</title>
    ...   <pages>$book.count_pages()$</pages>
    ... >>> for chapter in book.chapters:
    ...     <chaptername>$chapter.name$</chaptername>
    ... >>> #endfor
    ... </book>
    >>> write_book = compile_template('write_book(out, book)', TEMPLATE)
Acknowledgements: The syntax used by `compile_template` is loosely based on Cheetah.