diff options
Diffstat (limited to 'sphinx/environment/adapters/indexentries.py')
| -rw-r--r-- | sphinx/environment/adapters/indexentries.py | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/sphinx/environment/adapters/indexentries.py b/sphinx/environment/adapters/indexentries.py index b3985432a..1fedbcce4 100644 --- a/sphinx/environment/adapters/indexentries.py +++ b/sphinx/environment/adapters/indexentries.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- """ sphinx.environment.adapters.indexentries ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -13,8 +12,6 @@ import re import unicodedata from itertools import groupby -from six import text_type, iteritems - from sphinx.locale import _, __ from sphinx.util import split_into, logging @@ -27,25 +24,25 @@ if False: logger = logging.getLogger(__name__) -class IndexEntries(object): +class IndexEntries: def __init__(self, env): # type: (BuildEnvironment) -> None self.env = env def create_index(self, builder, group_entries=True, _fixre=re.compile(r'(.*) ([(][^()]*[)])')): - # type: (Builder, bool, Pattern) -> List[Tuple[unicode, List[Tuple[unicode, Any]]]] # NOQA + # type: (Builder, bool, Pattern) -> List[Tuple[str, List[Tuple[str, Any]]]] """Create the real index from the collected index entries.""" from sphinx.environment import NoUri - new = {} # type: Dict[unicode, List] + new = {} # type: Dict[str, List] def add_entry(word, subword, main, link=True, dic=new, key=None): - # type: (unicode, unicode, unicode, bool, Dict, unicode) -> None + # type: (str, str, str, bool, Dict, str) -> None # Force the word to be unicode if it's a ASCII bytestring. # This will solve problems with unicode normalization later. # For instance the RFC role will add bytestrings at the moment - word = text_type(word) + word = str(word) entry = dic.get(word) if not entry: dic[word] = entry = [[], {}, key] @@ -60,7 +57,7 @@ class IndexEntries(object): # maintain links in sorted/deterministic order bisect.insort(entry[0], (main, uri)) - for fn, entries in iteritems(self.env.indexentries): + for fn, entries in self.env.indexentries.items(): # new entry types must be listed in directives/other.py! for type, value, tid, main, index_key in entries: try: @@ -96,13 +93,13 @@ class IndexEntries(object): # sort the index entries; put all symbols at the front, even those # following the letters in ASCII, this is where the chr(127) comes from def keyfunc(entry): - # type: (Tuple[unicode, List]) -> Tuple[unicode, unicode] + # type: (Tuple[str, List]) -> Tuple[str, str] key, (void, void, category_key) = entry if category_key: # using specified category key to sort key = category_key lckey = unicodedata.normalize('NFD', key.lower()) - if lckey.startswith(u'\N{RIGHT-TO-LEFT MARK}'): + if lckey.startswith('\N{RIGHT-TO-LEFT MARK}'): lckey = lckey[1:] if lckey[0:1].isalpha() or lckey.startswith('_'): lckey = chr(127) + lckey @@ -119,8 +116,8 @@ class IndexEntries(object): # func() # (in module foo) # (in module bar) - oldkey = '' # type: unicode - oldsubitems = None # type: Dict[unicode, List] + oldkey = '' + oldsubitems = None # type: Dict[str, List] i = 0 while i < len(newlist): key, (targets, subitems, _key) = newlist[i] @@ -143,13 +140,13 @@ class IndexEntries(object): # group the entries by letter def keyfunc2(item): - # type: (Tuple[unicode, List]) -> unicode + # type: (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 iteritems(v[1])) + v[1] = sorted((si, se) for (si, (se, void, void)) in v[1].items()) if v[2] is None: # now calculate the key - if k.startswith(u'\N{RIGHT-TO-LEFT MARK}'): + if k.startswith('\N{RIGHT-TO-LEFT MARK}'): k = k[1:] letter = unicodedata.normalize('NFD', k[0])[0].upper() if letter.isalpha() or letter == '_': |
