TotalDepth.util.HtmlUtils (HTML Utilities)

HTML utility functions.

TotalDepth.util.HtmlUtils.retHtmlFileName(thePath)

Creates a unique, short, human readable file name base on the input file path.

Returns a link to a file/line.

Writes a link to another HTML file that represents source code. theS is an XHTML stream. theSrcPath is the path of the original source, which will be encoded with retHtmlFileName(). theLineNum is an integer line number in the target. theText is optional navigation text. theClass is optional CSS class for the navigation text.

TotalDepth.util.HtmlUtils.writeHtmlFileAnchor(theS, theLineNum, theText='', theClass=None)

Write an anchor to the stream.

TotalDepth.util.HtmlUtils.pathSplit(p)

Split a path into its components.

TotalDepth.util.HtmlUtils.writeFileListAsTable(theS, theFileLinkS, tableAttrs, includeKeyTail)

Writes a list of file names as an HTML table looking like a directory structure. theFileLinkS is a list of pairs (file_path, href). The navigation text in the cell will be the basename of the file_path.

TotalDepth.util.HtmlUtils.writeFileListTrippleAsTable(theS, theFileLinkS, tableAttrs, includeKeyTail)

Writes a list of file names as an HTML table looking like a directory structure. theFileLinkS is a list of triples (file_name, href, nav_text).

TotalDepth.util.HtmlUtils.writeDictTreeAsTable(theS, theDt, tableAttrs, includeKeyTail)

Writes a DictTreeHtmlTable object as a table, for example as a directory structure.

The key list in the DictTreeHtmlTable object is the path to the file i.e. os.path.abspath(p).split(os.sep) and the value is expected to be a pair of (link, nav_text) or None.

TotalDepth.util.HtmlUtils.writeFilePathsAsTable(valueType, theS, theKvS, tableStyle, fnTd)

Writes file paths as a table, for example as a directory structure.

valueType - The type of the value: None | ‘list’ | ‘set’

theKvS - A list of pairs (file_path, value).

tableStyle - The style used for the table.

fnTd - A callback function that is executed for a <td> element when there is a non-None value. This is called with the following arguments:

  • theS - The HTML stream.
  • attrs - A map of attrs that include the rowspan/colspan for the <td>
  • k - The key as a list of path components.
  • v - The value given by the caller.