#plain-text #requirements #trace #ast #collect #mantra #framework

mantra-lang-tracing

Contains functionality needed to collect requirement traces from code or plain text files for the mantra framework

7 releases (breaking)

0.7.0 Dec 17, 2024
0.6.1 Jul 4, 2024
0.5.0 Jun 14, 2024
0.4.0 Jun 13, 2024
0.1.0 Apr 29, 2024

#382 in Text processing

Download history 26/week @ 2024-09-18 26/week @ 2024-09-25 11/week @ 2024-10-02 45/week @ 2024-10-09 72/week @ 2024-10-16 4/week @ 2024-10-23 3/week @ 2024-10-30 4/week @ 2024-11-06 2/week @ 2024-11-13 5/week @ 2024-11-20 4/week @ 2024-11-27 8/week @ 2024-12-04 101/week @ 2024-12-11 75/week @ 2024-12-18 13/week @ 2024-12-25 7/week @ 2025-01-01

203 downloads per month
Used in 6 crates (4 directly)

MIT license

45KB
915 lines

mantra-lang-tracing

This crate contains functionality needed to collect requirement traces from code or plain text files. Traces are a link between requirement definitions and where they are implemented in code.

Usage

Plain text collector

The PlainCollector may be used to collect traces from plain text files. Traces with the form [req(<requirement id(s)>)] are collected line by line.

Example:

This line has a valid trace. [req(valid_trace)]

Traces cannot span multiple lines. [req(
invalid_trace)]

AST collector

The AstCollector may be used to collect traces from the abstract syntax tree of a code file. It uses tree-sitter to create the AST, and allows to define a collector function that tries to collect traces from AST nodes.

This collector may be used as a base to create trace collectors for programming languages.

Specifying requirement IDs

The extract_req_ids*() functions offer a consistent way to extract requirement IDs from traces. They should be used in custom collector implementations, to keep the same syntax for specifying IDs.

Syntax:

ids = id , {(",", id)} ;
id = {(id_part, "." )}, id_part ;
id_part = escaped_id_part | unescaped_id_part ;
escaped_id_part = '"', ?any char except '"', '`', or '.'?, '"' ;
unescaped_id_part = ( digit | rust_identifier ) , { digit | rust_identifier } ;

Examples:

"escaped-id".sub_id

1234."digit-only-main-id"

first_id, second_id

Dependencies

~1.5–3.5MB
~65K SLoC