[Python-checkins] r65636 - in doctools/trunk/sphinx: directives/desc.py directives/other.py environment.py roles.py
georg.brandl
python-checkins at python.org
Mon Aug 11 10:40:13 CEST 2008
Author: georg.brandl
Date: Mon Aug 11 10:40:12 2008
New Revision: 65636
Log:
Simplify index entry handling.
Modified:
doctools/trunk/sphinx/directives/desc.py
doctools/trunk/sphinx/directives/other.py
doctools/trunk/sphinx/environment.py
doctools/trunk/sphinx/roles.py
Modified: doctools/trunk/sphinx/directives/desc.py
==============================================================================
--- doctools/trunk/sphinx/directives/desc.py (original)
+++ doctools/trunk/sphinx/directives/desc.py Mon Aug 11 10:40:12 2008
@@ -399,8 +399,6 @@
targetname = 'cmdoption-' + optname
signode['ids'].append(targetname)
state.document.note_explicit_target(signode)
- env.note_index_entry('pair', _('command line option; %s') % sig,
- targetname, targetname)
inode['entries'].append(('pair', _('command line option; %s') % sig,
targetname, targetname))
env.note_reftarget('option', optname, targetname)
@@ -430,8 +428,6 @@
if colon != -1:
indextype = indexentry[:colon].strip()
indexentry = indexentry[colon+1:].strip()
- env.note_index_entry(indextype, indexentry,
- targetname, targetname)
inode['entries'].append((indextype, indexentry,
targetname, targetname))
env.note_reftarget(rolename, fullname, targetname)
@@ -456,7 +452,6 @@
names.append(name)
indextext = desc_index_text(desctype, module, name)
- env.note_index_entry('single', indextext, fullname, fullname)
inode['entries'].append(('single', indextext, fullname, fullname))
subnode = addnodes.desc_content()
@@ -542,7 +537,6 @@
if colon != -1:
indextype = indexentry[:colon].strip()
indexentry = indexentry[colon+1:].strip()
- env.note_index_entry(indextype, indexentry, targetname, targetname)
inode = addnodes.index(entries=[(indextype, indexentry, targetname, targetname)])
ret.insert(0, inode)
env.note_reftarget(rolename, fullname, targetname)
Modified: doctools/trunk/sphinx/directives/other.py
==============================================================================
--- doctools/trunk/sphinx/directives/other.py (original)
+++ doctools/trunk/sphinx/directives/other.py Mon Aug 11 10:40:12 2008
@@ -105,7 +105,6 @@
# the synopsis isn't printed; in fact, it is only used in the modindex currently
if not noindex:
indextext = _('%s (module)') % modname
- env.note_index_entry('single', indextext, 'module-' + modname, modname)
inode = addnodes.index(entries=[('single', indextext,
'module-' + modname, modname)])
ret.insert(0, inode)
@@ -182,21 +181,17 @@
if entry.startswith(type+':'):
value = entry[len(type)+1:].strip()
value = pairindextypes[type] + '; ' + value
- env.note_index_entry(type, value, targetid, value)
ne.append((type, value, targetid, value))
break
else:
for type in indextypes:
if entry.startswith(type+':'):
value = entry[len(type)+1:].strip()
- env.note_index_entry(type, value, targetid, value)
ne.append((type, value, targetid, value))
break
# shorthand notation for single entries
else:
for value in entry.split(','):
- env.note_index_entry('single', value.strip(),
- targetid, value.strip())
ne.append(('single', value.strip(), targetid, value.strip()))
return [indexnode, targetnode]
@@ -329,7 +324,6 @@
# add an index entry too
indexnode = addnodes.index()
indexnode['entries'] = [('single', termtext, new_id, termtext)]
- env.note_index_entry('single', termtext, new_id, termtext)
li.insert(0, indexnode)
return [node]
Modified: doctools/trunk/sphinx/environment.py
==============================================================================
--- doctools/trunk/sphinx/environment.py (original)
+++ doctools/trunk/sphinx/environment.py Mon Aug 11 10:40:12 2008
@@ -496,6 +496,7 @@
self.process_metadata(docname, doctree)
self.create_title_from(docname, doctree)
self.note_labels_from(docname, doctree)
+ self.note_indexentries_from(docname, doctree)
self.build_toc_from(docname, doctree)
# store time of reading, used to find outdated files
@@ -665,6 +666,11 @@
sectname = node[0].astext() # node[0] == title node
self.labels[name] = docname, labelid, sectname
+ def note_indexentries_from(self, docname, document):
+ entries = self.indexentries[docname] = []
+ for node in document.traverse(addnodes.index):
+ entries.extend(node['entries'])
+
def note_toctree(self, docname, toctreenode):
"""Note a TOC tree directive in a document and gather information about
file relations from it."""
@@ -755,10 +761,6 @@
def note_reftarget(self, type, name, labelid):
self.reftargets[type, name] = (self.docname, labelid)
- def note_index_entry(self, type, string, targetid, aliasname):
- self.indexentries.setdefault(self.docname, []).append(
- (type, string, targetid, aliasname))
-
def note_versionchange(self, type, version, node, lineno):
self.versionchanges.setdefault(version, []).append(
(type, self.docname, lineno, self.currmodule, self.currdesc, node.astext()))
Modified: doctools/trunk/sphinx/roles.py
==============================================================================
--- doctools/trunk/sphinx/roles.py (original)
+++ doctools/trunk/sphinx/roles.py Mon Aug 11 10:40:12 2008
@@ -48,9 +48,6 @@
targetnode = nodes.target('', '', ids=[targetid])
inliner.document.note_explicit_target(targetnode)
if typ == 'envvar':
- env.note_index_entry('single', text, targetid, text)
- env.note_index_entry('single', _('environment variable; %s') % text,
- targetid, text)
indexnode['entries'] = [('single', text, targetid, text),
('single', _('environment variable; %s') % text,
targetid, text)]
@@ -58,8 +55,6 @@
options, content)[0]
return [indexnode, targetnode] + xref_nodes, []
elif typ == 'pep':
- env.note_index_entry('single', _('Python Enhancement Proposals!PEP %s') % text,
- targetid, 'PEP %s' % text)
indexnode['entries'] = [('single',
_('Python Enhancement Proposals!PEP %s') % text,
targetid, 'PEP %s' % text)]
@@ -75,8 +70,6 @@
rn += sn
return [indexnode, targetnode, rn], []
elif typ == 'rfc':
- env.note_index_entry('single', 'RFC; RFC %s' % text,
- targetid, 'RFC %s' % text)
indexnode['entries'] = [('single', 'RFC; RFC %s' % text,
targetid, 'RFC %s' % text)]
try:
More information about the Python-checkins
mailing list