-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathconf.py
More file actions
140 lines (116 loc) · 4.75 KB
/
Copy pathconf.py
File metadata and controls
140 lines (116 loc) · 4.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# *******************************************************************************
# Copyright (c) 2024 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************
# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
import os
import shutil
from itertools import chain
from pathlib import Path
from docutils import nodes
from docutils.parsers.rst import Directive
# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
project = "Lifecycle and Health Management"
project_url = "https://eclipse-score.github.io/lifecycle/"
project_prefix = "LIFE_"
author = "S-CORE"
version = "0.1"
# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
extensions = [
"sphinx_design",
"sphinx_needs",
"sphinxcontrib.plantuml",
"score_plantuml",
"score_metamodel",
"score_draw_uml_funcs",
"score_source_code_linker",
"score_layout",
"myst_parser",
]
include_patterns = [
"index.rst",
"docs/**",
"examples/docs/**",
"score/launch_manager/docs/**",
"score/launch_manager/src/lifecycle_client/docs/**",
"score/health_monitor/docs/**",
]
exclude_patterns = [
# The following entries are not required when building the documentation via 'bazel
# build //docs:docs', as that command runs in a sandboxed environment. However, when
# building the documentation via 'bazel run //docs:incremental' or esbonio, these
# entries are required to prevent the build from failing.
"bazel-*",
".venv_docs",
]
templates_path = ["templates"]
# Enable numref
numfig = True
class DisplayTestLogs(Directive):
"""Find and display the raw content of all test.log files."""
def run(self):
env = self.state.document.settings.env
ws_root = Path(env.app.srcdir)
result_nodes = []
for log_file in chain(
(ws_root / "bazel-testlogs").rglob("test.log"),
(ws_root / "tests-report").rglob("test.log"),
):
rel_path = log_file.relative_to(ws_root)
title = nodes.rubric(text=str(rel_path))
result_nodes.append(title)
try:
content = log_file.read_text(encoding="utf-8")
except Exception as e:
content = f"Error reading file: {e}"
code = nodes.literal_block(content, content)
code["language"] = "text"
code["source"] = str(rel_path)
result_nodes.append(code)
if not result_nodes:
para = nodes.paragraph(
text="No test.log files found in bazel-testlogs or tests-report."
)
result_nodes.append(para)
return result_nodes
def setup(app):
app.add_directive("display-test-logs", DisplayTestLogs)
# When Sphinx runs inside a Bazel action (bazel build //:needs_json), the
# CWD is the execroot / sandbox root and the JSON schema files are linked
# there at their workspace-relative paths (src/...) because they are
# declared as tools. However, the Sphinx source tree lives under
# bazel-out/…/_needs_json/_sources/, so literalinclude directives that
# traverse four levels up from docs/module/…/user_guide/ land at
# _sources/src/…, which Bazel does not populate automatically. Copying
# the files into the source tree directory makes literalinclude work
# without touching the RST files or the external docs macro.
#
# For non-Bazel runs (bazel run //:docs, local sphinx-build) the source
# JSON files already exist at srcdir.parent / "src" / …, so the guard
# below is a no-op.
srcdir = Path(app.srcdir)
workspace_root = Path(os.getcwd())
src_json_dir = (
workspace_root
/ "score/lifecycle/score/launch_manager/src/daemon/src/configuration/config_schema"
)
dest_json_dir = (
srcdir.parent
/ "score/lifecycle/score/launch_manager/src/daemon/src/configuration/config_schema"
)
if src_json_dir.exists() and not dest_json_dir.exists():
dest_json_dir.parent.mkdir(parents=True, exist_ok=True)
shutil.copytree(src_json_dir, dest_json_dir)