diff options
author | Georg Brandl <georg@python.org> | 2010-02-28 11:39:13 +0100 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2010-02-28 11:39:13 +0100 |
commit | a31e7e2f5d2e82e2af09081ac6ee128963522895 (patch) | |
tree | 7338193901f847626069f9805128bb24f24bf01f /tests/test_autodoc.py | |
parent | 9a316a21a031bde8fa9657f74ebfba368ab88b5d (diff) | |
download | sphinx-git-a31e7e2f5d2e82e2af09081ac6ee128963522895.tar.gz |
#187: Added support for source ordering of members in autodoc, with ``autodoc_member_order = 'bysource'``.
Diffstat (limited to 'tests/test_autodoc.py')
-rw-r--r-- | tests/test_autodoc.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/test_autodoc.py b/tests/test_autodoc.py index ea41dcaa9..62768b202 100644 --- a/tests/test_autodoc.py +++ b/tests/test_autodoc.py @@ -341,6 +341,26 @@ def test_generate(): assert item in directive.result del directive.result[:] + def assert_order(items, objtype, name, member_order, **kw): + inst = AutoDirective._registry[objtype](directive, name) + inst.options.member_order = member_order + inst.generate(**kw) + assert len(_warnings) == 0, _warnings + items = list(reversed(items)) + lineiter = iter(directive.result) + #for line in directive.result: + # if line.strip(): + # print repr(line) + while items: + item = items.pop() + for line in lineiter: + if line == item: + break + else: # ran out of items! + assert False, 'item %r not found in result or not in the ' \ + ' correct order' % item + del directive.result[:] + options.members = [] # no module found? @@ -442,6 +462,22 @@ def test_generate(): assert_processes([('function', 'time.asctime')], 'function', 'asctime') assert_processes([('function', 'time.asctime')], 'function', 'asctime') + # test autodoc_member_order == 'source' + directive.env.temp_data['py:module'] = 'test_autodoc' + assert_order(['.. py:class:: Class(arg)', + ' .. py:attribute:: Class.descr', + ' .. py:method:: Class.meth()', + ' .. py:method:: Class.undocmeth()', + ' .. py:attribute:: Class.attr', + ' .. py:attribute:: Class.prop', + ' .. py:attribute:: Class.docattr', + ' .. py:attribute:: Class.udocattr', + ' .. py:attribute:: Class.inst_attr_comment', + ' .. py:attribute:: Class.inst_attr_string', + ' .. py:method:: Class.inheritedmeth()', + ], + 'class', 'Class', member_order='bysource', all_members=True) + # --- generate fodder ------------ |