@@ -306,6 +306,33 @@ def test_autosummary_generate_content_for_module_imported_members(app):
306
306
assert context ['objtype' ] == 'module'
307
307
308
308
309
+ @pytest .mark .sphinx (testroot = 'ext-autosummary' )
310
+ def test_autosummary_generate_content_for_module_imported_members_inherited_module (app ):
311
+ import autosummary_dummy_inherited_module
312
+ template = Mock ()
313
+
314
+ generate_autosummary_content ('autosummary_dummy_inherited_module' ,
315
+ autosummary_dummy_inherited_module , None ,
316
+ template , None , True , app , False , {})
317
+ assert template .render .call_args [0 ][0 ] == 'module'
318
+
319
+ context = template .render .call_args [0 ][1 ]
320
+ assert context ['members' ] == ['Foo' , 'InheritedAttrClass' , '__all__' , '__builtins__' , '__cached__' ,
321
+ '__doc__' , '__file__' , '__loader__' , '__name__' ,
322
+ '__package__' , '__spec__' ]
323
+ assert context ['functions' ] == []
324
+ assert context ['classes' ] == ['Foo' , 'InheritedAttrClass' ]
325
+ assert context ['exceptions' ] == []
326
+ assert context ['all_exceptions' ] == []
327
+ assert context ['attributes' ] == []
328
+ assert context ['all_attributes' ] == []
329
+ assert context ['fullname' ] == 'autosummary_dummy_inherited_module'
330
+ assert context ['module' ] == 'autosummary_dummy_inherited_module'
331
+ assert context ['objname' ] == ''
332
+ assert context ['name' ] == ''
333
+ assert context ['objtype' ] == 'module'
334
+
335
+
309
336
@pytest .mark .sphinx ('dummy' , testroot = 'ext-autosummary' )
310
337
def test_autosummary_generate (app , status , warning ):
311
338
app .builder .build_all ()
@@ -324,16 +351,20 @@ def test_autosummary_generate(app, status, warning):
324
351
nodes .row ,
325
352
nodes .row ,
326
353
nodes .row ,
354
+ nodes .row ,
355
+ nodes .row ,
327
356
nodes .row )])])
328
357
assert_node (doctree [4 ][0 ], addnodes .toctree , caption = "An autosummary" )
329
358
330
- assert len (doctree [3 ][0 ][0 ][2 ]) == 6
359
+ assert len (doctree [3 ][0 ][0 ][2 ]) == 8
331
360
assert doctree [3 ][0 ][0 ][2 ][0 ].astext () == 'autosummary_dummy_module\n \n '
332
361
assert doctree [3 ][0 ][0 ][2 ][1 ].astext () == 'autosummary_dummy_module.Foo()\n \n '
333
362
assert doctree [3 ][0 ][0 ][2 ][2 ].astext () == 'autosummary_dummy_module.Foo.Bar()\n \n '
334
363
assert doctree [3 ][0 ][0 ][2 ][3 ].astext () == 'autosummary_dummy_module.Foo.value\n \n docstring'
335
364
assert doctree [3 ][0 ][0 ][2 ][4 ].astext () == 'autosummary_dummy_module.bar(x[, y])\n \n '
336
365
assert doctree [3 ][0 ][0 ][2 ][5 ].astext () == 'autosummary_dummy_module.qux\n \n a module-level attribute'
366
+ assert doctree [3 ][0 ][0 ][2 ][6 ].astext () == 'autosummary_dummy_inherited_module.InheritedAttrClass()\n \n '
367
+ assert doctree [3 ][0 ][0 ][2 ][7 ].astext () == 'autosummary_dummy_inherited_module.InheritedAttrClass.subclassattr\n \n other docstring'
337
368
338
369
module = (app .srcdir / 'generated' / 'autosummary_dummy_module.rst' ).read_text (encoding = 'utf8' )
339
370
@@ -379,6 +410,28 @@ def test_autosummary_generate(app, status, warning):
379
410
'\n '
380
411
'.. autodata:: qux' in qux )
381
412
413
+ InheritedAttrClass = (app .srcdir / 'generated' / 'autosummary_dummy_inherited_module.InheritedAttrClass.rst' ).read_text (encoding = 'utf8' )
414
+ print (InheritedAttrClass )
415
+ assert '.. automethod:: __init__' in Foo
416
+ assert (' .. autosummary::\n '
417
+ ' \n '
418
+ ' ~InheritedAttrClass.__init__\n '
419
+ ' ~InheritedAttrClass.bar\n '
420
+ ' \n ' in InheritedAttrClass )
421
+ assert (' .. autosummary::\n '
422
+ ' \n '
423
+ ' ~InheritedAttrClass.CONSTANT3\n '
424
+ ' ~InheritedAttrClass.CONSTANT4\n '
425
+ ' ~InheritedAttrClass.baz\n '
426
+ ' ~InheritedAttrClass.subclassattr\n '
427
+ ' ~InheritedAttrClass.value\n '
428
+ ' \n ' in InheritedAttrClass )
429
+
430
+ InheritedAttrClass_subclassattr = (app .srcdir / 'generated' / 'autosummary_dummy_inherited_module.InheritedAttrClass.subclassattr.rst' ).read_text (encoding = 'utf8' )
431
+ assert ('.. currentmodule:: autosummary_dummy_inherited_module\n '
432
+ '\n '
433
+ '.. autoattribute:: InheritedAttrClass.subclassattr' in InheritedAttrClass_subclassattr )
434
+
382
435
383
436
@pytest .mark .sphinx ('dummy' , testroot = 'ext-autosummary' ,
384
437
confoverrides = {'autosummary_generate_overwrite' : False })
0 commit comments