Skip to content

Commit

Permalink
Fix steps for Section.
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenpieters committed Jan 4, 2024
1 parent b700a60 commit 602725c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion rules_doc_generator/input/yaml/parser.py
Expand Up @@ -101,9 +101,10 @@ def parse_section(yaml_section: Any) -> Section:
new = parse_boolean(yaml_section, 'new')
text = parse_format_text_field(yaml_section, 'text')
toc_entry = parse_with_default(yaml_section, 'toc_entry', None, parse_str_field)
steps = parse_boolean(yaml_section, 'steps')
snippet = parse_with_default(yaml_section, 'snippet', None, parse_format_text_field)
section_elements = parse_subelements(yaml_section, 'rules', parse_section_element)
return Section(id, new, text, toc_entry, snippet, section_elements)
return Section(id, new, text, toc_entry, steps, snippet, section_elements)

def parse_chapter(yaml_chapter: Any) -> Chapter:
id = parse_id(yaml_chapter, 'chapter')
Expand Down
5 changes: 3 additions & 2 deletions rules_doc_generator/model/analysis/references.py
Expand Up @@ -35,11 +35,12 @@ def _construct_reference_map(
ref_map[id] = RefInfo(f'{chapter_index}', 'section', text, id, toc=True)
for i, section in enumerate(sections):
_construct_reference_map(section, ref_map, chapter_index, i+1, 0, 0)
case Section(id=id, section_elements=section_elements, text=text):
case Section(id=id, section_elements=section_elements, text=text, steps=steps):
check_id_defined(ref_map, id)
ref_map[id] = RefInfo(f'{chapter_index}.{section_index}', 'section', element.toc_text(), id, toc=True)
sub_ref_type = 'step' if steps else 'rule'
for i, section_element in enumerate(section_elements):
_construct_reference_map(section_element, ref_map, chapter_index, section_index, i+1, 0)
_construct_reference_map(section_element, ref_map, chapter_index, section_index, i+1, 0, sub_ref_type)
case SubSection(id=id, rules=rules, steps=steps, toc=toc):
if id is not None:
check_id_defined(ref_map, id)
Expand Down
1 change: 1 addition & 0 deletions rules_doc_generator/model/section.py
Expand Up @@ -260,6 +260,7 @@ class Section:
new: bool
text: FormatText
toc_entry: str | None
steps: bool
snippet: Optional[FormatText]
section_elements: list[SectionElement]

Expand Down

0 comments on commit 602725c

Please sign in to comment.