Debian Codegraph @

tasks/doc/tasks.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 Documentation Tasks
19 ~~~~~~~~~~~~~~~~~~~
20
21 """
22
23 import os as _os
24
25 import invoke as _invoke
26
27 from .. import _features
28 from .._inv import tasks as _tasks
29 from . import _sphinx
30
31 NAMESPACE = "doc"
32
33
34 @_tasks.optional(None, _features.sphinx)
35 @_invoke.task()
36 def userdoc(ctx):
37 """Create userdocs"""
38 if _tasks.exists("compile.compile"):
39 _tasks.execute(ctx, "compile.compile")
40
41 _sphinx.run(
42 ctx, ctx.doc.sphinx.build, ctx.doc.sphinx.source, ctx.doc.userdoc
43 )
44
45
46 @_tasks.optional(None, _features.sphinx)
47 @_invoke.task(userdoc, default=True)
48 def doc(ctx): # pylint: disable = unused-argument
49 """Create docs"""
50
51
52 @_tasks.optional(None, _features.sphinx)
53 @_invoke.task()
54 def website(ctx):
55 """Create website"""
56 ctx.shell.rm_rf(ctx.doc.website.source)
57 ctx.shell.cp_r(
58 ctx.doc.sphinx.source, _os.path.join(ctx.doc.website.source, "src")
59 )
60 ctx.shell.rm_rf(ctx.doc.website.target)
61 ctx.shell.mkdir_p(ctx.doc.website.target)
62
63 dlfile = _os.path.join(
64 ctx.doc.website.source, "src", "website_download.txt"
65 )
66 with open(dlfile, "rb") as fp:
67 download = fp.read().decode("latin-1")
68
69 ixfile = _os.path.join(ctx.doc.website.source, "src", "index.txt")
70 with open(ixfile, "rb") as fp:
71 index = fp.read().decode("latin-1").splitlines(True)
72
73 with open(ixfile, "wb") as fp:
74 for line in index:
75 if line.startswith(".. placeholder: Download"):
76 line = download
77 fp.write(line.encode("latin-1"))
78
79 _sphinx.run(
80 ctx,
81 ctx.shell.native(_os.path.join(ctx.doc.website.source, "build")),
82 ctx.shell.native(_os.path.join(ctx.doc.website.source, "src")),
83 ctx.shell.native(ctx.doc.website.target),
84 )
85 ctx.shell.rm(_os.path.join(ctx.doc.website.target, ".buildinfo"))