Debian Codegraph @

debian/dh-sphinxdoc/install-js

raw
1 #!/usr/bin/python3
2
3 import shutil
4 import sys
5 from pathlib import Path
6
7 from sphinx.application import Sphinx
8 from sphinx.search import languages
9
10 if len(sys.argv) != 2:
11 sys.exit(f"Usage: {sys.argv[0]} <target-directory>")
12
13 here = Path(__file__).parent
14 static = here / "tmp" / "_static"
15 out = Path(sys.argv[1])
16
17 app = Sphinx(
18 srcdir=here,
19 confdir=here,
20 outdir=here / "tmp",
21 doctreedir=here / "tmp" / ".doctrees",
22 buildername="html",
23 )
24
25 for language in languages:
26 app.config.html_search_language = language
27
28 builder = app.builder
29 builder.init()
30 builder.prepare_writing(docnames=set())
31 builder.copy_static_files()
32
33 if language == "en":
34 shutil.copy(static / "language_data.js", out)
35 shutil.copy(static / "sidebar.js", out)
36 else:
37 shutil.copy(static / "language_data.js", out / f"language_data_{language}.js")
38
39 shutil.rmtree(here / "tmp")