formatCode: Format R code for displaying in a document

formatCodeR Documentation

Format R code for displaying in a document

Description

This function is used to take code as text and format it for display in with the appropriate width - number of characters - etc. It is exported so that it can be called from XSL code that performs the formatting.

Usage

formatCode(node, defaultWidth = options()$width, ...)

Arguments

node

the XML node that contains the R code to be parsed and formatted. The node can have attributes that control the formatting, e.g. width which is passed to deparse.

defaultWidth

the width to use in the call to deparse if the node does not have an explicit r:width attribute.

...

additional parameters that are currently ignored. Intended for methods.

Value

A character string.

Note

We may enhance this to format the results in HTML or FO or LaTeX. In fact there is a collection of methods in highlight.R that are overridden but are much more general.

Author(s)

Duncan Temple Lang

See Also

dynDoc


duncantl/XDynDocs documentation built on Jan. 4, 2024, 5:20 p.m.