Skip to content

Commit abc4ef9

Browse files
datapythonistajorisvandenbossche
authored andcommitted
DOC: Making doc/source/conf.py pass PEP-8, and added to lint (#19839)
1 parent 5af06f0 commit abc4ef9

File tree

2 files changed

+37
-34
lines changed

2 files changed

+37
-34
lines changed

ci/lint.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ if [ "$LINT" ]; then
3737
fi
3838
echo "Linting scripts/*.py DONE"
3939

40-
echo "Linting doc script"
41-
flake8 doc/make.py
40+
echo "Linting doc scripts"
41+
flake8 doc/make.py doc/source/conf.py
4242
if [ $? -ne "0" ]; then
4343
RET=1
4444
fi
45-
echo "Linting doc script DONE"
45+
echo "Linting doc scripts DONE"
4646

4747
echo "Linting *.pyx"
4848
flake8 pandas --filename=*.pyx --select=E501,E302,E203,E111,E114,E221,E303,E128,E231,E126,E265,E305,E301,E127,E261,E271,E129,W291,E222,E241,E123,F403

doc/source/conf.py

+34-31
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
#
33
# pandas documentation build configuration file, created by
44
#
5-
# This file is execfile()d with the current directory set to its containing dir.
5+
# This file is execfile()d with the current directory set to its containing
6+
# dir.
67
#
78
# Note that not all possible configuration values are present in this
89
# autogenerated file.
@@ -49,8 +50,9 @@
4950

5051
# -- General configuration -----------------------------------------------
5152

52-
# Add any Sphinx extension module names here, as strings. They can be extensions
53-
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones. sphinxext.
53+
# Add any Sphinx extension module names here, as strings. They can be
54+
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
55+
# sphinxext.
5456

5557
extensions = ['sphinx.ext.autodoc',
5658
'sphinx.ext.autosummary',
@@ -60,7 +62,8 @@
6062
'numpydoc',
6163
'ipython_sphinxext.ipython_directive',
6264
'ipython_sphinxext.ipython_console_highlighting',
63-
'IPython.sphinxext.ipython_console_highlighting', # lowercase didn't work
65+
# lowercase didn't work
66+
'IPython.sphinxext.ipython_console_highlighting',
6467
'sphinx.ext.intersphinx',
6568
'sphinx.ext.coverage',
6669
'sphinx.ext.mathjax',
@@ -95,22 +98,24 @@
9598
files_to_delete.append(f)
9699

97100
if files_to_delete:
98-
print("I'm about to DELETE the following:\n%s\n" % list(sorted(files_to_delete)))
99-
sys.stdout.write("WARNING: I'd like to delete those to speed up processing (yes/no)? ")
101+
print("I'm about to DELETE the following:\n{}\n".format(
102+
list(sorted(files_to_delete))))
103+
sys.stdout.write("WARNING: I'd like to delete those "
104+
"to speed up processing (yes/no)? ")
100105
if PY3:
101106
answer = input()
102107
else:
103108
answer = raw_input()
104109

105-
if answer.lower().strip() in ('y','yes'):
110+
if answer.lower().strip() in ('y', 'yes'):
106111
for f in files_to_delete:
107-
f = os.path.join(os.path.join(os.path.dirname(__file__),f))
108-
f= os.path.abspath(f)
112+
f = os.path.join(os.path.join(os.path.dirname(__file__), f))
113+
f = os.path.abspath(f)
109114
try:
110-
print("Deleting %s" % f)
115+
print("Deleting {}".format(f))
111116
os.unlink(f)
112117
except:
113-
print("Error deleting %s" % f)
118+
print("Error deleting {}".format(f))
114119
pass
115120

116121
# Add any paths that contain templates here, relative to this directory.
@@ -137,7 +142,7 @@
137142
import pandas
138143

139144
# version = '%s r%s' % (pandas.__version__, svn_version())
140-
version = '%s' % (pandas.__version__)
145+
version = str(pandas.__version__)
141146

142147
# The full version, including alpha/beta/rc tags.
143148
release = version
@@ -159,8 +164,8 @@
159164
# for source files.
160165
exclude_trees = []
161166

162-
# The reST default role (used for this markup: `text`) to use for all documents.
163-
# default_role = None
167+
# The reST default role (used for this markup: `text`) to use for all
168+
# documents. default_role = None
164169

165170
# If true, '()' will be appended to :func: etc. cross-reference text.
166171
# add_function_parentheses = True
@@ -334,8 +339,8 @@
334339
# The font size ('10pt', '11pt' or '12pt').
335340
# latex_font_size = '10pt'
336341

337-
# Grouping the document tree into LaTeX files. List of tuples
338-
# (source start file, target name, title, author, documentclass [howto/manual]).
342+
# Grouping the document tree into LaTeX files. List of tuples (source start
343+
# file, target name, title, author, documentclass [howto/manual]).
339344
latex_documents = [
340345
('index', 'pandas.tex',
341346
u('pandas: powerful Python data analysis toolkit'),
@@ -392,23 +397,23 @@
392397
# wherever the docs are built. The docs' target is the browser, not
393398
# the console, so this is fine.
394399
'pd.options.display.encoding="utf8"'
395-
]
400+
]
396401

397402

398403
# Add custom Documenter to handle attributes/methods of an AccessorProperty
399404
# eg pandas.Series.str and pandas.Series.dt (see GH9322)
400405

401406
import sphinx
402407
from sphinx.util import rpartition
403-
from sphinx.ext.autodoc import Documenter, MethodDocumenter, AttributeDocumenter
408+
from sphinx.ext.autodoc import (
409+
Documenter, MethodDocumenter, AttributeDocumenter)
404410
from sphinx.ext.autosummary import Autosummary
405411

406412

407413
class AccessorDocumenter(MethodDocumenter):
408414
"""
409415
Specialized Documenter subclass for accessors.
410416
"""
411-
412417
objtype = 'accessor'
413418
directivetype = 'method'
414419

@@ -426,7 +431,6 @@ class AccessorLevelDocumenter(Documenter):
426431
Specialized Documenter subclass for objects on accessor level (methods,
427432
attributes).
428433
"""
429-
430434
# This is the simple straightforward version
431435
# modname is None, base the last elements (eg 'hour')
432436
# and path the part before (eg 'Series.dt')
@@ -436,7 +440,6 @@ class AccessorLevelDocumenter(Documenter):
436440
# mod_cls = mod_cls.split('.')
437441
#
438442
# return modname, mod_cls + [base]
439-
440443
def resolve_name(self, modname, parents, path, base):
441444
if modname is None:
442445
if path:
@@ -471,16 +474,17 @@ def resolve_name(self, modname, parents, path, base):
471474
return modname, parents + [base]
472475

473476

474-
class AccessorAttributeDocumenter(AccessorLevelDocumenter, AttributeDocumenter):
475-
477+
class AccessorAttributeDocumenter(AccessorLevelDocumenter,
478+
AttributeDocumenter):
476479
objtype = 'accessorattribute'
477480
directivetype = 'attribute'
478481

479-
# lower than AttributeDocumenter so this is not chosen for normal attributes
482+
# lower than AttributeDocumenter so this is not chosen for normal
483+
# attributes
480484
priority = 0.6
481485

482-
class AccessorMethodDocumenter(AccessorLevelDocumenter, MethodDocumenter):
483486

487+
class AccessorMethodDocumenter(AccessorLevelDocumenter, MethodDocumenter):
484488
objtype = 'accessormethod'
485489
directivetype = 'method'
486490

@@ -508,7 +512,6 @@ class PandasAutosummary(Autosummary):
508512
This alternative autosummary class lets us override the table summary for
509513
Series.plot and DataFrame.plot in the API docs.
510514
"""
511-
512515
def _replace_pandas_items(self, display_name, sig, summary, real_name):
513516
# this a hack: ideally we should extract the signature from the
514517
# .__call__ method instead of hard coding this
@@ -561,18 +564,18 @@ def linkcode_resolve(domain, info):
561564
lineno = None
562565

563566
if lineno:
564-
linespec = "#L%d-L%d" % (lineno, lineno + len(source) - 1)
567+
linespec = "#L{:d}-L{:d}".format(lineno, lineno + len(source) - 1)
565568
else:
566569
linespec = ""
567570

568571
fn = os.path.relpath(fn, start=os.path.dirname(pandas.__file__))
569572

570573
if '+' in pandas.__version__:
571-
return "http://github.com/pandas-dev/pandas/blob/master/pandas/%s%s" % (
572-
fn, linespec)
574+
return ("http://github.com/pandas-dev/pandas/blob/master/pandas/"
575+
"{}{}".format(fn, linespec))
573576
else:
574-
return "http://github.com/pandas-dev/pandas/blob/v%s/pandas/%s%s" % (
575-
pandas.__version__, fn, linespec)
577+
return ("http://github.com/pandas-dev/pandas/blob/"
578+
"v{}/pandas/{}{}".format(pandas.__version__, fn, linespec))
576579

577580

578581
# remove the docstring of the flags attribute (inherited from numpy ndarray)

0 commit comments

Comments
 (0)