Skip to content

Commit 358e08d

Browse files
enable building all api pages with --single api.rst
1 parent 09c508a commit 358e08d

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

doc/make.py

+14-10
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def __init__(self, num_jobs=1, include_api=True, single_doc=None):
8585
self.exclude_patterns = self._exclude_patterns
8686

8787
self._generate_index()
88-
if self.single_doc_type == 'api':
88+
if self.single_doc_type == 'docstring':
8989
self._run_os('sphinx-autogen', '-o',
9090
'source/generated_single', 'source/index.rst')
9191

@@ -98,7 +98,8 @@ def _exclude_patterns(self):
9898
if ((f.endswith('.rst') or f.endswith('.ipynb'))
9999
and (f != 'index.rst')
100100
and (f != self.single_doc))]
101-
rst_files += ['generated/*.rst']
101+
if self.single_doc_type != 'api':
102+
rst_files += ['generated/*.rst']
102103
elif not self.include_api:
103104
rst_files = ['api.rst', 'generated/*.rst']
104105
else:
@@ -112,6 +113,8 @@ def _exclude_patterns(self):
112113
@property
113114
def _single_doc_type(self):
114115
if self.single_doc:
116+
if self.single_doc == 'api.rst':
117+
return 'api'
115118
if os.path.exists(os.path.join(SOURCE_PATH, self.single_doc)):
116119
return 'rst'
117120
try:
@@ -124,7 +127,7 @@ def _single_doc_type(self):
124127
'"contributing.rst" or a pandas function or '
125128
'method (e.g. "pandas.DataFrame.head")')
126129
else:
127-
return 'api'
130+
return 'docstring'
128131

129132
def _copy_generated_docstring(self, method):
130133
"""Copy existing generated (from api.rst) docstring page because
@@ -154,14 +157,15 @@ def _generate_index(self):
154157
if self.single_doc_type == 'rst':
155158
single_doc = os.path.splitext(os.path.basename(self.single_doc))[0]
156159
self.include_api = False
157-
elif self.single_doc_type == 'api' and \
158-
self.single_doc.startswith('pandas.'):
159-
single_doc = self.single_doc[len('pandas.'):]
160-
else:
161-
single_doc = self.single_doc
162-
163-
if self.single_doc_type == 'api':
160+
elif self.single_doc_type == 'docstring':
161+
if self.single_doc.startswith('pandas.'):
162+
single_doc = self.single_doc[len('pandas.'):]
163+
else:
164+
single_doc = self.single_doc
165+
self.include_api = False
164166
self._copy_generated_docstring(single_doc)
167+
elif self.single_doc_type == 'api':
168+
single_doc = 'api'
165169

166170
with open(os.path.join(SOURCE_PATH, 'index.rst.template')) as f:
167171
t = jinja2.Template(f.read())

doc/source/index.rst.template

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ Some other notes
106106
See the package overview for more detail about what's in the library.
107107

108108

109-
{% if single_doc_type == 'api' -%}
109+
{% if single_doc_type == 'docstring' -%}
110110
.. autosummary::
111111
:toctree: generated_single/
112112
{% else -%}

0 commit comments

Comments
 (0)