summaryrefslogtreecommitdiff
path: root/sphinx/environment/adapters/indexentries.py
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2019-07-01 00:16:11 +0900
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2019-07-06 14:12:12 +0900
commit31207aa813cd0a74ce2be504c76c1e7aca368cf8 (patch)
treedc32fc8df02f9887fb7ca3874a24cb867c882e1f /sphinx/environment/adapters/indexentries.py
parent8b4e54f90413d26c60476ce8acdd908fbfc05a82 (diff)
downloadsphinx-git-31207aa813cd0a74ce2be504c76c1e7aca368cf8.tar.gz
Fix #736: Invalid sort in pair index
Diffstat (limited to 'sphinx/environment/adapters/indexentries.py')
-rw-r--r--sphinx/environment/adapters/indexentries.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/sphinx/environment/adapters/indexentries.py b/sphinx/environment/adapters/indexentries.py
index 430c3dce2..68198040d 100644
--- a/sphinx/environment/adapters/indexentries.py
+++ b/sphinx/environment/adapters/indexentries.py
@@ -133,11 +133,21 @@ class IndexEntries:
oldsubitems = subitems
i += 1
+ # sort the sub-index entries
+ def keyfunc2(entry: Tuple[str, List]) -> str:
+ key = unicodedata.normalize('NFD', entry[0].lower())
+ if key.startswith('\N{RIGHT-TO-LEFT MARK}'):
+ key = key[1:]
+ if key[0:1].isalpha() or key.startswith('_'):
+ key = chr(127) + key
+ return key
+
# group the entries by letter
- def keyfunc2(item: Tuple[str, List]) -> str:
+ def keyfunc3(item: Tuple[str, List]) -> str:
# hack: mutating the subitems dicts to a list in the keyfunc
k, v = item
- v[1] = sorted((si, se) for (si, (se, void, void)) in v[1].items())
+ v[1] = sorted(((si, se) for (si, (se, void, void)) in v[1].items()),
+ key=keyfunc2)
if v[2] is None:
# now calculate the key
if k.startswith('\N{RIGHT-TO-LEFT MARK}'):
@@ -151,4 +161,4 @@ class IndexEntries:
else:
return v[2]
return [(key_, list(group))
- for (key_, group) in groupby(newlist, keyfunc2)]
+ for (key_, group) in groupby(newlist, keyfunc3)]