Skip to content

Commit 3c52ae9

Browse files
committed
Update documentation
1 parent 78c98fa commit 3c52ae9

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

Doc/library/difflib.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,22 @@ Diff generation
338338
+ tree
339339
+ emu
340340

341+
.. function:: mdiff(fromlines, tolines, context=None, linejunk=None, charjunk=IS_CHARACTER_JUNK)
342+
343+
Return a generator yielding marked up *fromlines* and *tolines* side by side differences.
344+
345+
Optional keyword parameters *context* is number of lines to display on each side the difference, if ``None``, all from/to text lines will be generated; *linejunk* and *charjunk* are filtering functions.
346+
347+
from/to line tuple -- (line num, line text)
348+
line num -- integer or None (to indicate a context separation)
349+
line text -- original line text with following markers inserted:
350+
'\0+' -- marks start of added text
351+
'\0-' -- marks start of deleted text
352+
'\0^' -- marks start of changed text
353+
'\1' -- marks end of added/deleted/changed text
354+
355+
boolean flag -- None indicates context separation, True indicates
356+
either "from" or "to" line contains a change, otherwise False.
341357

342358
.. function:: restore(sequence, which)
343359

Lib/difflib.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
Function ndiff(a, b):
1111
Return a delta: the difference between `a` and `b` (lists of strings).
1212
13+
Function mdiff(fromlines, tolines):
14+
Return a generator yielding marked up from/to side by side differences.
15+
1316
Function restore(delta, which):
1417
Return one of the two sequences that generated an ndiff delta.
1518
@@ -26,7 +29,7 @@
2629
For producing HTML side by side comparison with change highlights.
2730
"""
2831

29-
__all__ = ['get_close_matches', 'ndiff', 'restore', 'SequenceMatcher',
32+
__all__ = ['get_close_matches', 'ndiff', 'mdiff', 'restore', 'SequenceMatcher',
3033
'Differ','IS_CHARACTER_JUNK', 'IS_LINE_JUNK', 'context_diff',
3134
'unified_diff', 'diff_bytes', 'HtmlDiff', 'Match']
3235

0 commit comments

Comments
 (0)