@@ -319,6 +319,33 @@ def test_autosummary_generate_content_for_module_imported_members(app):
319
319
assert context ['objtype' ] == 'module'
320
320
321
321
322
+ @pytest .mark .sphinx (testroot = 'ext-autosummary' )
323
+ def test_autosummary_generate_content_for_module_imported_members_inherited_module (app ):
324
+ import autosummary_dummy_inherited_module
325
+ template = Mock ()
326
+
327
+ generate_autosummary_content ('autosummary_dummy_inherited_module' ,
328
+ autosummary_dummy_inherited_module , None ,
329
+ template , None , True , app , False , {})
330
+ assert template .render .call_args [0 ][0 ] == 'module'
331
+
332
+ context = template .render .call_args [0 ][1 ]
333
+ assert context ['members' ] == ['Foo' , 'InheritedAttrClass' , '__all__' , '__builtins__' , '__cached__' ,
334
+ '__doc__' , '__file__' , '__loader__' , '__name__' ,
335
+ '__package__' , '__spec__' ]
336
+ assert context ['functions' ] == []
337
+ assert context ['classes' ] == ['Foo' , 'InheritedAttrClass' ]
338
+ assert context ['exceptions' ] == []
339
+ assert context ['all_exceptions' ] == []
340
+ assert context ['attributes' ] == []
341
+ assert context ['all_attributes' ] == []
342
+ assert context ['fullname' ] == 'autosummary_dummy_inherited_module'
343
+ assert context ['module' ] == 'autosummary_dummy_inherited_module'
344
+ assert context ['objname' ] == ''
345
+ assert context ['name' ] == ''
346
+ assert context ['objtype' ] == 'module'
347
+
348
+
322
349
@pytest .mark .sphinx ('dummy' , testroot = 'ext-autosummary' )
323
350
def test_autosummary_generate (app , status , warning ):
324
351
app .builder .build_all ()
@@ -337,16 +364,20 @@ def test_autosummary_generate(app, status, warning):
337
364
nodes .row ,
338
365
nodes .row ,
339
366
nodes .row ,
367
+ nodes .row ,
368
+ nodes .row ,
340
369
nodes .row )])])
341
370
assert_node (doctree [4 ][0 ], addnodes .toctree , caption = "An autosummary" )
342
371
343
- assert len (doctree [3 ][0 ][0 ][2 ]) == 6
372
+ assert len (doctree [3 ][0 ][0 ][2 ]) == 8
344
373
assert doctree [3 ][0 ][0 ][2 ][0 ].astext () == 'autosummary_dummy_module\n \n '
345
374
assert doctree [3 ][0 ][0 ][2 ][1 ].astext () == 'autosummary_dummy_module.Foo()\n \n '
346
375
assert doctree [3 ][0 ][0 ][2 ][2 ].astext () == 'autosummary_dummy_module.Foo.Bar()\n \n '
347
376
assert doctree [3 ][0 ][0 ][2 ][3 ].astext () == 'autosummary_dummy_module.Foo.value\n \n docstring'
348
377
assert doctree [3 ][0 ][0 ][2 ][4 ].astext () == 'autosummary_dummy_module.bar(x[, y])\n \n '
349
378
assert doctree [3 ][0 ][0 ][2 ][5 ].astext () == 'autosummary_dummy_module.qux\n \n a module-level attribute'
379
+ assert doctree [3 ][0 ][0 ][2 ][6 ].astext () == 'autosummary_dummy_inherited_module.InheritedAttrClass()\n \n '
380
+ assert doctree [3 ][0 ][0 ][2 ][7 ].astext () == 'autosummary_dummy_inherited_module.InheritedAttrClass.subclassattr\n \n other docstring'
350
381
351
382
module = (app .srcdir / 'generated' / 'autosummary_dummy_module.rst' ).read_text (encoding = 'utf8' )
352
383
@@ -392,6 +423,28 @@ def test_autosummary_generate(app, status, warning):
392
423
'\n '
393
424
'.. autodata:: qux' in qux )
394
425
426
+ InheritedAttrClass = (app .srcdir / 'generated' / 'autosummary_dummy_inherited_module.InheritedAttrClass.rst' ).read_text (encoding = 'utf8' )
427
+ print (InheritedAttrClass )
428
+ assert '.. automethod:: __init__' in Foo
429
+ assert (' .. autosummary::\n '
430
+ ' \n '
431
+ ' ~InheritedAttrClass.__init__\n '
432
+ ' ~InheritedAttrClass.bar\n '
433
+ ' \n ' in InheritedAttrClass )
434
+ assert (' .. autosummary::\n '
435
+ ' \n '
436
+ ' ~InheritedAttrClass.CONSTANT3\n '
437
+ ' ~InheritedAttrClass.CONSTANT4\n '
438
+ ' ~InheritedAttrClass.baz\n '
439
+ ' ~InheritedAttrClass.subclassattr\n '
440
+ ' ~InheritedAttrClass.value\n '
441
+ ' \n ' in InheritedAttrClass )
442
+
443
+ InheritedAttrClass_subclassattr = (app .srcdir / 'generated' / 'autosummary_dummy_inherited_module.InheritedAttrClass.subclassattr.rst' ).read_text (encoding = 'utf8' )
444
+ assert ('.. currentmodule:: autosummary_dummy_inherited_module\n '
445
+ '\n '
446
+ '.. autoattribute:: InheritedAttrClass.subclassattr' in InheritedAttrClass_subclassattr )
447
+
395
448
396
449
@pytest .mark .sphinx ('dummy' , testroot = 'ext-autosummary' ,
397
450
confoverrides = {'autosummary_generate_overwrite' : False })
0 commit comments