5.1.1.3.4. TextDocumentDiffModel

This module provides a document model for the Diff Viewer.

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 corresponding to the type of chunck. A text fragment is a piece of text and is decorated by a frame type and a token type used for the syntax highlighting. The frame type is used for replace chunck type to show the inner-line difference.

class CodeReview.Diff.TextDocumentDiffModel.TextBlockDiff(line_slice, frame_type=None, other_side=None)[source]

Bases: CodeReview.Diff.TextDocumentModel.TextBlock

This class implements a text block with a link to the other side.

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

Public Attributes:

other_side
alignment_padding()[source]
copy()[source]

Return a copy of the instance.

Link to the other side.

class CodeReview.Diff.TextDocumentDiffModel.TextDocumentDiffModelFactory[source]

Bases: object

_append_sub_chunk(sub_chunks, text_block1, text_block2)[source]

Append sub-chunks to the text blocks.

_complete_one_side(document, line_slice, document_model)[source]

Add to the document model an equal block.

Create the links between the two text blocks.

process(file_diff)[source]

Build two DiffViewer.TextDocumentModel instances from a class DiffViewer.RawTextDocumentDiff instance.

Return the 2-tuple mades of the document models.

CodeReview.Diff.TextDocumentDiffModel.highlight_document(document_model, highlighted_text)[source]

Merge a Diff document model and highlighted counter part.

Return a new document model.