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

Skip to content

Commit 8f37c92

Browse files
committed
Improve reference checkign
1 parent 6fab2e0 commit 8f37c92

2 files changed

Lines changed: 28 additions & 10 deletions

File tree

doc/missing-references.json

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -373,15 +373,15 @@
373373
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.contourf:133"
374374
],
375375
"P_{xy}": [
376-
"lib/matplotlib/axes/_axes.py:docstring of matplotlib.axes.Axes.csd:168",
376+
"lib/matplotlib/axes/_axes.py:docstring of matplotlib.axes.Axes.csd:167",
377377
"lib/matplotlib/axes/_axes.py:docstring of matplotlib.axes.Axes.csd:89",
378378
"lib/matplotlib/mlab.py:docstring of matplotlib.mlab.csd:79",
379-
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.csd:168",
379+
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.csd:167",
380380
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.csd:89"
381381
],
382382
"Lines2D": [
383-
"lib/matplotlib/axes/_axes.py:docstring of matplotlib.axes.Axes.errorbar:105",
384-
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.errorbar:105"
383+
"lib/matplotlib/axes/_axes.py:docstring of matplotlib.axes.Axes.errorbar:103",
384+
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.errorbar:103"
385385
],
386386
"fmt_xdata": [
387387
"lib/matplotlib/axes/_base.py:docstring of matplotlib.axes.Axes.format_xdata:4"
@@ -1473,6 +1473,11 @@
14731473
"Locator.view_limits()": [
14741474
"doc/api/next_api_changes/2019-02-19-AL.rst:4"
14751475
],
1476+
"MovieWriterRegistry": [
1477+
"doc/api/next_api_changes/2019-03-03-AL.rst:10",
1478+
"doc/api/next_api_changes/2019-03-03-AL.rst:4",
1479+
"doc/api/prev_api_changes/api_changes_2.2.0.rst:158"
1480+
],
14761481
"Axes.add_line": [
14771482
"doc/api/next_api_changes/2019-03-04-AL.rst:9"
14781483
],
@@ -1551,6 +1556,9 @@
15511556
"imshow(A, interpolation='antialiased')": [
15521557
"doc/api/next_api_changes/2019-07-17-JMK.rst:8"
15531558
],
1559+
"SymLogScale": [
1560+
"doc/api/next_api_changes/2019-07-24-AL.rst:4"
1561+
],
15541562
"api_changes.rst": [
15551563
"doc/api/next_api_changes/README.rst:6"
15561564
],
@@ -2471,9 +2479,6 @@
24712479
"fontd": [
24722480
"doc/api/prev_api_changes/api_changes_2.2.0.rst:110"
24732481
],
2474-
"MovieWriterRegistry": [
2475-
"doc/api/prev_api_changes/api_changes_2.2.0.rst:158"
2476-
],
24772482
"MovieWriter": [
24782483
"doc/api/prev_api_changes/api_changes_2.2.0.rst:158"
24792484
],

doc/sphinxext/missing_references.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,18 @@ def get_location(node, app):
129129
return f"{path}:{line}"
130130

131131

132+
def _truncate_location(location):
133+
"""
134+
Cuts off anything after the first colon in location strings.
135+
136+
This allows for easy comparison even when line numbers chagne
137+
(as they do regularily).
138+
"""
139+
if ":" in location:
140+
return location.split(":", 1)[0]
141+
return location
142+
143+
132144
def _warn_unused_missing_references(app):
133145
if not app.config.missing_references_warn_unused_ignores:
134146
return
@@ -148,13 +160,14 @@ def _warn_unused_missing_references(app):
148160

149161
# Warn about any reference which is no longer missing.
150162
for (domain_type, target), locations in references_ignored.items():
151-
missing_reference_locations = references_events.get(
152-
(domain_type, target), [])
163+
missing_reference_locations = [_truncate_location(location)
164+
for location in references_events.get((domain_type, target), [])]
153165

154166
# For each ignored reference location, ensure a missing reference
155167
# was observed. If it wasn't observed, issue a warning.
156168
for ignored_reference_location in locations:
157-
if ignored_reference_location not in missing_reference_locations:
169+
short_location = _truncate_location(ignored_reference_location)
170+
if short_location not in missing_reference_locations:
158171
msg = (f"Reference {domain_type} {target} for "
159172
f"{ignored_reference_location} can be removed"
160173
f" from {app.config.missing_references_filename}."

0 commit comments

Comments
 (0)