Debian Codegraph @

tasks/doc/_sphinx.py

raw symbols SCIP
1 # -*- coding: ascii -*-
2 #
3 # Copyright 2018 - 2025
4 # Andr\xe9 Malo or his licensors, as applicable
5 #
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
9 #
10 # http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 """
18 Doc Tasks
19 ~~~~~~~~~
20
21 """
22
23 import os as _os
24
25
26 def run(ctx, build, source, target):
27 """
28 Run sphinx
29
30 Parameters:
31 build (str):
32 Build directory
33
34 source (str):
35 Source directory
36
37 target (str):
38 Target directory
39 """
40 want_apidoc = ctx.doc.sphinx.want_apidoc
41 if want_apidoc:
42 apidoc = ctx.which("sphinx-apidoc")
43 sphinx = ctx.which("sphinx-build")
44
45 with ctx.shell.root_dir():
46 if want_apidoc:
47 cmd = (
48 [apidoc]
49 + ctx.s("-f --private -stxt -e -o")
50 + ["%s/apidoc" % (source,), ctx.package]
51 )
52 ctx.run(
53 ctx.c(cmd),
54 env=dict(
55 _os.environ,
56 SPHINX_APIDOC_OPTIONS=",".join(
57 ["members", "undoc-members", "special-members"]
58 ),
59 ),
60 echo=True,
61 )
62
63 cmd = (
64 [sphinx]
65 + ctx.s("-a -d")
66 + [_os.path.join(build, "doctrees")]
67 + ctx.s("-b html")
68 + [source, target]
69 )
70 ctx.run(ctx.c(cmd), echo=True)