From d65e16b5abc73b3343699290c315f5e3dff438b4 Mon Sep 17 00:00:00 2001 From: Joel Nothman Date: Tue, 31 Oct 2017 18:08:38 +1100 Subject: [PATCH 1/4] Avoid reprocessing already numpydocced docstrings --- numpydoc/numpydoc.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/numpydoc/numpydoc.py b/numpydoc/numpydoc.py index d7b84254..36953056 100644 --- a/numpydoc/numpydoc.py +++ b/numpydoc/numpydoc.py @@ -63,7 +63,12 @@ def rename_references(app, what, name, obj, options, lines, reference_offset[0] += len(references) +DEDUPLICATION_TAG = ['..', ' processed by numpydoc'] + + def mangle_docstrings(app, what, name, obj, options, lines): + if lines[-len(DEDUPLICATION_TAG):] == DEDUPLICATION_TAG: + return cfg = {'use_plots': app.config.numpydoc_use_plots, 'show_class_members': app.config.numpydoc_show_class_members, @@ -71,6 +76,8 @@ def mangle_docstrings(app, what, name, obj, options, lines): app.config.numpydoc_show_inherited_class_members, 'class_members_toctree': app.config.numpydoc_class_members_toctree} + print(locals()) + u_NL = sixu('\n') if what == 'module': # Strip top title @@ -100,6 +107,8 @@ def mangle_docstrings(app, what, name, obj, options, lines): # duplicates rename_references(app, what, name, obj, options, lines) + lines += DEDUPLICATION_TAG + def mangle_signature(app, what, name, obj, options, sig, retann): # Do not try to inspect classes that don't define `__init__` From 8a7fa50076fece9fb7f731706d00d9144f55dc18 Mon Sep 17 00:00:00 2001 From: Joel Nothman Date: Tue, 31 Oct 2017 18:50:42 +1100 Subject: [PATCH 2/4] Remove debugging print statement --- numpydoc/numpydoc.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/numpydoc/numpydoc.py b/numpydoc/numpydoc.py index 36953056..943bb5d5 100644 --- a/numpydoc/numpydoc.py +++ b/numpydoc/numpydoc.py @@ -76,8 +76,6 @@ def mangle_docstrings(app, what, name, obj, options, lines): app.config.numpydoc_show_inherited_class_members, 'class_members_toctree': app.config.numpydoc_class_members_toctree} - print(locals()) - u_NL = sixu('\n') if what == 'module': # Strip top title From 795f576b8fa8bac56a422b2d6000c9c2c5c96efc Mon Sep 17 00:00:00 2001 From: Joel Nothman Date: Wed, 1 Nov 2017 21:15:42 +1100 Subject: [PATCH 3/4] Make sure case when class + method docstrings are combined is not reprocessed --- numpydoc/numpydoc.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/numpydoc/numpydoc.py b/numpydoc/numpydoc.py index 943bb5d5..01ef39fa 100644 --- a/numpydoc/numpydoc.py +++ b/numpydoc/numpydoc.py @@ -63,11 +63,11 @@ def rename_references(app, what, name, obj, options, lines, reference_offset[0] += len(references) -DEDUPLICATION_TAG = ['..', ' processed by numpydoc'] +DEDUPLICATION_TAG = ' !! processed by numpydoc !!' def mangle_docstrings(app, what, name, obj, options, lines): - if lines[-len(DEDUPLICATION_TAG):] == DEDUPLICATION_TAG: + if DEDUPLICATION_TAG in lines: return cfg = {'use_plots': app.config.numpydoc_use_plots, @@ -105,7 +105,7 @@ def mangle_docstrings(app, what, name, obj, options, lines): # duplicates rename_references(app, what, name, obj, options, lines) - lines += DEDUPLICATION_TAG + lines += ['..', ' ' + DEDUPLICATION_TAG] def mangle_signature(app, what, name, obj, options, sig, retann): From f902cc787089dc159b2378ea5edafb1152631dad Mon Sep 17 00:00:00 2001 From: Joel Nothman Date: Wed, 1 Nov 2017 22:16:52 +1100 Subject: [PATCH 4/4] Correct deduplication logic --- numpydoc/numpydoc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/numpydoc/numpydoc.py b/numpydoc/numpydoc.py index 01ef39fa..c14fb0e4 100644 --- a/numpydoc/numpydoc.py +++ b/numpydoc/numpydoc.py @@ -105,7 +105,7 @@ def mangle_docstrings(app, what, name, obj, options, lines): # duplicates rename_references(app, what, name, obj, options, lines) - lines += ['..', ' ' + DEDUPLICATION_TAG] + lines += ['..', DEDUPLICATION_TAG] def mangle_signature(app, what, name, obj, options, sig, retann):