11
11
from sphinx .jinja2glue import BuiltinTemplateLoader
12
12
13
13
from .docscrape import NumpyDocString , FunctionDoc , ClassDoc , ObjDoc
14
+ from .docscrape import get_doc_object as get_doc_object_orig
14
15
from .xref import make_xref
15
16
16
17
@@ -407,20 +408,10 @@ def __init__(self, obj, doc=None, config=None):
407
408
ObjDoc .__init__ (self , obj , doc = doc , config = config )
408
409
409
410
410
- # TODO: refactor to use docscrape.get_doc_object
411
411
def get_doc_object (obj , what = None , doc = None , config = None , builder = None ):
412
- if what is None :
413
- if inspect .isclass (obj ):
414
- what = "class"
415
- elif inspect .ismodule (obj ):
416
- what = "module"
417
- elif isinstance (obj , Callable ):
418
- what = "function"
419
- else :
420
- what = "object"
421
-
422
412
if config is None :
423
413
config = {}
414
+
424
415
template_dirs = [os .path .join (os .path .dirname (__file__ ), "templates" )]
425
416
if builder is not None :
426
417
template_loader = BuiltinTemplateLoader ()
@@ -430,11 +421,12 @@ def get_doc_object(obj, what=None, doc=None, config=None, builder=None):
430
421
template_env = SandboxedEnvironment (loader = template_loader )
431
422
config ["template" ] = template_env .get_template ("numpydoc_docstring.rst" )
432
423
433
- if what == "class" :
434
- return SphinxClassDoc (obj , func_doc = SphinxFunctionDoc , doc = doc , config = config )
435
- elif what in ("function" , "method" ):
436
- return SphinxFunctionDoc (obj , doc = doc , config = config )
437
- else :
438
- if doc is None :
439
- doc = pydoc .getdoc (obj )
440
- return SphinxObjDoc (obj , doc , config = config )
424
+ return get_doc_object_orig (
425
+ obj ,
426
+ what = what ,
427
+ doc = doc ,
428
+ config = config ,
429
+ class_doc = SphinxClassDoc ,
430
+ func_doc = SphinxFunctionDoc ,
431
+ obj_doc = SphinxObjDoc ,
432
+ )
0 commit comments