MCPcopy
hub / github.com/pandas-dev/pandas / _get_page_title

Method _get_page_title

doc/make.py:160–185  ·  view source on GitHub ↗

Open the rst file `page` and extract its title.

(self, page)

Source from the content-addressed store, hash-verified

158 webbrowser.open(url, new=2)
159
160 def _get_page_title(self, page):
161 """
162 Open the rst file `page` and extract its title.
163 """
164 fname = os.path.join(SOURCE_PATH, f"{page}.rst")
165 doc = docutils.utils.new_document(
166 "<doc>",
167 docutils.frontend.get_default_settings(docutils.parsers.rst.Parser),
168 )
169 with open(fname, encoding="utf-8") as f:
170 data = f.read()
171
172 parser = docutils.parsers.rst.Parser()
173 # do not generate any warning when parsing the rst
174 with open(os.devnull, "a", encoding="utf-8") as f:
175 doc.reporter.stream = f
176 parser.parse(data, doc)
177
178 section = next(
179 node for node in doc.children if isinstance(node, docutils.nodes.section)
180 )
181 title = next(
182 node for node in section.children if isinstance(node, docutils.nodes.title)
183 )
184
185 return title.astext()
186
187 def _add_redirects(self) -> None:
188 """

Callers 1

_add_redirectsMethod · 0.95

Calls 3

parseMethod · 0.95
joinMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected