Skip to content

Commit e064b41

Browse files
committed
Patch #914575: difflib side by side diff support, diff.py s/b/s HTML option.
1 parent 87fa785 commit e064b41

7 files changed

Lines changed: 1412 additions & 7 deletions

File tree

Doc/lib/libdifflib.tex

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

55+
\begin{classdesc*}{HtmlDiff}
56+
57+
This class can be used to create an HTML table (or a complete HTML file
58+
containing the table) showing a side by side, line by line comparision
59+
of text with inter-line and intra-line change highlights. The table can
60+
be generated in either full or contextual difference mode.
61+
62+
The constructor for this class is:
63+
64+
\begin{funcdesc}{__init__}{
65+
\optional{, tabsize
66+
\optional{, wrapcolumn
67+
\optional{, linejunk
68+
\optional{, charjunk}}}}}
69+
70+
Initializes instance of \class{HtmlDiff}.
71+
72+
\var{tabsize} is an optional keyword argument to specify tab stop spacing
73+
and defaults to \code{8}.
74+
75+
\var{wrapcolumn} is an optional keyword to specify column number where
76+
lines are broken and wrapped, defaults to \code{None} where lines are not
77+
wrapped.
78+
79+
\var{linejunk} and \var{charjunk} are optional keyword arguments passed
80+
into \code{ndiff()} (used to by \class{HtmlDiff} to generate the
81+
side by side HTML differences). See \code{ndiff()} documentation for
82+
argument default values and descriptions.
83+
\end{funcdesc}
84+
85+
The following methods are public:
86+
87+
\begin{funcdesc}{make_file}{fromlines, tolines
88+
\optional{, fromdesc
89+
\optional{, todesc
90+
\optional{, context
91+
\optional{, numlines}}}}}
92+
Compares \var{fromlines} and \var{tolines} (lists of strings) and returns
93+
a string which is a complete HTML file containing a table showing line by
94+
line differences with inter-line and intra-line changes highlighted.
95+
96+
\var{fromdesc} and \var{todesc} are optional keyword arguments to specify
97+
from/to file column header strings (both default to an empty string).
98+
99+
\var{context} and \var{numlines} are both optional keyword arguments.
100+
Set \var{context} to \code{True} when contextual differences are to be
101+
shown, else the default is \code{False} to show the full files.
102+
\var{numlines} defaults to \code{5}. When \var{context} is \code{True}
103+
\var{numlines} controls the number of context lines which surround the
104+
difference highlights. When \var{context} is \code{False} \var{numlines}
105+
controls the number of lines which are shown before a difference
106+
highlight when using the "next" hyperlinks (setting to zero would cause
107+
the "next" hyperlinks to place the next difference highlight at the top of
108+
the browser without any leading context).
109+
\end{funcdesc}
110+
111+
\begin{funcdesc}{make_table}{fromlines, tolines
112+
\optional{, fromdesc
113+
\optional{, todesc
114+
\optional{, context}}}}
115+
Compares \var{fromlines} and \var{tolines} (lists of strings) and returns
116+
a string which is a complete HTML table showing line by line differences
117+
with inter-line and intra-line changes highlighted.
118+
119+
The arguments of this method are a subset of those for the
120+
\code{make_file} method. Refer to the \code{make_file} method
121+
documentation.
122+
\end{funcdesc}
123+
124+
\file{Tools/scripts/ndiff.py} is a command-line front-end to this class
125+
and contains a good example of its use.
126+
\end{classdesc*}
127+
55128
\begin{funcdesc}{context_diff}{a, b\optional{, fromfile\optional{, tofile
56129
\optional{, fromfiledate\optional{, tofiledate\optional{, n
57130
\optional{, lineterm}}}}}}}

0 commit comments

Comments
 (0)