MCPcopy Index your code
hub / github.com/python/cpython / run

Method run

Doc/tools/extensions/misc_news.py:45–65  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

43 option_spec = {}
44
45 def run(self) -> list[Node]:
46 # Get content of NEWS file
47 source, _ = self.get_source_info()
48 news_file = Path(source).resolve().parent / self.arguments[0]
49 self.env.note_dependency(news_file)
50 try:
51 news_text = news_file.read_text(encoding="utf-8")
52 except (OSError, UnicodeError):
53 text = sphinx_gettext("The NEWS file is not available.")
54 return [nodes.strong(text, text)]
55
56 # remove first 3 lines as they are the main heading
57 news_text = news_text.removeprefix(BLURB_HEADER)
58
59 news_text = bpo_issue_re.sub(r":issue:`\1`", news_text)
60 # Fallback handling for GitHub issues
61 news_text = gh_issue_re.sub(r":gh:`\1`", news_text)
62 news_text = whatsnew_re.sub(r"\1", news_text)
63
64 self.state_machine.insert_input(news_text.splitlines(), str(news_file))
65 return []
66
67
68def setup(app: Sphinx) -> ExtensionMetadata:

Callers 2

get_diff_filesFunction · 0.45
get_diff_linesFunction · 0.45

Calls 7

PathClass · 0.90
strFunction · 0.85
resolveMethod · 0.45
read_textMethod · 0.45
removeprefixMethod · 0.45
subMethod · 0.45
splitlinesMethod · 0.45

Tested by

no test coverage detected