File tree 1 file changed +26
-0
lines changed 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -126,6 +126,29 @@ def _single_doc_type(self):
126
126
else :
127
127
return 'api'
128
128
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
+
129
152
def _generate_index (self ):
130
153
"""Create index.rst file with the specified sections."""
131
154
if self .single_doc_type == 'rst' :
@@ -137,6 +160,9 @@ def _generate_index(self):
137
160
else :
138
161
single_doc = self .single_doc
139
162
163
+ if self .single_doc_type == 'api' :
164
+ self ._copy_generated_docstring (single_doc )
165
+
140
166
with open (os .path .join (SOURCE_PATH , 'index.rst.template' )) as f :
141
167
t = jinja2 .Template (f .read ())
142
168
You can’t perform that action at this time.
0 commit comments