Skip to content

docs: example of retrieving the requirement text as plain text - #234

Merged
stanislaw merged 1 commit into
strictdoc-project:mainfrom
devteamaegis:docs/extract-requirement-text-example
Nov 13, 2026
Merged

stanislaw merged 1 commit into
strictdoc-project:mainfrom
devteamaegis:docs/extract-requirement-text-example

Conversation

@devteamaegis

Copy link
Copy Markdown
Contributor

Closes #143.

The README showed how to iterate a specification's hierarchy, but not how to get from a SPEC-HIERARCHY node to the requirement text. That takes three steps that are hard to find: look up the SPEC-OBJECT by the SPEC-OBJECT-REF (ReqIFBundle.get_spec_object_by_ref()), get the attribute names such as ReqIF.Text from the SPEC-OBJECT-TYPE (get_spec_object_type_by_ref() and attribute_map), and turn the XHTML value into plain text.

This adds the integration example tests/integration/examples/05_extract_requirement_text with a small ReqIF input (a section and two requirements with nested XHTML). Its script prints each SPEC-OBJECT's identifier, LONG-NAME, and attribute values, and converts XHTML attributes with lxml.html.fromstring(attribute.value_stripped_xhtml).text_content(). lxml is already a dependency. The test checks every output line with FileCheck and fails if any XHTML tag is left in the output. The README gets a "Retrieving the requirement text" section with the same code.

The input file passes reqif validate --use-reqif-schema, and reqif passthrough reproduces it unchanged. No library code changes.

Locally, invoke lint passes, and invoke test passes 76 unit tests plus 79 of 80 integration tests (1 pre-existing unsupported). One note: lit 23.x, the current PyPI release, rejects ShTest("0") in tests/integration/lit.cfg, so I ran the integration tests with lit 18.1.8. CI might hit this independently of this PR.

Users reading a ReqIF file did not find how to go from a SPEC-HIERARCHY
node to the requirement text: the hierarchy only holds a SPEC-OBJECT-REF,
the attribute names live on the SPEC-OBJECT-TYPE, and the text of XHTML
attributes is an XHTML fragment.

Add the integration example 05_extract_requirement_text. It looks up the
SPEC-OBJECT with ReqIFBundle.get_spec_object_by_ref(), names each
attribute through the SPEC-OBJECT-TYPE's attribute_map, and converts
value_stripped_xhtml to plain text with lxml. The test checks the
script's output with FileCheck, including that no XHTML tag is left.

Add a "Retrieving the requirement text" section to the README with the
same code.

Closes strictdoc-project#143
@devteamaegis

Copy link
Copy Markdown
Contributor Author

Friendly ping @stanislaw: this is ready for review whenever you have time (addresses #143); happy to change the approach.

This was investigated and written with an AI coding agent (Claude) working on my behalf.

@stanislaw
stanislaw force-pushed the docs/extract-requirement-text-example branch from efb0265 to 53e8c50 Compare November 12, 2026 22:31
@stanislaw
stanislaw merged commit 721421e into strictdoc-project:main Nov 13, 2026
6 checks passed
@devteamaegis

Copy link
Copy Markdown
Contributor Author

Thanks @stanislaw for merging.

This was investigated and written with an AI coding agent (Claude) working on my behalf.

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.

Make it very obvious how to retrieve the requirement text

2 participants