@@ -10,17 +10,26 @@ def autodoc_skip_member(app, what, name, obj, skip, options):
10
10
return skip
11
11
12
12
13
- def _adjust_rendered_mod_name (modname , objname ):
14
- modname = modname .replace ("sqlalchemy.sql.sqltypes" , "sqlalchemy.types" )
15
- modname = modname .replace ("sqlalchemy.sql.type_api" , "sqlalchemy.types" )
16
- modname = modname .replace ("sqlalchemy.sql.schema" , "sqlalchemy.schema" )
17
- modname = modname .replace ("sqlalchemy.sql.elements" , "sqlalchemy.sql.expression" )
18
- modname = modname .replace ("sqlalchemy.sql.selectable" , "sqlalchemy.sql.expression" )
19
- modname = modname .replace ("sqlalchemy.sql.dml" , "sqlalchemy.sql.expression" )
20
- modname = modname .replace ("sqlalchemy.sql.ddl" , "sqlalchemy.schema" )
21
- modname = modname .replace ("sqlalchemy.sql.base" , "sqlalchemy.sql.expression" )
13
+ _convert_modname = {
14
+ "sqlalchemy.sql.sqltypes" : "sqlalchemy.types" ,
15
+ "sqlalchemy.sql.type_api" : "sqlalchemy.types" ,
16
+ "sqlalchemy.sql.schema" : "sqlalchemy.schema" ,
17
+ "sqlalchemy.sql.elements" : "sqlalchemy.sql.expression" ,
18
+ "sqlalchemy.sql.selectable" : "sqlalchemy.sql.expression" ,
19
+ "sqlalchemy.sql.dml" : "sqlalchemy.sql.expression" ,
20
+ "sqlalchemy.sql.ddl" : "sqlalchemy.schema" ,
21
+ "sqlalchemy.sql.base" : "sqlalchemy.sql.expression"
22
+ }
23
+
24
+ _convert_modname_w_class = {
25
+ ("sqlalchemy.engine.interfaces" , "Connectable" ): "sqlalchemy.engine"
26
+ }
22
27
23
- return modname
28
+ def _adjust_rendered_mod_name (modname , objname ):
29
+ if modname in _convert_modname :
30
+ return _convert_modname [modname ]
31
+ elif (modname , objname ) in _convert_modname_w_class :
32
+ return _convert_modname_w_class [(modname , objname )]
24
33
25
34
# im sure this is in the app somewhere, but I don't really
26
35
# know where, so we're doing it here.
@@ -30,6 +39,9 @@ def autodoc_process_docstring(app, what, name, obj, options, lines):
30
39
if what == "class" :
31
40
_track_autodoced [name ] = obj
32
41
42
+ # need to translate module names for bases, others
43
+ # as we document lots of symbols in namespace modules
44
+ # outside of their source
33
45
bases = []
34
46
for base in obj .__bases__ :
35
47
if base is not object :
@@ -38,11 +50,10 @@ def autodoc_process_docstring(app, what, name, obj, options, lines):
38
50
base .__name__ ))
39
51
40
52
if bases :
41
- lines .insert (0 ,
42
- "Bases: %s" % (
43
- ", " .join (bases )
44
- ))
45
- lines .insert (1 , "" )
53
+ lines [:0 ] = [
54
+ "Bases: %s" % (", " .join (bases )),
55
+ ""
56
+ ]
46
57
47
58
48
59
elif what in ("attribute" , "method" ) and \
@@ -74,7 +85,6 @@ def autodoc_process_docstring(app, what, name, obj, options, lines):
74
85
""
75
86
]
76
87
77
- from docutils import nodes
78
88
def missing_reference (app , env , node , contnode ):
79
89
if node .attributes ['reftarget' ] in _inherited_names :
80
90
return node .children [0 ]
0 commit comments