Skip to content

Commit 04f03aa

Browse files
committed
Merge branch 'master' into snowball/all
# Conflicts: # CHANGES.rst # sphinx/search/_stopwords/da.py # sphinx/search/_stopwords/da.txt # sphinx/search/_stopwords/de.py # sphinx/search/_stopwords/de.txt # sphinx/search/_stopwords/en.py # sphinx/search/_stopwords/es.py # sphinx/search/_stopwords/es.txt # sphinx/search/_stopwords/fi.py # sphinx/search/_stopwords/fi.txt # sphinx/search/_stopwords/fr.py # sphinx/search/_stopwords/fr.txt # sphinx/search/_stopwords/hu.py # sphinx/search/_stopwords/hu.txt # sphinx/search/_stopwords/it.py # sphinx/search/_stopwords/it.txt # sphinx/search/_stopwords/nl.py # sphinx/search/_stopwords/nl.txt # sphinx/search/_stopwords/no.py # sphinx/search/_stopwords/no.txt # sphinx/search/_stopwords/pt.py # sphinx/search/_stopwords/pt.txt # sphinx/search/_stopwords/ru.py # sphinx/search/_stopwords/ru.txt # sphinx/search/_stopwords/sv.py # sphinx/search/_stopwords/sv.txt # sphinx/search/en.py # sphinx/search/zh.py
2 parents db62729 + c30effe commit 04f03aa

File tree

20 files changed

+61
-23
lines changed

20 files changed

+61
-23
lines changed

CHANGES.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Features added
1919
* #13439: linkcheck: Permit warning on every redirect with
2020
``linkcheck_allowed_redirects = {}``.
2121
Patch by Adam Turner.
22+
* #13497: Support C domain objects in the table of contents.
2223
* #13535: html search: Update to the latest version of Snowball (v3.01.)
2324
Patch by Adam Turner.
2425

sphinx/domains/c/__init__.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939

4040
from docutils.nodes import Element, Node, TextElement, system_message
4141

42-
from sphinx.addnodes import pending_xref
42+
from sphinx.addnodes import desc_signature, pending_xref
4343
from sphinx.application import Sphinx
4444
from sphinx.builders import Builder
4545
from sphinx.domains.c._symbol import LookupKey
@@ -309,6 +309,32 @@ def after_content(self) -> None:
309309
self.env.current_document.c_parent_symbol = self.oldParentSymbol
310310
self.env.ref_context['c:parent_key'] = self.oldParentKey
311311

312+
def _object_hierarchy_parts(self, sig_node: desc_signature) -> tuple[str, ...]:
313+
last_symbol: Symbol = self.env.current_document.c_last_symbol
314+
return tuple(map(str, last_symbol.get_full_nested_name().names))
315+
316+
def _toc_entry_name(self, sig_node: desc_signature) -> str:
317+
if not sig_node.get('_toc_parts'):
318+
return ''
319+
320+
config = self.config
321+
objtype = sig_node.parent.get('objtype')
322+
if config.add_function_parentheses and (
323+
objtype in {'function', 'method'}
324+
or (objtype == 'macro' and '(' in sig_node.rawsource)
325+
):
326+
parens = '()'
327+
else:
328+
parens = ''
329+
*parents, name = sig_node['_toc_parts']
330+
if config.toc_object_entries_show_parents == 'domain':
331+
return '::'.join((name + parens,))
332+
if config.toc_object_entries_show_parents == 'hide':
333+
return name + parens
334+
if config.toc_object_entries_show_parents == 'all':
335+
return '::'.join([*parents, name + parens])
336+
return ''
337+
312338

313339
class CMemberObject(CObject):
314340
object_type = 'member'

sphinx/search/__init__.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,8 @@ class SearchLanguage:
9191
_word_re = re.compile(r'\w+')
9292

9393
def __init__(self, options: dict[str, str]) -> None:
94-
self.options = options
95-
self.init(options)
96-
97-
def init(self, options: dict[str, str]) -> None:
9894
"""Initialize the class with the options the user has given."""
95+
self.options = options
9996

10097
def split(self, input: str) -> list[str]:
10198
"""This method splits a sentence into words. Default splitter splits input

sphinx/search/da.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ class SearchDanish(SearchLanguage):
1414
js_stemmer_rawcode = 'danish-stemmer.js'
1515
stopwords = DANISH_STOPWORDS
1616

17-
def init(self, options: dict[str, str]) -> None:
17+
def __init__(self, options: dict[str, str]) -> None:
18+
super().__init__(options)
1819
self.stemmer = snowballstemmer.stemmer('danish')
1920

2021
def stem(self, word: str) -> str:

sphinx/search/de.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ class SearchGerman(SearchLanguage):
1414
js_stemmer_rawcode = 'german-stemmer.js'
1515
stopwords = GERMAN_STOPWORDS
1616

17-
def init(self, options: dict[str, str]) -> None:
17+
def __init__(self, options: dict[str, str]) -> None:
18+
super().__init__(options)
1819
self.stemmer = snowballstemmer.stemmer('german')
1920

2021
def stem(self, word: str) -> str:

sphinx/search/en.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ class SearchEnglish(SearchLanguage):
1414
js_stemmer_rawcode = 'english-stemmer.js'
1515
stopwords = ENGLISH_STOPWORDS
1616

17-
def init(self, options: dict[str, str]) -> None:
17+
def __init__(self, options: dict[str, str]) -> None:
18+
super().__init__(options)
1819
self.stemmer = snowballstemmer.stemmer('english')
1920

2021
def stem(self, word: str) -> str:

sphinx/search/es.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ class SearchSpanish(SearchLanguage):
1414
js_stemmer_rawcode = 'spanish-stemmer.js'
1515
stopwords = SPANISH_STOPWORDS
1616

17-
def init(self, options: dict[str, str]) -> None:
17+
def __init__(self, options: dict[str, str]) -> None:
18+
super().__init__(options)
1819
self.stemmer = snowballstemmer.stemmer('spanish')
1920

2021
def stem(self, word: str) -> str:

sphinx/search/fi.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ class SearchFinnish(SearchLanguage):
1414
js_stemmer_rawcode = 'finnish-stemmer.js'
1515
stopwords = FINNISH_STOPWORDS
1616

17-
def init(self, options: dict[str, str]) -> None:
17+
def __init__(self, options: dict[str, str]) -> None:
18+
super().__init__(options)
1819
self.stemmer = snowballstemmer.stemmer('finnish')
1920

2021
def stem(self, word: str) -> str:

sphinx/search/fr.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ class SearchFrench(SearchLanguage):
1414
js_stemmer_rawcode = 'french-stemmer.js'
1515
stopwords = FRENCH_STOPWORDS
1616

17-
def init(self, options: dict[str, str]) -> None:
17+
def __init__(self, options: dict[str, str]) -> None:
18+
super().__init__(options)
1819
self.stemmer = snowballstemmer.stemmer('french')
1920

2021
def stem(self, word: str) -> str:

sphinx/search/hu.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ class SearchHungarian(SearchLanguage):
1414
js_stemmer_rawcode = 'hungarian-stemmer.js'
1515
stopwords = HUNGARIAN_STOPWORDS
1616

17-
def init(self, options: dict[str, str]) -> None:
17+
def __init__(self, options: dict[str, str]) -> None:
18+
super().__init__(options)
1819
self.stemmer = snowballstemmer.stemmer('hungarian')
1920

2021
def stem(self, word: str) -> str:

sphinx/search/it.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ class SearchItalian(SearchLanguage):
1414
js_stemmer_rawcode = 'italian-stemmer.js'
1515
stopwords = ITALIAN_STOPWORDS
1616

17-
def init(self, options: dict[str, str]) -> None:
17+
def __init__(self, options: dict[str, str]) -> None:
18+
super().__init__(options)
1819
self.stemmer = snowballstemmer.stemmer('italian')
1920

2021
def stem(self, word: str) -> str:

sphinx/search/ja.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,8 @@ class SearchJapanese(SearchLanguage):
523523
lang = 'ja'
524524
language_name = 'Japanese'
525525

526-
def init(self, options: dict[str, str]) -> None:
526+
def __init__(self, options: dict[str, str]) -> None:
527+
super().__init__(options)
527528
dotted_path = options.get('type')
528529
if dotted_path is None:
529530
self.splitter = DefaultSplitter(options)

sphinx/search/nl.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ class SearchDutch(SearchLanguage):
1414
js_stemmer_rawcode = 'dutch-stemmer.js'
1515
stopwords = DUTCH_STOPWORDS
1616

17-
def init(self, options: dict[str, str]) -> None:
17+
def __init__(self, options: dict[str, str]) -> None:
18+
super().__init__(options)
1819
self.stemmer = snowballstemmer.stemmer('dutch')
1920

2021
def stem(self, word: str) -> str:

sphinx/search/no.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ class SearchNorwegian(SearchLanguage):
1414
js_stemmer_rawcode = 'norwegian-stemmer.js'
1515
stopwords = NORWEGIAN_STOPWORDS
1616

17-
def init(self, options: dict[str, str]) -> None:
17+
def __init__(self, options: dict[str, str]) -> None:
18+
super().__init__(options)
1819
self.stemmer = snowballstemmer.stemmer('norwegian')
1920

2021
def stem(self, word: str) -> str:

sphinx/search/pt.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ class SearchPortuguese(SearchLanguage):
1414
js_stemmer_rawcode = 'portuguese-stemmer.js'
1515
stopwords = PORTUGUESE_STOPWORDS
1616

17-
def init(self, options: dict[str, str]) -> None:
17+
def __init__(self, options: dict[str, str]) -> None:
18+
super().__init__(options)
1819
self.stemmer = snowballstemmer.stemmer('portuguese')
1920

2021
def stem(self, word: str) -> str:

sphinx/search/ro.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ class SearchRomanian(SearchLanguage):
1313
js_stemmer_rawcode = 'romanian-stemmer.js'
1414
stopwords = frozenset()
1515

16-
def init(self, options: dict[str, str]) -> None:
16+
def __init__(self, options: dict[str, str]) -> None:
17+
super().__init__(options)
1718
self.stemmer = snowballstemmer.stemmer('romanian')
1819

1920
def stem(self, word: str) -> str:

sphinx/search/ru.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ class SearchRussian(SearchLanguage):
1414
js_stemmer_rawcode = 'russian-stemmer.js'
1515
stopwords = RUSSIAN_STOPWORDS
1616

17-
def init(self, options: dict[str, str]) -> None:
17+
def __init__(self, options: dict[str, str]) -> None:
18+
super().__init__(options)
1819
self.stemmer = snowballstemmer.stemmer('russian')
1920

2021
def stem(self, word: str) -> str:

sphinx/search/sv.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ class SearchSwedish(SearchLanguage):
1414
js_stemmer_rawcode = 'swedish-stemmer.js'
1515
stopwords = SWEDISH_STOPWORDS
1616

17-
def init(self, options: dict[str, str]) -> None:
17+
def __init__(self, options: dict[str, str]) -> None:
18+
super().__init__(options)
1819
self.stemmer = snowballstemmer.stemmer('swedish')
1920

2021
def stem(self, word: str) -> str:

sphinx/search/tr.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ class SearchTurkish(SearchLanguage):
1313
js_stemmer_rawcode = 'turkish-stemmer.js'
1414
stopwords = frozenset()
1515

16-
def init(self, options: dict[str, str]) -> None:
16+
def __init__(self, options: dict[str, str]) -> None:
17+
super().__init__(options)
1718
self.stemmer = snowballstemmer.stemmer('turkish')
1819

1920
def stem(self, word: str) -> str:

sphinx/search/zh.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ class SearchChinese(SearchLanguage):
4646
def __init__(self, options: dict[str, str]) -> None:
4747
super().__init__(options)
4848
self.latin_terms: set[str] = set()
49-
50-
def init(self, options: dict[str, str]) -> None:
5149
dict_path = options.get('dict', JIEBA_DEFAULT_DICT)
5250
if dict_path and Path(dict_path).is_file():
5351
jieba_load_userdict(str(dict_path))

0 commit comments

Comments
 (0)