Skip to content

Commit 1ca28a0

Browse files
copy existing generated/ docstring page
to make sure we have the correct autodoc template
1 parent 812eb01 commit 1ca28a0

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

doc/make.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,29 @@ def _single_doc_type(self):
126126
else:
127127
return 'api'
128128

129+
def _copy_generated_docstring(self, method):
130+
"""Copy existing generated (from api.rst) docstring page because
131+
this is more correct in certain cases (where a custom autodoc
132+
template is used).
133+
134+
"""
135+
fname = os.path.join(SOURCE_PATH, 'generated',
136+
'pandas.{}.rst'.format(method))
137+
temp_dir = os.path.join(SOURCE_PATH, 'generated_single')
138+
139+
try:
140+
os.makedirs(temp_dir)
141+
except OSError:
142+
pass
143+
144+
if os.path.exists(fname):
145+
try:
146+
# copying to make sure sphinx always thinks it is new
147+
# and needs to be re-generated (to pick source code changes)
148+
shutil.copy(fname, temp_dir)
149+
except: # noqa
150+
pass
151+
129152
def _generate_index(self):
130153
"""Create index.rst file with the specified sections."""
131154
if self.single_doc_type == 'rst':
@@ -137,6 +160,9 @@ def _generate_index(self):
137160
else:
138161
single_doc = self.single_doc
139162

163+
if self.single_doc_type == 'api':
164+
self._copy_generated_docstring(single_doc)
165+
140166
with open(os.path.join(SOURCE_PATH, 'index.rst.template')) as f:
141167
t = jinja2.Template(f.read())
142168

0 commit comments

Comments
 (0)