Skip to main content

section_lines

Function section_lines 

Source
pub fn section_lines(file: &ProtoFile) -> Vec<String>
Expand description

The section list the shell tool reads: one section per line, tab-separated, in document order — level, heading, required/optional, non-empty/any. A kind with no body contract projects an empty file, which is an answer rather than a missing artifact.

use majordomus_cli::proto;
let text = r#"
syntax = "proto3";
package majordomus.adr.v1;
option (majordomus.schema_id) = "majordomus.adr/v1";
option (majordomus.document_format) = "markdown";
message Header { string id = 1; }
message Body {
  option (majordomus.body) = true;
  Section context = 1 [(majordomus.heading) = "Context", (majordomus.level) = 2,
                       (majordomus.required) = true, (majordomus.non_empty) = true];
  Section notes = 2 [(majordomus.heading) = "Notes", (majordomus.level) = 2];
}
message Section { string heading = 1; }
"#;
let file = proto::parse("adr.v1.proto", text).unwrap();
assert_eq!(proto::project::section_lines(&file), [
    "2\tContext\trequired\tnon-empty",
    "2\tNotes\toptional\tany",
]);