Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e07b835

Browse files
committed
Document context_diff() and unified_diff()
1 parent 4e3363e commit e07b835

1 file changed

Lines changed: 63 additions & 0 deletions

File tree

Doc/lib/libdifflib.tex

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,38 @@ \section{\module{difflib} ---
5252
characters.
5353
\end{classdesc*}
5454

55+
\begin{funcdesc}{context_diff}{a, b\optional{, fromfile\optional{, tofile
56+
\optional{, fromfiledate\optional{, tofiledate\optional{, n
57+
\optional{, lineterm}}}}}}}
58+
59+
Compare \var{a} and \var{b} (lists of strings); return a
60+
delta (a generator generating the delta lines) in context diff
61+
format.
62+
63+
Context diffs are a compact way of showing just the lines that have
64+
changed plus a few lines of context. The changes are shown in a
65+
before/after style. The number of context lines is set by \var{n}
66+
which defaults to three.
67+
68+
By default, the diff control lines (those with \code{***} or \code{---})
69+
are created with a trailing newline. This is helpful so that inputs created
70+
from \function{file.readlines()} result in diffs that are suitable for use
71+
with \function{file.writelines()} since both the inputs and outputs have
72+
trailing newlines.
73+
74+
For inputs that do not have trailing newlines, set the \var{lineterm}
75+
argument to \code{""} so that the output will be uniformly newline free.
76+
77+
The context diff format normally has a header for filenames and
78+
modification times. Any or all of these may be specified using strings for
79+
\var{fromfile}, \var{tofile}, \var{fromfiledate}, and \var{tofiledate}.
80+
The modification times are normally expressed in the format returned by
81+
\function{time.ctime()}. If not specified, the strings default to blanks.
82+
83+
\file{Tools/scripts/diff.py} is a command-line front-end for this
84+
function.
85+
\end{funcdesc}
86+
5587
\begin{funcdesc}{get_close_matches}{word, possibilities\optional{,
5688
n\optional{, cutoff}}}
5789
Return a list of the best ``good enough'' matches. \var{word} is a
@@ -151,6 +183,37 @@ \section{\module{difflib} ---
151183

152184
\end{funcdesc}
153185

186+
\begin{funcdesc}{unified_diff}{a, b\optional{, fromfile\optional{, tofile
187+
\optional{, fromfiledate\optional{, tofiledate\optional{, n
188+
\optional{, lineterm}}}}}}}
189+
190+
Compare \var{a} and \var{b} (lists of strings); return a
191+
delta (a generator generating the delta lines) in unified diff
192+
format.
193+
194+
Unified diffs are a compact way of showing just the lines that have
195+
changed plus a few lines of context. The changes are shown in a
196+
inline style (instead of separate before/after blocks). The number
197+
of context lines is set by \var{n} which defaults to three.
198+
199+
By default, the diff control lines (those with \code{---}, \code{+++},
200+
or \code{@@}) are created with a trailing newline. This is helpful so
201+
that inputs created from \function{file.readlines()} result in diffs
202+
that are suitable for use with \function{file.writelines()} since both
203+
the inputs and outputs have trailing newlines.
204+
205+
For inputs that do not have trailing newlines, set the \var{lineterm}
206+
argument to \code{""} so that the output will be uniformly newline free.
207+
208+
The context diff format normally has a header for filenames and
209+
modification times. Any or all of these may be specified using strings for
210+
\var{fromfile}, \var{tofile}, \var{fromfiledate}, and \var{tofiledate}.
211+
The modification times are normally expressed in the format returned by
212+
\function{time.ctime()}. If not specified, the strings default to blanks.
213+
214+
\file{Tools/scripts/diff.py} is a command-line front-end for this
215+
function.
216+
\end{funcdesc}
154217

155218
\begin{funcdesc}{IS_LINE_JUNK}{line}
156219
Return true for ignorable lines. The line \var{line} is ignorable

0 commit comments

Comments
 (0)