From ff348a2aa0ab6ad237b1396eb9069b85f69c6548 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Wed, 15 Dec 2021 18:07:14 -0600 Subject: [PATCH] Add some minimal docs for Diff constructor --- tailbone/diffs.py | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/tailbone/diffs.py b/tailbone/diffs.py index d4031b1f..d57aa9ac 100644 --- a/tailbone/diffs.py +++ b/tailbone/diffs.py @@ -35,8 +35,29 @@ class Diff(object): Core diff class. In sore need of documentation. """ - def __init__(self, old_data, new_data, columns=None, fields=None, render_field=None, render_value=None, monospace=False, - extra_row_attrs=None): + def __init__(self, old_data, new_data, columns=None, fields=None, + render_field=None, render_value=None, + monospace=False, extra_row_attrs=None): + """ + Constructor. You must provide the old and new data sets, and + the set of relevant fields as well, if they cannot be easily + introspected. + + :param old_data: Dict of "old" data values. + + :param new_data: Dict of "old" data values. + + :param fields: Sequence of relevant field names. Note that + both data dicts are expected to have keys which match these + field names. If you do not specify the fields then they + will (hopefully) be introspected from the old or new data + sets; however this will not work if they are both empty. + + :param monospace: If true, this flag will cause the value + columns to be rendered in monospace font. This is assumed + to be helpful when comparing "raw" data values which are + shown as e.g. ``repr(val)``. + """ self.old_data = old_data self.new_data = new_data self.columns = columns or ["field name", "old value", "new value"]