5.1.1.3.5. TextDocumentModel

This module implements a basic document model.

A document is made of text blocks that are themselves made of text fragments. A text block corresponds to a chunck of lines and is decorated by a frame type. A text fragment is a piece of text and is decorated by a frame type and a token type used for syntax highlighting.

class CodeReview.Diff.TextDocumentModel.TextBlock(line_slice, frame_type=None)[source]

Bases: list

This class implements a text block.

The parameter line_slice specifies the line slice corresponding to the text block and the parameter frame_type the type of frame.

class CodeReview.Diff.TextDocumentModel.TextDocumentModel(metadata=None)[source]

Bases: list

This class implements an ordered list of text blocks.

class CodeReview.Diff.TextDocumentModel.TextFragment(text, frame_type=None, token_type=None)[source]

Bases: object

This class implements a text fragment.

The parameter text specifies the content, it must implement the Boolean evaluation and the string conversion.

The parameter frame_type specifies the type of frame and the parameter token_type the type of token for the syntax highlighting.

To test if an instance represents an non-empty string use a Boolean evaluation:

bool(instance)

To get the content string use:

str(instance)