Skip to content

Commit da00c2b

Browse files
committed
Cleanup of unused parts
- Removed feature_requirements from component - Fixed integration tests
1 parent e3b4f65 commit da00c2b

10 files changed

Lines changed: 222 additions & 283 deletions

File tree

MODULE.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,5 +101,5 @@ git_override(
101101
remote = "https://github.com/eclipse-score/docs-as-code.git",
102102
)
103103

104-
bazel_dep(name = "score_platform", version = "0.5.0")
104+
# bazel_dep(name = "score_platform", version = "0.5.0")
105105
bazel_dep(name = "score_process", version = "1.3.2")

bazel/rules/rules_score/docs/index.rst

Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,141 @@ Builds Sphinx-based HTML documentation from RST source files with support for de
5959
**Output:** ``<name>/html/`` with merged dependency documentation
6060

6161

62+
Artifact Rules
63+
--------------
64+
65+
Artifact rules define S-CORE process work products. All provide ``SphinxSourcesInfo`` for documentation generation.
66+
67+
**feature_requirements**
68+
69+
.. code-block:: python
70+
71+
feature_requirements(
72+
name = "features",
73+
srcs = ["docs/features.rst"],
74+
)
75+
76+
**component_requirements**
77+
78+
.. code-block:: python
79+
80+
component_requirements(
81+
name = "requirements",
82+
srcs = ["docs/requirements.rst"],
83+
)
84+
85+
**assumptions_of_use**
86+
87+
.. code-block:: python
88+
89+
assumptions_of_use(
90+
name = "aous",
91+
srcs = ["docs/assumptions.rst"],
92+
)
93+
94+
**architectural_design**
95+
96+
.. code-block:: python
97+
98+
architectural_design(
99+
name = "architecture",
100+
static = ["docs/static_arch.rst"],
101+
dynamic = ["docs/dynamic_arch.rst"],
102+
)
103+
104+
**safety_analysis**
105+
106+
.. code-block:: python
107+
108+
safety_analysis(
109+
name = "safety",
110+
controlmeasures = ["docs/controls.rst"],
111+
failuremodes = ["docs/failures.rst"],
112+
fta = ["docs/fta.rst"],
113+
arch_design = ":architecture",
114+
)
115+
116+
**dependability_analysis**
117+
118+
.. code-block:: python
119+
120+
dependability_analysis(
121+
name = "analysis",
122+
arch_design = ":architecture",
123+
dfa = ["docs/dfa.rst"],
124+
safety_analysis = [":safety"],
125+
)
126+
127+
128+
Structural Rules
129+
----------------
130+
131+
**unit**
132+
133+
Define the smallest testable software element.
134+
135+
.. code-block:: python
136+
137+
unit(
138+
name = "my_unit",
139+
unit_design = [":architecture"],
140+
implementation = ["//src:lib"],
141+
tests = ["//tests:unit_test"],
142+
)
143+
144+
**component**
145+
146+
Define a collection of units.
147+
148+
.. code-block:: python
149+
150+
component(
151+
name = "my_component",
152+
component_requirements = [":requirements"],
153+
units = [":my_unit"],
154+
implementation = ["//src:binary"],
155+
tests = ["//tests:integration_test"],
156+
)
157+
158+
**dependable_element**
159+
160+
Define a complete SEooC with automatic documentation generation.
161+
162+
.. code-block:: python
163+
164+
dependable_element(
165+
name = "my_seooc",
166+
description = "My safety-critical component",
167+
assumptions_of_use = [":aous"],
168+
requirements = [":requirements"],
169+
architectural_design = [":architecture"],
170+
dependability_analysis = [":analysis"],
171+
components = [":my_component"],
172+
tests = ["//tests:system_test"],
173+
deps = ["@platform//:platform_module"],
174+
)
175+
176+
**Generated Targets:**
177+
178+
- ``<name>``: Sphinx module with HTML documentation
179+
- ``<name>_needs``: Sphinx-needs JSON for cross-referencing
180+
- ``<name>_index``: Generated index.rst with artifact structure
181+
182+
srcs = glob(["docs/**/*.rst"]),
183+
index = "docs/index.rst",
184+
deps = ["@external_module//:docs"],
185+
)
186+
187+
**Key Parameters:**
188+
189+
- ``srcs``: RST/MD source files
190+
- ``index``: Main index.rst file
191+
- ``deps``: Other sphinx_module or dependable_element targets for cross-referencing
192+
- ``sphinx``: Sphinx build binary (default: ``//bazel/rules/rules_score:score_build``)
193+
194+
**Output:** ``<name>/html/`` with merged dependency documentation
195+
196+
62197
Artifact Rules
63198
--------------
64199

@@ -180,6 +315,14 @@ Define a complete SEooC with automatic documentation generation.
180315
- ``<name>_needs``: Sphinx-needs JSON for cross-referencing
181316
- ``<name>_index``: Generated index.rst with artifact structure
182317

318+
**Implementation Details:**
319+
320+
The macro automatically:
321+
322+
- Generates an index.rst file with a toctree referencing all provided artifacts
323+
- Creates symlinks to artifact files (assumptions of use, requirements, architecture, safety analysis) for co-location with the generated index
324+
- Delegates to ``sphinx_module`` for actual Sphinx build and HTML generation
325+
- Integrates dependencies for cross-module referencing and HTML merging
183326

184327
Dependency Management
185328
---------------------
@@ -248,6 +391,49 @@ Build:
248391
bazel build //:persistency_kvs
249392
# Output: bazel-bin/persistency_kvs/html/
250393
394+
# Implementation
395+
cc_library(name = "kvs_lib", srcs = ["kvs.cpp"], hdrs = ["kvs.h"])
396+
cc_test(name = "kvs_test", srcs = ["kvs_test.cpp"], deps = [":kvs_lib"])
397+
398+
# Structure
399+
unit(name = "kvs_unit", unit_design = [":arch"],
400+
implementation = [":kvs_lib"], tests = [":kvs_test"])
401+
component(name = "kvs_component", component_requirements = [":reqs"],
402+
units = [":kvs_unit"], implementation = [":kvs_lib"], tests = [])
403+
404+
# SEooC
405+
dependable_element(
406+
name = "persistency_kvs",
407+
description = "Key-Value Store for persistent data storage",
408+
assumptions_of_use = [":aous"],
409+
requirements = [":reqs"],
410+
architectural_design = [":arch"],
411+
dependability_analysis = [":analysis"],
412+
components = [":kvs_component"],
413+
tests = [],
414+
deps = ["@score_process//:score_process_module"],
415+
)
416+
417+
Build:
418+
419+
.. code-block:: bash
420+
421+
bazel build //:kvs_seooc
422+
# Output: bazel-bin/kvs_seooc/html/
423+
# Includes merged HTML from score_platform and score_process modules
424+
425+
Design Rationale
426+
----------------
427+
428+
These rules provide a structured approach to documentation by:
429+
430+
1. **Two-Tier Architecture**: Generic ``sphinx_module`` for flexibility, specialized ``score_component`` for safety-critical work
431+
2. **Dependency Management**: Automatic cross-referencing and HTML merging across modules
432+
3. **Standardization**: SEooC enforces consistent structure for safety documentation
433+
4. **Traceability**: Sphinx-needs integration enables bidirectional traceability
434+
5. **Automation**: Index generation, symlinking, and configuration management are automatic
435+
6. **Build System Integration**: Bazel ensures reproducible, cacheable documentation builds
436+
251437
Reference Implementation
252438
------------------------
253439

bazel/rules/rules_score/private/component.bzl

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ def _component_impl(ctx):
4949
# Collect implementation targets
5050
implementation_depset = depset(ctx.attr.implementation)
5151

52-
# Collect units and tests
53-
units_depset = depset(ctx.attr.units)
52+
# Collect components and tests
53+
components_depset = depset(ctx.attr.components)
5454
tests_depset = depset(ctx.attr.tests)
5555

5656
# Combine all files for DefaultInfo
@@ -64,7 +64,7 @@ def _component_impl(ctx):
6464
name = ctx.label.name,
6565
requirements = requirements_depset,
6666
implementation = implementation_depset,
67-
units = units_depset,
67+
components = components_depset,
6868
tests = tests_depset,
6969
),
7070
SphinxSourcesInfo(
@@ -89,7 +89,7 @@ _component = rule(
8989
doc = "Implementation targets (libraries, binaries) that realize this component",
9090
default = [],
9191
),
92-
"units": attr.label_list(
92+
"components": attr.label_list(
9393
mandatory = True,
9494
doc = "Unit targets that comprise this component",
9595
),
@@ -149,20 +149,11 @@ def component(
149149
```
150150
"""
151151

152-
# Support both old parameter names and new aliases
153-
final_requirements = requirements
154-
final_units = units if units != None else components
155-
156-
if final_requirements == None:
157-
fail("component() requires 'requirements' parameter")
158-
if final_units == None:
159-
fail("component() requires either 'units' or 'components' parameter")
160-
161152
_component(
162153
name = name,
163-
requirements = final_requirements,
154+
requirements = requirements,
164155
implementation = implementation,
165-
units = final_units,
156+
components = components,
166157
tests = tests,
167158
testonly = testonly,
168159
visibility = visibility,

bazel/rules/rules_score/private/component_requirements.bzl

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ ComponentRequirementsInfo = provider(
3030
doc = "Provider for component requirements artifacts",
3131
fields = {
3232
"srcs": "Depset of source files containing component requirements",
33+
"requirements": "List of FeatureRequirementsInfo providers this component traces to",
3334
"name": "Name of the component requirements target",
3435
},
3536
)
@@ -54,15 +55,9 @@ def _component_requirements_impl(ctx):
5455

5556
# Collect feature requirements providers
5657
feature_reqs = []
57-
for feat_req in ctx.attr.feature_requirement:
58-
if FeatureRequirementsInfo in feat_req:
59-
feature_reqs.append(feat_req[FeatureRequirementsInfo])
6058

6159
# Collect transitive sphinx sources from feature requirements
6260
transitive = [srcs]
63-
for feat_req in ctx.attr.feature_requirement:
64-
if SphinxSourcesInfo in feat_req:
65-
transitive.append(feat_req[SphinxSourcesInfo].transitive_srcs)
6661

6762
return [
6863
DefaultInfo(files = srcs),
@@ -99,7 +94,6 @@ _component_requirements = rule(
9994
def component_requirements(
10095
name,
10196
srcs,
102-
feature_requirement = [],
10397
visibility = None):
10498
"""Define component requirements following S-CORE process guidelines.
10599
@@ -114,9 +108,6 @@ def component_requirements(
114108
srcs: List of labels to .rst, .md, or .trlc files containing the
115109
component requirements specifications as defined in the S-CORE
116110
process.
117-
feature_requirement: Optional list of labels to feature_requirements
118-
targets that these component requirements trace to. Establishes
119-
bidirectional traceability as defined in the S-CORE process.
120111
visibility: Bazel visibility specification for the generated targets.
121112
122113
Generated Targets:
@@ -127,13 +118,11 @@ def component_requirements(
127118
component_requirements(
128119
name = "my_component_requirements",
129120
srcs = ["component_requirements.rst"],
130-
feature_requirement = [":my_feature_requirements"],
131121
)
132122
```
133123
"""
134124
_component_requirements(
135125
name = name,
136126
srcs = srcs,
137-
feature_requirement = feature_requirement,
138127
visibility = visibility,
139128
)

0 commit comments

Comments
 (0)