summaryrefslogtreecommitdiff
path: root/sandbox/py-rest-doc/sphinx/builder.py
diff options
context:
space:
mode:
authorgbrandl <gbrandl@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2007-07-08 16:17:46 +0000
committergbrandl <gbrandl@929543f6-e4f2-0310-98a6-ba3bd3dd1d04>2007-07-08 16:17:46 +0000
commit6e5b7f2814a38af5d95a656f963d6426aa7e904d (patch)
tree17f20e3df99eefc1b6cdc581bd1457a31121c8f7 /sandbox/py-rest-doc/sphinx/builder.py
parent5d472cbf7c05367fac8f65c38df852a268cb5fe1 (diff)
downloaddocutils-6e5b7f2814a38af5d95a656f963d6426aa7e904d.tar.gz
Some fixes and module index improvements: list all synopses,
collapse packages. git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@5328 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
Diffstat (limited to 'sandbox/py-rest-doc/sphinx/builder.py')
-rw-r--r--sandbox/py-rest-doc/sphinx/builder.py34
1 files changed, 28 insertions, 6 deletions
diff --git a/sandbox/py-rest-doc/sphinx/builder.py b/sandbox/py-rest-doc/sphinx/builder.py
index 15eb4ab96..3ba94c8ce 100644
--- a/sandbox/py-rest-doc/sphinx/builder.py
+++ b/sandbox/py-rest-doc/sphinx/builder.py
@@ -381,14 +381,36 @@ class StandaloneHTMLBuilder(Builder):
# the global module index
# the sorted list of all modules, for the global module index
- modules = list(sorted(
- ((mn, (self.get_relative_uri('modindex.rst', fn) +
- '#module-' + mn, sy, pl))
- for (mn, (fn, sy, pl)) in self.env.modules.iteritems()),
- key=lambda x: x[0].lower()))
+ modules = sorted(((mn, (self.get_relative_uri('modindex.rst', fn) +
+ '#module-' + mn, sy, pl))
+ for (mn, (fn, sy, pl)) in self.env.modules.iteritems()),
+ key=lambda x: x[0].lower())
+ # sort out collapsable modules
+ modindexentries = []
+ pmn = ''
+ cg = 0 # collapse group
+ fl = '' # first letter
+ for mn, (fn, sy, pl) in modules:
+ if fl != mn[0].lower() and mn[0] != '_':
+ modindexentries.append(['', False, 0, False, mn[0].upper(), '', ''])
+ tn = mn.partition('.')[0]
+ if tn != mn:
+ # submodule
+ if pmn == tn:
+ # first submodule - make parent collapsable
+ modindexentries[-1][1] = True
+ elif not pmn.startswith(tn):
+ # submodule without parent in list, add dummy entry
+ cg += 1
+ modindexentries.append([tn, True, cg, False, '', '', ''])
+ else:
+ cg += 1
+ modindexentries.append([mn, False, cg, (tn != mn), fn, sy, pl])
+ pmn = mn
+ fl = mn[0].lower()
modindexcontext = dict(
- modindexentries = modules,
+ modindexentries = modindexentries,
current_page_name = 'modindex',
pathto = relpath_to(self, self.get_target_uri('modindex.rst')),
)