Debian Codegraph @

docs/scripts/update_kitchen_sink.py

raw
1 """Script run to update the kitchen sink from https://sphinx-themes.org."""
2
3 from pathlib import Path
4 from urllib.request import urlopen
5
6
7 EXTRA_MESSAGE = """\
8 .. note::
9
10 The Kitchen Sink was generated from the
11 `Sphinx Themes website <https://sphinx-themes.org/>`_, a community-supported showcase
12 of themes for `Sphinx <https://www.sphinx-doc.org/>`_.
13 Check it out to see other great themes.
14
15 .. button-link:: https://sphinx-themes.org
16 :color: primary
17
18 Go to Sphinx Themes
19 """
20
21 kitchen_sink_files = [
22 "admonitions.rst",
23 "api.rst",
24 "blocks.rst",
25 "generic.rst",
26 "images.rst",
27 "index.rst",
28 "lists.rst",
29 "really-long.rst",
30 "structure.rst",
31 "tables.rst",
32 "typography.rst",
33 ]
34 path_sink = Path(__file__).resolve().parents[1] / "examples" / "kitchen-sink"
35 assert path_sink.exists(), path_sink
36 for ifile in kitchen_sink_files:
37 print(f"Reading {ifile}...")
38 url = f"https://github.com/sphinx-themes/sphinx-themes.org/raw/master/sample-docs/kitchen-sink/{ifile}"
39 text = urlopen(url).read().decode()
40 # The sphinx-themes docs expect Furo to be installed, so we overwrite w/ PST
41 text = text.replace("src/furo", "src/pydata_sphinx_theme")
42 text = text.replace(":any:`sphinx.ext.autodoc`", "``sphinx.ext.autodoc``")
43 # Add introductory message directing people to Sphinx Themes
44 if "index" in ifile:
45 text = text.replace("============", "============\n\n" + EXTRA_MESSAGE)
46 (path_sink / f"{ifile}").write_text(text)
47
48 print(f"Finished updating {len(kitchen_sink_files)} files...")