def test_modindex_common_prefix(app): text = (".. py:module:: docutils\n" ".. py:module:: sphinx\n" ".. py:module:: sphinx.config\n" ".. py:module:: sphinx.builders\n" ".. py:module:: sphinx.builders.html\n" ".. py:module:: sphinx_intl\n") restructuredtext.parse(app, text) index = PythonModuleIndex(app.env.get_domain('py')) assert index.generate() == ( [ ( 'b', [ IndexEntry('sphinx.builders', 1, 'index', 'module-sphinx.builders', '', '', ''), # NOQA IndexEntry('sphinx.builders.html', 2, 'index', 'module-sphinx.builders.html', '', '', '') ]), # NOQA ('c', [ IndexEntry('sphinx.config', 0, 'index', 'module-sphinx.config', '', '', '') ]), ('d', [ IndexEntry('docutils', 0, 'index', 'module-docutils', '', '', '') ]), ('s', [ IndexEntry('sphinx', 0, 'index', 'module-sphinx', '', '', ''), IndexEntry('sphinx_intl', 0, 'index', 'module-sphinx_intl', '', '', '') ]) ], True)
def test_module_index_submodule(app): text = ".. py:module:: sphinx.config\n" restructuredtext.parse(app, text) index = PythonModuleIndex(app.env.get_domain('py')) assert index.generate() == ( [('s', [IndexEntry('sphinx', 1, '', '', '', '', ''), IndexEntry('sphinx.config', 2, 'index', 'module-sphinx.config', '', '', '')])], False )
def test_module_index_not_collapsed(app): text = (".. py:module:: docutils\n" ".. py:module:: sphinx\n") restructuredtext.parse(app, text) index = PythonModuleIndex(app.env.get_domain('py')) assert index.generate() == ([ ('d', [IndexEntry('docutils', 0, 'index', 'module-docutils', '', '', '')]), ('s', [IndexEntry('sphinx', 0, 'index', 'module-sphinx', '', '', '')]) ], True)