Skip to content

Commit

Permalink
Modeling from assertions.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmchilton committed Sep 12, 2024
1 parent a07ca1a commit 06a89e6
Show file tree
Hide file tree
Showing 16 changed files with 3,170 additions and 1,180 deletions.
32 changes: 12 additions & 20 deletions doc/parse_gx_xsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,28 +83,20 @@ def _build_tag(tag, hide_attributes):
assertions_buffer.write(_doc_or_none(assertions_tag))
assertions_buffer.write("\n\n")

assertion_groups = assertions_tag.xpath(
"xs:choice/xs:group", namespaces={"xs": "http://www.w3.org/2001/XMLSchema"}
assertion_tag = xmlschema_doc.find("//{http://www.w3.org/2001/XMLSchema}group[@name='TestAssertion']")
elements = assertion_tag.findall(
"{http://www.w3.org/2001/XMLSchema}choice/{http://www.w3.org/2001/XMLSchema}element"
)
for group in assertion_groups:
ref = group.attrib["ref"]
assertion_tag = xmlschema_doc.find("//{http://www.w3.org/2001/XMLSchema}group[@name='" + ref + "']")
doc = _doc_or_none(assertion_tag)
assertions_buffer.write(f"### {doc}\n\n")
elements = assertion_tag.findall(
"{http://www.w3.org/2001/XMLSchema}choice/{http://www.w3.org/2001/XMLSchema}element"
)
for element in elements:
for element in elements:
doc = _doc_or_none(element)
if doc is None:
doc = _doc_or_none(element)
if doc is None:
doc = _doc_or_none(_type_el(element))
assert doc is not None, f"Documentation for {element.attrib['name']} is empty"
doc = doc.strip()

element_el = _find_tag_el(element)
element_attributes = _find_attributes(element_el)
doc = _replace_attribute_list(element_el, doc, element_attributes)
assertions_buffer.write(f"#### ``{element.attrib['name']}``:\n\n{doc}\n\n")
assert doc is not None, f"Documentation for {element.attrib['name']} is empty"
doc = doc.strip()

element_attributes = _find_attributes(element)
doc = _replace_attribute_list(element, doc, element_attributes)
assertions_buffer.write(f"#### ``{element.attrib['name']}``:\n\n{doc}\n\n")
text = text.replace(line, assertions_buffer.getvalue())
tag_help.write(text)
if best_practices := _get_bp_link(annotation_el):
Expand Down
Loading

0 comments on commit 06a89e6

Please sign in to comment.