Skip to content

Poc/rst package param - #449

Draft
antonkri wants to merge 5 commits into
mainfrom
poc/rst-package-param
Draft

Poc/rst package param#449
antonkri wants to merge 5 commits into
mainfrom
poc/rst-package-param

Conversation

@antonkri

Copy link
Copy Markdown

No description provided.

component_requirements/feature_requirements/assumed_system_requirements
derive the TRLC package name from the .rst source file's basename stem
when no explicit override is given (see rst_to_trlc.py). Multiple
requirement targets converted from same-named .rst files (e.g.
'index.rst' in different packages) therefore collide on the same
default package name, which can lead to invalid self-imports when one
target's ref_package points at another target that resolves to the
same name.

Thread a new 'package' parameter through score_requirements_rule and
the three public macros down to the existing (but previously
unexposed) rst_to_trlc 'package' attribute, so callers can pick an
explicit, collision-free package name. Only affects the .rst
conversion path; raw .trlc srcs are unaffected and keep declaring
their package name in the source file as before.
derived_from/satisfies fields previously had the record's [version==N]
qualifier (if written by the RST author) silently discarded: render_trlc
always hardcoded '@1' regardless of what version was actually requested,
producing wrong (or, when combined with the literal bracket text, plain
invalid) TRLC syntax such as 'Pkg.name[version==2]@1'.

Add _split_ref() to parse the optional qualifier out of each reference
token and use the parsed version number (defaulting to 1, matching prior
behavior for bare ids) when building the derived_from list.
Lets a single RST source file that contains multiple directive types (e.g.
both comp_req and aou_req in one requirements/index.rst) be converted
differently by different rule invocations, each picking up only its
relevant subset.

- rst_to_trlc.py: parse_directives()/convert() gain an optional
  only_types set; CLI gains --only-types (comma-separated).
- rst_to_trlc.bzl: rst_to_trlc rule gains an only_types string_list attr,
  forwarded to the Python CLI; rst_srcs_to_trlc() gains a matching
  only_types param. Also: declare_file output is now namespaced under
  ctx.label.name instead of sibling=src, fixing an output-path collision
  when two rules (e.g. component_requirements and assumptions_of_use)
  both convert the same source RST file.
- requirements.bzl: score_requirements_rule() maps req_kind to the
  relevant directive set (_REQ_KIND_TO_DIRECTIVES) and passes it as
  only_types.
- assumptions_of_use.bzl: assumptions_of_use() passes
  only_types=["aou_req"] so it only ever picks up AoU directives, even
  when srcs is shared with a component_requirements() target.
LOCAL WORKAROUND: the pinned trlc v3.0.0 module TRLCRST class does not
implement objects_by_fqn()/field_value_for()/render_table_to_string()
that fmea_assembler.py expects. Add a local reimplementation driven by
the already-parsed Symbol_Table so the fmea() pipeline can be exercised
end-to-end. Remove once upstream trlc_rst gains this API.
main bumped the pinned trlc module to v3.0.1, which now ships
objects_by_fqn()/field_value_for()/render_table_to_string() natively on
TRLCRST. The local workaround added in 9a90e17 is therefore no longer
needed.

Also fixes test_fmea_assembler.py fixtures that still used the old
singular 'guideword' field instead of the plural 'guidewords' list.
@antonkri
antonkri marked this pull request as draft August 28, 2026 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant