From 92c71e8e82957b7ef9f12cd6e92da1f31768b582 Mon Sep 17 00:00:00 2001
From: Nik Richers [^<]*
',
+ '',
+ html_content
+ )
+ # Clean up multiple consecutive blank lines
+ html_content = re.sub(r'\n{3,}', '\n\n', html_content)
# Build stylesheet link tags
stylesheet_links = '\n'.join(
@@ -124,34 +141,45 @@ def main():
'
Top-level documentation sections shown in the template editor.
+ + + + + + + No Additional ItemsA section in the document tree.
+ + + No Additional Properties + + + + + + +Unique identifier for the section.
+ + + + + + + +Title of the section.
+ + + + + + + +Description of the section.
+ + + + + + + +Order of the section in the navigation menu. By default sections are ordered alphabetically. If order is specified, sections will be ordered by the order value, and then alphabetically.
+ + + + + + + +Default text for the section. If set, a metadata content row will be created with this text when installing the template on a given project.
+ + + + + + + +If true, the section will be displayed in the navigation menu, but it will not be accessible via direct link.
+ + + + + + + +If true, the section will condense all of its subsections into a single section.
+ + + + + + + +Documentation or validation guidelines for the section.
+ + + + + + + No Additional ItemsContents to be displayed on the section.
+ + + + + + + No Additional ItemsSingle content block rendered within a section.
+ + + + + + + + + +"text"
+"test"
+ID of the content to be displayed for the given content type.
+"sample_text"
+[
+ "sample_text",
+ "section_intro"
+]
+Options for the content block.
+ + + + + + +{
+ "default_text": "This is a sample text block."
+}
+{
+ "metric_id": "metric_1",
+ "title": "Custom Title for Metric 1"
+}
+{
+ "test_id": "adf_test"
+}
+Default text for the content block. Only applicable for text content blocks.
+ + + + + + + +Title of the content block. Only applicable for metric and test content blocks.
+ + + + + + + +Additional Properties of any type are allowed.
+ + Type: objectNested child sections.
+ + + + + + + No Additional Items' ) - # Copyright header to place before the raw HTML block - copyright_header = """""" - - # Wrap HTML in Quarto raw HTML block for .qmd file, with comment before - qmd_content = f"""{copyright_header} +Source: {SCHEMA_FILE.relative_to(BACKEND_ROOT.parent)} +--> ```{{=html}} {html_content} ``` """ - # Write final output - OUTPUT_FILE.parent.mkdir(parents=True, exist_ok=True) - with open(OUTPUT_FILE, "w") as f: - f.write(qmd_content) + # Validate output before writing + if len(output_content) < MIN_OUTPUT_SIZE: + print(f"Error: Generated output is too small ({len(output_content)} bytes)") + print("This likely indicates a generation failure.") + temp_output.unlink(missing_ok=True) + sys.exit(1) + + if "" not in html_content: + print("Error: Generated output does not contain valid HTML structure") + temp_output.unlink(missing_ok=True) + sys.exit(1) + + # Write to target file + TARGET_FILE.write_text(output_content) # Clean up temp file temp_output.unlink() - print(f"Generated {OUTPUT_FILE}") + print(f"Generated template schema documentation: {TARGET_FILE}") + print(f"Output size: {len(output_content)} bytes") if __name__ == "__main__": diff --git a/site/Makefile b/site/Makefile index 6773da52d5..d3372f286c 100644 --- a/site/Makefile +++ b/site/Makefile @@ -427,7 +427,7 @@ release-notes: template-schema-docs: @echo "\nGenerating template schema documentation ..." @if [ ! -d "$(SRC_ROOT)/backend" ]; then echo "Error: Backend not cloned. Run 'make clone' first."; exit 1; fi - @pip install -q json-schema-for-humans + @python -m pip install -q json-schema-for-humans @BACKEND_ROOT=$(SRC_ROOT)/backend python ../scripts/generate_template_schema_docs.py test-descriptions: diff --git a/site/guide/templates/_template-schema-generated.qmd b/site/guide/templates/_template-schema-generated.qmd new file mode 100644 index 0000000000..8edc74c349 --- /dev/null +++ b/site/guide/templates/_template-schema-generated.qmd @@ -0,0 +1,1143 @@ + + +```{=html} + + +
+ + + + + + + + + + + +