-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathconf.py
More file actions
254 lines (218 loc) · 8.37 KB
/
Copy pathconf.py
File metadata and controls
254 lines (218 loc) · 8.37 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
# SPDX-License-Identifier: MIT OR Apache-2.0
# SPDX-FileCopyrightText: The Coding Guidelines Subcommittee Contributors
# -- Project information -----------------------------------------------------
project = "Safety-Critical Rust Coding Guidelines"
copyright = "2025, Contributors to Coding Guidelines Subcommittee"
author = "Contributors to Coding Guidelines Subcommittee"
release = "0.1"
# -- General configuration ---------------------------------------------------
# Add sphinx-needs to extensions
extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.viewcode",
"sphinx.ext.autosectionlabel",
"sphinx_needs",
"coding_guidelines",
]
# Show hidden lines in all examples (default: False)
rust_examples_show_hidden = False
# Path to shared prelude (default: None)
rust_examples_prelude_file = "src/examples_prelude.rs"
# Basic needs configuration
needs_id_regex = "^[A-Za-z0-9_]+"
needs_title_optional = True
needs_id_from_title = False
needs_build_json = True
# Configure sphinx-needs
needs_types = [
{
"directive": "guideline",
"title": "Guideline",
"prefix": "gui_",
"color": "#BFD8D2",
"style": "node",
},
{
"directive": "rationale",
"title": "Rationale",
"prefix": "rat_",
"color": "#DF744A",
"style": "node",
},
{
"directive": "compliant_example",
"title": "Compliant Example",
"prefix": "compl_ex_",
"color": "#729FCF",
"style": "node",
},
{
"directive": "non_compliant_example",
"title": "Non-Compliant Example",
"prefix": "non_compl_ex_",
"color": "#729FCF",
"style": "node",
},
{
"directive": "bibliography",
"title": "Bibliography",
"prefix": "bib_",
"color": "#A8D8EA",
"style": "node",
},
]
# Define custom sections for needs
needs_layouts = {
"guideline": {
"content": [
"content",
"rationale",
"non_compliant_example",
"compliant_example",
"bibliography",
]
}
}
# Tell sphinx-needs which sections to render
needs_render_contexts = {
"guideline": {
"content": ["content"],
"extra_content": [
"rationale",
"non_compliant_example",
"non_compliant_example",
"bibliography",
],
}
}
# Make sure these sections are included in the JSON
needs_extra_sections = ["rationale", "compliant_example", "non_compliant_example", "bibliography"]
needs_statuses = [
dict(name="draft", description="This guideline is in draft stage", color="#999999"),
dict(
name="approved", description="This guideline has been approved", color="#00FF00"
),
dict(name="retired", description="This guideline is retired", color="#FF0000"),
]
needs_tags = [
dict(name="security", description="Security-related guideline"),
dict(name="safety", description="The degree to which a product or system avoids endangering human life, health, property, or the environment under defined operating conditions."),
dict(name="performance", description="Performance-related guideline"),
dict(name="readability", description="Readability-related guideline"),
dict(name="understandability", description="Understandability is a sub-characteristic of usability in the ISO/IEC 25000 quality model, which measures how easy it is for users to understand the functions and usage of a software product. It is also a separate quality characteristic for data, referring to how well data can be read and interpreted by users with the help of appropriate languages, symbols, and units."),
dict(name="reduce-human-error", description="Guideline that helps prevent human error"),
dict(name="numerics", description="Numerics-related guideline"),
dict(name="undefined-behavior", description="Guideline related to Undefined Behavior"),
dict(name="stack-overflow", description="Guideline related to Stack Overflow"),
dict(name="unions", description="Guideline related to union types and field access"),
dict(name="initialization", description="Guideline related to initialization requirements and uninitialized data"),
dict(name="maintainability", description="How effectively and efficiently a product or system can be modified. This includes improvements, fault corrections, and adaptations to changes in the environment or requirements. It is considered a crucial software quality characteristic."),
dict(name="portability", description="The degree to which a system, product, or component can be effectively and efficiently transferred from one hardware, software, or other operational or usage environment to another."),
dict(name="surprising-behavior", description="Guideline related to surprising or unexpected behavior"),
dict(name="types", description="Guideline associated with the correct use of types"),
dict(name="subset", description="Guideline associated with the language-subset profile"),
dict(name="defect", description="Guideline associated with the defect-prevention profile"),
dict(name="unsafe", description="Guidelines that interact with or involve the unsafe keyword"),
dict(name="injection", description="Guidelines about various kinds of injections"),
dict(name="sanitization", description="Guidelines about sanitizing untrusted input"),
]
needs_categories = [
dict(name="mandatory", description="This guideline is mandatory", color="#999999"),
dict(name="required", description="This guideline is required", color="#FFCC00"),
dict(
name="advisory",
description="This guideline is advisory, should be followed when able",
color="#FFCC00",
),
dict(
name="disapplied",
description="This guideline is advisory, should be followed when able",
color="#FFCC00",
),
]
needs_decidabilities = [
dict(
name="decidable",
description="This guideline can be automatically checked with tooling",
color="#999999",
),
dict(
name="undecidable",
description="This guideline cannot be automatically checked with tooling",
color="#999999",
),
]
needs_scopes = [
dict(
name="module",
description="This guideline can be checked at the module level",
color="#999999",
),
dict(
name="crate",
description="This guideline can be checked at the crate level",
color="#FFCC00",
),
dict(
name="system",
description="This guideline must be checked alongside the entire source",
color="#FFCC00",
),
]
needs_releases = [
dict(
name="1.85.0",
description="This guideline can be checked at the module level",
color="#999999",
),
dict(
name="1.85.1",
description="This guideline can be checked at the module level",
color="#999999",
),
]
# Enable needs export
needs_extra_options = [
"category",
"recommendation",
"fls",
"decidability",
"scope",
"release",
]
# Required guideline fields
required_guideline_fields = [
"category",
"release",
"fls",
"decidability",
"scope",
"tags",
] # Id is automatically generated
# -- Bibliography validation configuration -----------------------------------
# Enable URL validation (typically only in CI)
bibliography_check_urls = False # Set via --define or environment
# Timeout for URL checks in seconds
bibliography_url_timeout = 10
# Whether broken URLs should fail the build (True) or just warn (False)
bibliography_fail_on_broken = True
# Whether duplicate URLs should fail the build
bibliography_fail_on_duplicates = True
# Whether to warn about bibliography entries not cited in text
bibliography_check_unused = False
# -- Text content validation configuration -----------------------------------
# Enable inline URL detection in guideline text
# When enabled, URLs in guideline content will be flagged as errors
# Contributors should use :std: role or bibliography citations instead
text_check_inline_urls = True
# Whether inline URLs should fail the build (True) or just warn (False)
text_check_fail_on_inline_urls = True
# -- Options for HTML output -------------------------------------------------
# Configure the theme
html_theme = "sphinx_rtd_theme"
html_static_path = ["_static"]
templates_path = ['_templates']
# Custom CSS files to include
html_css_files = [
'custom.css',
]