Skip to content

Commit e5500c9

Browse files
author
y-p
committed
BLD/DOC: add logic to sphinx conf.py to speedup processing
1 parent 831ea80 commit e5500c9

File tree

1 file changed

+41
-4
lines changed

1 file changed

+41
-4
lines changed

doc/source/conf.py

+41-4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
import sys
1414
import os
15+
import re
1516
from pandas.compat import u
1617

1718
# If extensions (or modules to document with autodoc) are in another directory,
@@ -46,11 +47,50 @@
4647
'sphinx.ext.coverage',
4748
'sphinx.ext.pngmath',
4849
'sphinx.ext.ifconfig',
49-
'sphinx.ext.autosummary',
5050
'matplotlib.sphinxext.only_directives',
5151
'matplotlib.sphinxext.plot_directive',
5252
]
5353

54+
55+
56+
with open("index.rst") as f:
57+
lines = f.readlines()
58+
59+
# only include the slow autosummary feature if we're building the API section
60+
# of the docs
61+
62+
# JP: added from sphinxdocs
63+
autosummary_generate = False
64+
65+
if any([re.match("\s*api\s*",l) for l in lines]):
66+
extensions.append('sphinx.ext.autosummary')
67+
autosummary_generate = True
68+
69+
ds = []
70+
for f in os.listdir(os.path.dirname(__file__)):
71+
if (not f.endswith(('.rst'))) or (f.startswith('.')) or os.path.basename(f) == 'index.rst':
72+
continue
73+
74+
_f = f.split('.rst')[0]
75+
if not any([re.match("\s*%s\s*$" % _f,l) for l in lines]):
76+
ds.append(f)
77+
78+
if ds:
79+
print("I'm about to DELETE the following:\n%s\n" % list(sorted(ds)))
80+
sys.stdout.write("WARNING: I'd like to delete those to speed up proccesing (yes/no)? ")
81+
answer = raw_input()
82+
83+
if answer.lower().strip() in ('y','yes'):
84+
for f in ds:
85+
f = os.path.join(os.path.join(os.path.dirname(__file__),f))
86+
f= os.path.abspath(f)
87+
try:
88+
print("Deleting %s" % f)
89+
os.unlink(f)
90+
except:
91+
print("Error deleting %s" % f)
92+
pass
93+
5494
# Add any paths that contain templates here, relative to this directory.
5595
templates_path = ['../_templates']
5696

@@ -80,9 +120,6 @@
80120
# The full version, including alpha/beta/rc tags.
81121
release = version
82122

83-
# JP: added from sphinxdocs
84-
autosummary_generate = True
85-
86123
# The language for content autogenerated by Sphinx. Refer to documentation
87124
# for a list of supported languages.
88125
# language = None

0 commit comments

Comments
 (0)