TOC

Formatting of Table of Contents for documents

class disseminate.tags.toc.Toc(name, content, attributes, context)

Bases: disseminate.tags.tag.Tag

Table of contents and listings.

contentsstr

The contents are the label types to list. The following entries are supported:

  • document: list the document labels

  • heading : list heading labels

  • figure : list figure labels

  • table : list table labels

Additionally, the following modifiers have special meaning: - all : list labels from all documents - current : list labels from the current document (default)

  • expandedpertains to ‘all document’ and ‘all headings’.

    Show all label references for all documents.

  • abbreviatedpertains to ‘all document’ and ‘all headings’.

    show all label references for the current document and the top level heading for other documents.

  • collapsedpertains to ‘all document’ and ‘all headings’.

    show only the documents without headings. (default)

get_labels()

Get the labels, ordering function and labeling type.

Returns
labelsList[label_manager.types.Label]

The labels referenced by this TOC.

html_fmt(content=None, attributes=None, cache=None, format_func='html_fmt', method='html', level=1, **kwargs)

Convert the tag to an html string or html element.

Parameters
contentOptional[Union[str, List[Union[str, list, Tag]]]

Specify an alternative content from the tag’s content. It can either be a string, a tag or a list of strings, tags and lists.

attributesOptional[Union[str, Attributes]]

Specify an alternative attributes dict from the tag’s attributes. It can either be a string or an attributes dict.

format_funcOptional[str]

The format function to use with by formatted_content when formatting sub-tags.

methodOptional[str]

The rendering method for the string. ex: ‘html’ or ‘xml’

levelOptional[int]

The level of the tag.

Returns
htmlstr or html element

A string in HTML format or an HTML element (lxml.builder.E).

property reference_tags

This tag’s TocRef tag items.

tex_fmt(content=None, attributes=None, mathmode=False, level=1, **kwargs)

Format the tag in LaTeX format.

Parameters
contentOptional[Union[str, List[Union[str, list, Tag]]]

Specify an alternative content from the tag’s content. It can either be a string, a tag or a list of strings, tags and lists.

attributesOptional[Union[str, Attributes]]

Specify an alternative attributes dict from the tag’s attributes. It can either be a string or an attributes dict.

mathmodeOptional[bool]

If True, the tag will be rendered in math mode. Otherwise (default) latex text mode is assumed.

levelOptional[int]

The level of the tag.

Returns
tex_stringstr

The formatted tex string.

exception disseminate.tags.toc.TocError

Bases: Exception

An error was encountered while processing a table of contents tag.

class disseminate.tags.toc.TocRef(name, content, *args, **kwargs)

Bases: disseminate.tags.ref.Ref

A Ref tag for the TOC.

This is a separate class so that the label_fmt may be different for TOC entries.

html_fmt(content=None, attributes=None, cache=None, format_func='html_fmt', method='html', level=1, **kwargs)

Convert the tag to an (x)html string or (x)html element.

Parameters
contentOptional[Union[str, List[Union[str, list, Tag]]]

Specify an alternative content from the tag’s content. It can either be a string, a tag or a list of strings, tags and lists.

attributesOptional[Union[str, Attributes]]

Specify an alternative attributes dict from the tag’s attributes. It can either be a string or an attributes dict.

cacheOptional[dict]

If specified, the cache values will be used instead of being evaluated. Possibilities: - ‘label’: types.Label - ‘documents_by_id’: Dict[str, document.Document] - ‘format_str’: str

format_funcOptional[str]

The tag format function to use in rendering the reference tag. (ex: ‘html_fmt’ or ‘xhtml_fmt’)

methodOptional[str]

The rendering method for the string. ex: ‘html’ or ‘xml’

levelOptional[int]

The level of the tag.

Returns
htmlstr or html element

A string in HTML format or an HTML element (lxml.builder.E).

tex_fmt(content=None, attributes=None, mathmode=False, cache=None, level=1, **kwargs)

Format the tag in LaTeX format.

Note

This function renders tex links to compiled pdf documents

Parameters
contentOptional[Union[str, List[Union[str, list, Tag]]]

Specify an alternative content from the tag’s content. It can either be a string, a tag or a list of strings, tags and lists.

attributesOptional[Union[str, Attributes]]

Specify an alternative attributes dict from the tag’s attributes. It can either be a string or an attributes dict.

mathmodeOptional[bool]

If True, the tag will be rendered in math mode. Otherwise (default) latex text mode is assumed.

cacheOptional[dict]

If specified, the cache values will be used instead of being evaluated. Possibilities: - ‘label’: types.Label - ‘documents_by_id’: Dict[str, document.Document]

levelOptional[int]

The level of the tag.

Returns
tex_stringstr

The formatted tex string.