Skip to content

Commit de5faf1

Browse files
Scorpiljreback
authored andcommitted
Lint rule to catch incorrect sphinx directives (#18437)
1 parent de4b384 commit de5faf1

File tree

5 files changed

+24
-11
lines changed

5 files changed

+24
-11
lines changed

ci/lint.sh

+14-1
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,26 @@ if [ "$LINT" ]; then
9090
#
9191
# Check the following functions:
9292
# any(), all(), sum(), max(), min(), list(), dict(), set(), frozenset(), tuple(), str.join()
93-
grep -R --include="*.py*" -E "[^_](any|all|sum|max|min|list|dict|set|frozenset|tuple|join)\(\[.* for .* in .*\]\)"
93+
grep -R --include="*.py*" -E "[^_](any|all|sum|max|min|list|dict|set|frozenset|tuple|join)\(\[.* for .* in .*\]\)" *
9494

9595
if [ $? = "0" ]; then
9696
RET=1
9797
fi
9898
echo "Check for use of lists instead of generators in built-in Python functions DONE"
9999

100+
echo "Check for incorrect sphinx directives"
101+
SPHINX_DIRECTIVES=$(echo \
102+
"autosummary|contents|currentmodule|deprecated|function|image|"\
103+
"important|include|ipython|literalinclude|math|module|note|raw|"\
104+
"seealso|toctree|versionadded|versionchanged|warning" | tr -d "[:space:]")
105+
for path in './pandas' './doc/source'
106+
do
107+
grep -R --include="*.py" --include="*.pyx" --include="*.rst" -E "\.\. ($SPHINX_DIRECTIVES):[^:]" $path
108+
if [ $? = "0" ]; then
109+
RET=1
110+
fi
111+
done
112+
echo "Check for incorrect sphinx directives DONE"
100113
else
101114
echo "NOT Linting"
102115
fi

pandas/core/frame.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -4513,7 +4513,7 @@ def unstack(self, level=-1, fill_value=None):
45134513
fill_value : replace NaN with this value if the unstack produces
45144514
missing values
45154515
4516-
.. versionadded: 0.18.0
4516+
.. versionadded:: 0.18.0
45174517
45184518
See also
45194519
--------
@@ -4676,7 +4676,7 @@ def diff(self, periods=1, axis=0):
46764676
axis : {0 or 'index', 1 or 'columns'}, default 0
46774677
Take difference over rows (0) or columns (1).
46784678
4679-
.. versionadded: 0.16.1
4679+
.. versionadded:: 0.16.1
46804680
46814681
Returns
46824682
-------

pandas/core/series.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1626,7 +1626,7 @@ def append(self, to_append, ignore_index=False, verify_integrity=False):
16261626
ignore_index : boolean, default False
16271627
If True, do not use the index labels.
16281628
1629-
.. versionadded: 0.19.0
1629+
.. versionadded:: 0.19.0
16301630
16311631
verify_integrity : boolean, default False
16321632
If True, raise Exception on creating index with duplicates
@@ -2213,7 +2213,7 @@ def unstack(self, level=-1, fill_value=None):
22132213
fill_value : replace NaN with this value if the unstack produces
22142214
missing values
22152215
2216-
.. versionadded: 0.18.0
2216+
.. versionadded:: 0.18.0
22172217
22182218
Examples
22192219
--------

pandas/core/tools/datetimes.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def to_datetime(arg, errors='raise', dayfirst=False, yearfirst=False,
114114
----------
115115
arg : integer, float, string, datetime, list, tuple, 1-d array, Series
116116
117-
.. versionadded: 0.18.1
117+
.. versionadded:: 0.18.1
118118
119119
or DataFrame/dict-like
120120
@@ -140,7 +140,7 @@ def to_datetime(arg, errors='raise', dayfirst=False, yearfirst=False,
140140
Warning: yearfirst=True is not strict, but will prefer to parse
141141
with year first (this is a known bug, based on dateutil beahavior).
142142
143-
.. versionadded: 0.16.1
143+
.. versionadded:: 0.16.1
144144
145145
utc : boolean, default None
146146
Return UTC DatetimeIndex if True (converting any tz-aware
@@ -178,13 +178,13 @@ def to_datetime(arg, errors='raise', dayfirst=False, yearfirst=False,
178178
- If Timestamp convertible, origin is set to Timestamp identified by
179179
origin.
180180
181-
.. versionadded: 0.20.0
181+
.. versionadded:: 0.20.0
182182
cache : boolean, default False
183183
If True, use a cache of unique, converted dates to apply the datetime
184184
conversion. May produce sigificant speed-up when parsing duplicate date
185185
strings, especially ones with timezone offsets.
186186
187-
.. versionadded: 0.22.0
187+
.. versionadded:: 0.22.0
188188
189189
Returns
190190
-------

pandas/tseries/offsets.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,7 @@ class BusinessHour(BusinessHourMixin, SingleConstructorOffset):
774774
"""
775775
DateOffset subclass representing possibly n business days
776776
777-
.. versionadded: 0.16.1
777+
.. versionadded:: 0.16.1
778778
779779
"""
780780
_prefix = 'BH'
@@ -878,7 +878,7 @@ class CustomBusinessHour(BusinessHourMixin, SingleConstructorOffset):
878878
"""
879879
DateOffset subclass representing possibly n custom business days
880880
881-
.. versionadded: 0.18.1
881+
.. versionadded:: 0.18.1
882882
883883
"""
884884
_prefix = 'CBH'

0 commit comments

Comments
 (0)