Home | Trees | Index | Help |
|
---|
|
A class that renders a python module's source code into HTML pages. These HTML pages are intended to be provided along with the API documentation for a module, in case a user wants to learn more about a particular object by examining its source code. Links are therefore generated from the API documentation to the source code pages, and from the source code pages back into the API documentation.
The HTML generated byPythonSourceColorizer
has several
notable features:
'#<name>'
), then that class or function
will automatically be highlighted; and all other classes and function
definition blocks will be 'collapsed'. These collapsed blocks can be
expanded by clicking on them.
'coding:'
declarations).
|
|||
__init__(self,
module_filename,
module_name,
docindex=None,
api_docs=None,
url_func=None)
Create a new HTML colorizer for the specified module. |
|||
find_line_offsets(self)
Construct the line_offsets table from self.text .
|
|||
lineno_to_html(self) | |||
colorize(self)
Return an HTML string that renders the source code for the module that was specified in the constructor. |
|||
tokeneater(self,
toktype,
toktext,
(srow, scol),
(erow, ecol),
line)
A callback function used by tokenize.tokenize to
handle each token in the module.
|
|||
handle_line(self,
line)
Render a single logical line from the module, and write the generated HTML to self.out .
|
|||
doclink(self, name, docs) | |||
doc_descr(self, doc, context) | |||
doc_kind(self, doc) | |||
mark_def(self, s, name) | |||
is_docstring(self, line, i) | |||
add_line_numbers(self, s, css_class) | |||
name2url(self, class_name, func_name=None) |
|
|||
CSS_CLASSES | A look-up table that is used to determine which CSS class should be used to colorize a given token. | ||
START_DEF_BLOCK | HTML code for the beginning of a collapsable function or class definition block. | ||
END_DEF_BLOCK | HTML code for the end of a collapsable function or class definition block. | ||
UNICODE_CODING_RE | A regular expression used to pick out the unicode encoding for the source file. | ||
ADD_DEF_BLOCKS | A configuration constant, used to determine whether or not to add collapsable <div> elements for definition blocks. | ||
ADD_LINE_NUMBERS | A configuration constant, used to determine whether or not to add line numbers. | ||
ADD_TOOLTIPS | A configuration constant, used to determine whether or not to add tooltips for linked names. | ||
GUESS_LINK_TARGETS | If true, then try to guess which target is appropriate for linked names; if false, then always open a div asking the user which one they want. | ||
_next_uid |
|
|||
module_filename | The filename of the module we're colorizing. | ||
module_name | The dotted name of the module we're colorizing. | ||
name_to_docs | A mapping from short names to lists of ValueDoc. | ||
url_func | A function that maps APIDoc -> URL | ||
pos | The index in text of the last character of the last
token we've processed. |
||
line_offsets | A list that maps line numbers to character offsets in
text . |
||
cur_line | A list of (toktype, toktext) for all tokens on the
logical line that we are currently processing. |
||
context | A list of the names of the class or functions that include the current block. | ||
indents | A list of indentation strings for each of the current block's indents. | ||
lineno | The line number of the line we're currently processing. | ||
def_name | The name of the class or function whose definition started on the
previous logical line, or None if the previous logical
line was not a class or function definition. |
|
|
self.text .
|
|
|
tokenize.tokenize to handle
each token in the module. tokeneater collects tokens into
the self.cur_line list until a complete logical line has
been formed; and then calls handle_line to process that line.
|
self.out .
|
|
|
|
|
|
|
|
|
CSS_CLASSESA look-up table that is used to determine which CSS class should be used to colorize a given token. The following keys may be used:
|
START_DEF_BLOCKHTML code for the beginning of a collapsable function or class definition block. The block contains two <div>...</div> elements -- a collapsed version and an expanded version -- and only one of these elements is visible at any given time. By default, all definition blocks are expanded. This string should be interpolated with the following values:(name, indentation, name)Where name is the anchor name for the function or class;
and indentation is a string of whitespace used to indent the ellipsis
marker in the collapsed version.
|
END_DEF_BLOCKHTML code for the end of a collapsable function or class definition block.
|
UNICODE_CODING_REA regular expression used to pick out the unicode encoding for the source file.
|
ADD_DEF_BLOCKSA configuration constant, used to determine whether or not to add collapsable <div> elements for definition blocks.
|
ADD_LINE_NUMBERSA configuration constant, used to determine whether or not to add line numbers.
|
ADD_TOOLTIPSA configuration constant, used to determine whether or not to add tooltips for linked names.
|
GUESS_LINK_TARGETSIf true, then try to guess which target is appropriate for linked names; if false, then always open a div asking the user which one they want.
|
_next_uid
|
|
module_filenameThe filename of the module we're colorizing. |
module_nameThe dotted name of the module we're colorizing. |
name_to_docsA mapping from short names to lists of ValueDoc. |
url_funcA function that maps APIDoc -> URL |
posThe index intext of the last character of the last token
we've processed.
|
line_offsetsA list that maps line numbers to character offsets intext . In particular, line i begins at character line_offset[i]
in text . Since line numbers begin at 1, the first element
of line_offsets is None .
|
cur_lineA list of(toktype, toktext) for all tokens on the
logical line that we are currently processing. Once a complete line of
tokens has been collected in cur_line , it is sent to handle_line for processing.
|
contextA list of the names of the class or functions that include the current block.context has one element for each level of
indentation; context[i] is the name of the class or function
defined by the i th level of indentation, or
None if that level of indentation doesn't correspond to a
class or function definition.
|
indentsA list of indentation strings for each of the current block's indents. I.e., the current total indentation can be found by taking''.join(self.indents) .
|
linenoThe line number of the line we're currently processing. |
def_nameThe name of the class or function whose definition started on the previous logical line, orNone if the previous logical line
was not a class or function definition.
|
Home | Trees | Index | Help |
|
---|
Generated by Epydoc 3.0alpha2 on Tue Apr 11 17:35:12 2006 | http://epydoc.sf.net |