1
1
from __future__ import division , absolute_import , print_function
2
2
3
- import sys , re , inspect , textwrap , pydoc
3
+ import sys
4
+ import re
5
+ import inspect
6
+ import textwrap
7
+ import pydoc
4
8
import sphinx
5
9
import collections
10
+
6
11
from .docscrape import NumpyDocString , FunctionDoc , ClassDoc
7
12
8
13
if sys .version_info [0 ] >= 3 :
@@ -171,7 +176,7 @@ def _str_index(self):
171
176
if len (idx ) == 0 :
172
177
return out
173
178
174
- out += ['.. index:: %s' % idx .get ('default' ,'' )]
179
+ out += ['.. index:: %s' % idx .get ('default' , '' )]
175
180
for section , references in idx .items ():
176
181
if section == 'default' :
177
182
continue
@@ -192,9 +197,9 @@ def _str_references(self):
192
197
# Latex collects all references to a separate bibliography,
193
198
# so we need to insert links to it
194
199
if sphinx .__version__ >= "0.6" :
195
- out += ['.. only:: latex' ,'' ]
200
+ out += ['.. only:: latex' , '' ]
196
201
else :
197
- out += ['.. latexonly::' ,'' ]
202
+ out += ['.. latexonly::' , '' ]
198
203
items = []
199
204
for line in self ['References' ]:
200
205
m = re .match (r'.. \[([a-z0-9._-]+)\]' , line , re .I )
@@ -235,25 +240,29 @@ def __str__(self, indent=0, func_role="obj"):
235
240
out += self ._str_examples ()
236
241
for param_list in ('Attributes' , 'Methods' ):
237
242
out += self ._str_member_list (param_list )
238
- out = self ._str_indent (out ,indent )
243
+ out = self ._str_indent (out , indent )
239
244
return '\n ' .join (out )
240
245
246
+
241
247
class SphinxFunctionDoc (SphinxDocString , FunctionDoc ):
242
248
def __init__ (self , obj , doc = None , config = {}):
243
249
self .load_config (config )
244
250
FunctionDoc .__init__ (self , obj , doc = doc , config = config )
245
251
252
+
246
253
class SphinxClassDoc (SphinxDocString , ClassDoc ):
247
254
def __init__ (self , obj , doc = None , func_doc = None , config = {}):
248
255
self .load_config (config )
249
256
ClassDoc .__init__ (self , obj , doc = doc , func_doc = None , config = config )
250
257
258
+
251
259
class SphinxObjDoc (SphinxDocString ):
252
260
def __init__ (self , obj , doc = None , config = {}):
253
261
self ._f = obj
254
262
self .load_config (config )
255
263
SphinxDocString .__init__ (self , doc , config = config )
256
264
265
+
257
266
def get_doc_object (obj , what = None , doc = None , config = {}):
258
267
if what is None :
259
268
if inspect .isclass (obj ):
0 commit comments