mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #5705 from tk0miya/fix_typehints_for_settings
Fix typehints for settings and memo objects
This commit is contained in:
@@ -56,15 +56,16 @@ class ShowUrlsTransform(SphinxTransform):
|
||||
# type: (Any) -> None
|
||||
try:
|
||||
# replace id_prefix temporarily
|
||||
id_prefix = self.document.settings.id_prefix
|
||||
self.document.settings.id_prefix = 'show_urls'
|
||||
settings = self.document.settings # type: Any
|
||||
id_prefix = settings.id_prefix
|
||||
settings.id_prefix = 'show_urls'
|
||||
|
||||
self.expand_show_urls()
|
||||
if self.expanded:
|
||||
self.renumber_footnotes()
|
||||
finally:
|
||||
# restore id_prefix
|
||||
self.document.settings.id_prefix = id_prefix
|
||||
settings.id_prefix = id_prefix
|
||||
|
||||
def expand_show_urls(self):
|
||||
# type: () -> None
|
||||
|
||||
@@ -336,14 +336,15 @@ class Only(SphinxDirective):
|
||||
|
||||
# Same as util.nested_parse_with_titles but try to handle nested
|
||||
# sections which should be raised higher up the doctree.
|
||||
surrounding_title_styles = self.state.memo.title_styles
|
||||
surrounding_section_level = self.state.memo.section_level
|
||||
self.state.memo.title_styles = []
|
||||
self.state.memo.section_level = 0
|
||||
memo = self.state.memo # type: Any
|
||||
surrounding_title_styles = memo.title_styles
|
||||
surrounding_section_level = memo.section_level
|
||||
memo.title_styles = []
|
||||
memo.section_level = 0
|
||||
try:
|
||||
self.state.nested_parse(self.content, self.content_offset,
|
||||
node, match_titles=True)
|
||||
title_styles = self.state.memo.title_styles
|
||||
title_styles = memo.title_styles
|
||||
if (not surrounding_title_styles or
|
||||
not title_styles or
|
||||
title_styles[0] not in surrounding_title_styles or
|
||||
@@ -371,8 +372,8 @@ class Only(SphinxDirective):
|
||||
parent.append(node)
|
||||
return []
|
||||
finally:
|
||||
self.state.memo.title_styles = surrounding_title_styles
|
||||
self.state.memo.section_level = surrounding_section_level
|
||||
memo.title_styles = surrounding_title_styles
|
||||
memo.section_level = surrounding_section_level
|
||||
|
||||
|
||||
class Include(BaseInclude, SphinxDirective):
|
||||
|
||||
Reference in New Issue
Block a user