Skip to content
Snippets Groups Projects
Commit 2dee08bc authored by Kristina Mazur's avatar Kristina Mazur
Browse files

Initial adaptions (but make wrong output)

parent 91a9d945
No related tags found
No related merge requests found
......@@ -62,10 +62,10 @@ pages:
before_script:
- pip install pipenv
- pipenv install
script:
- mkdir $CI_PROJECT_DIR/docs/aircraft-xml
#- python $CI_PROJECT_DIR/scripts/document_aircraft_xml.py --title Design specification --level 4 $CI_PROJECT_DIR/scripts/csmr-2020_startCSD.xml > $CI_PROJECT_DIR/docs/aircraft-xml/specification.md
- python $CI_PROJECT_DIR/scripts/document_aircraft_xml.py --title DesignSpecification --level 4 $CI_PROJECT_DIR/scripts/CSR-02.xml > $CI_PROJECT_DIR/docs/aircraft-xml/specification.md
script:cmks
- mkdir $CI_PROJECT_DIR/documentation/aircraft-xml
#- python $CI_PROJECT_DIR/scripts/document_aircraft_xml.py --title Design specification --level 4 $CI_PROJECT_DIR/scripts/csmr-2020_startCSD.xml > $CI_PROJECT_DIR/documentation/aircraft-xml/specification.md
- python $CI_PROJECT_DIR/scripts/document_aircraft_xml.py --title DesignSpecification --level 4 $CI_PROJECT_DIR/scripts/csmr-2020_startCSD.xml > $CI_PROJECT_DIR/documentation/aircraft-xml/specification.md
- pipenv run mkdocs build --site-dir $CI_PROJECT_DIR/public
needs:
- doxygen
......
This diff is collapsed.
......@@ -59,11 +59,12 @@ FORMAT = {
# Which keys are used in the XML attributes for which information
KEYS = {
"Description": "Desc",
"Unit": "Unit",
"Description": "description", # Match the 'description' key from XML
"Unit": "unit", # Match the 'unit' key from XML
}
# === Classes ===
class Page:
"""Class for a page.
......@@ -93,11 +94,6 @@ class Page:
def create(self, node: ET.Element):
"""Creates the page from the given node.
This function adds all subnodes of the given node to the page.
It recursively calls itself for all subnodes.
It does not add sections which are already present in the current level.
Args:
node (ET.Element): Node to start from.
"""
......@@ -115,8 +111,10 @@ class Page:
# Loop through the children and group single entries in a table
for child in node:
if len(child) == 0:
if len(child) == 0: # No further nesting
self.make_table_entry(child)
else:
self.create(child) # Recursively process child nodes
# Add a new level of sections
self.current_level += 1
......@@ -141,20 +139,20 @@ class Page:
# Reset the table when creating a new header
self.table_started = False
# Fetch description
description = node.attrib.get(KEYS["Description"], "None")
# Create the header with description
print(
"\n"
+ self.current_level * "#"
+ FORMAT["Header"].format(
node.tag, node.attrib.get(KEYS["Description"], "None")
)
+ FORMAT["Header"].format(node.tag, description)
)
# Try to add a unit description
try:
print(FORMAT["Unit"].format(node.attrib[KEYS["Unit"]]))
except KeyError:
pass
unit = node.attrib.get(KEYS["Unit"])
if unit:
print(FORMAT["Unit"].format(unit))
def make_table_entry(self, node: ET.Element):
"""Creates a table entry.
......@@ -171,15 +169,13 @@ class Page:
# and replace the backslashes with forward slashes
path_name = str(self.current_path / node.tag).replace("\\", "/")
# Create the header with description
print(
FORMAT["Table"].format(
path_name,
node.attrib.get(KEYS["Unit"], "-"),
node.attrib.get(KEYS["Description"], "None"),
)
)
# Fetch description and unit
description = node.attrib.get(KEYS["Description"], f"No description for {node.tag}")
unit = node.attrib.get(KEYS["Unit"], "No unit specified")
# Create the table row
print(FORMAT["Table"].format(path_name, unit, description))
# === Main ===
def main():
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment