mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Add a shorthand notation for single index entries.
This commit is contained in:
parent
a6cadae78f
commit
d5469b432d
@ -38,12 +38,16 @@ def index_directive(name, arguments, options, content, lineno,
|
|||||||
indexnode = addnodes.index()
|
indexnode = addnodes.index()
|
||||||
indexnode['entries'] = arguments
|
indexnode['entries'] = arguments
|
||||||
for entry in arguments:
|
for entry in arguments:
|
||||||
try:
|
entry = entry.strip()
|
||||||
type, string = entry.split(':', 1)
|
for type in entrytypes:
|
||||||
env.note_index_entry(type.strip(), string.strip(),
|
if entry.startswith(type+':'):
|
||||||
targetid, string.strip())
|
value = entry[len(type)+1:].strip()
|
||||||
except ValueError:
|
env.note_index_entry(type, value, targetid, value)
|
||||||
continue
|
break
|
||||||
|
# shorthand notation for single entries
|
||||||
|
else:
|
||||||
|
for value in entry.split(','):
|
||||||
|
env.note_index_entry('single', value.strip(), targetid, value.strip())
|
||||||
return [indexnode, targetnode]
|
return [indexnode, targetnode]
|
||||||
|
|
||||||
index_directive.arguments = (1, 0, 1)
|
index_directive.arguments = (1, 0, 1)
|
||||||
|
Loading…
Reference in New Issue
Block a user