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