Tu2Html

Converts an initial translation unit to HTML.

TODO: For making anchors in the TU HTML that the conditional include graph can link to. If we put an <a name=”...” on every line most browsers can not handle that many. What we could do here is to keep a copy of the conditional include stack and for each token see if it has changed (like the file stack). If so that write a marker that the conditional graph can later link to.

cpip.Tu2Html.FILE_SHIFT_ACTIONS = ('Starting', 'Holding', 'Back in', 'Ending')

State changes

cpip.Tu2Html._adjustFileStack(theS, lexStack, theFileStack, theIntId)

Adjust the file stacks and write to the stream.

<insert documentation for function>

Parameters:
  • theS (cpip.util.XmlWrite.XhtmlStream) – HTML stream.
  • lexStack (list([str])) –

    ???

  • theFileStack (list([]), list([str])) –

    ???

  • theIntId (int) –

    ???

Returns:

inttheIntId

cpip.Tu2Html._writeFileName(theS, lenIndent, theFileStack, theAction, theFile, theIntId)
Parameters:
  • theS (cpip.util.XmlWrite.XhtmlStream) – HTML stream.
  • lenIndent (int) – Size of indent.
  • theFileStack (list([str])) – File stack.
  • theAction (str) – One of ('Starting', 'Holding', 'Back in', 'Ending')
  • theFile (str) – File ID such as a path.
  • theIntId (int) –

    ???

Returns:

inttheIntId

cpip.Tu2Html.linkToIndex(theS, theIdxPath)

Write a link to the index.

Parameters:
Returns:

NoneType

cpip.Tu2Html.processTuToHtml(theLex, theHtmlPath, theTitle, theCondLevel, theIdxPath, incItuAnchors=True)

Processes the PpLexer and writes the tokens to the HTML file.

Parameters:
  • theLex (cpip.core.PpLexer.PpLexer) – The lexer.
  • theHtmlPath (str) – The path to the HTML file to write.
  • theTitle (str) – A string to go into the <title> element.
  • theCondLevel (int) – The Conditional level to pass to theLex.ppTokens()
  • theIdxPath (str) – Path to link back to the index page.
  • incItuAnchors (bool) – If True will write anchors for lines in the ITU that are in this TU. If True then setItuLineNumbers returned is likely to be non-empty.
Returns:

tuple([cpip.core.PpTokenCount.PpTokenCount, set([int])]) – Returns a pair of (PpTokenCount.PpTokenCount(), set(int)) The latter is a set of integer line numbers in the ITU that are in the TU, these line numbers with have anchors in this HTML file of the form: <a name="%d" />.

Raises:

StopIteration