diff --git a/docgen/json/gen.sh b/docgen/json/gen.sh index e92128bc..a4e98d83 100755 --- a/docgen/json/gen.sh +++ b/docgen/json/gen.sh @@ -4,7 +4,7 @@ mkdir -p docs/{1.2,1.3,1.4,1.5,1.6} # Check to see if generate-schema-doc is executable and is in the path. If not, install JSON Schema for Humans. if ! [ -x "$(command -v generate-schema-doc)" ]; then - pip3 install json-schema-for-humans==0.44.3 + pip3 install json-schema-for-humans==0.47 fi generate () { diff --git a/docgen/json/templates/cyclonedx/content.html b/docgen/json/templates/cyclonedx/content.html index 3e880425..f5ae10c6 100644 --- a/docgen/json/templates/cyclonedx/content.html +++ b/docgen/json/templates/cyclonedx/content.html @@ -17,13 +17,17 @@ {# Display type #} {%- if not schema is combining -%} - Type: {{ type_name }} + Type: {{ type_name }} + {%- endif -%} + + {%- if schema.format -%} + Format: {{ schema.format }} {%- endif -%} {# Display default #} {%- set default_value = schema.default_value -%} {%- if default_value -%} - {{ " " }}Default: {{ default_value }} + {{ " " }}Default: {{ default_value }} {%- endif -%}
@@ -37,80 +41,72 @@ {%- elif schema.refers_to -%} {{ content(schema.refers_to_merged, True) }} {%- else -%} - {# Handle having oneOf or allOf with only one condition #} - {%- if schema.kw_all_of and (schema.kw_all_of.array_items | length) == 1 -%} - {{ content(schema.kw_all_of.array_items[0]) }} - {%- elif schema.kw_any_of and (schema.kw_any_of.array_items | length) == 1 -%} - {{ content(schema.kw_any_of.array_items[0]) }} - {%- else -%} - {%- if schema.explicit_no_additional_properties -%} - {{ " " }}No Additional Properties - {%- endif -%} - - {# Combining: allOf, anyOf, oneOf, not #} - {%- if schema.kw_all_of -%} -
{{ tabbed_section("allOf", schema.kw_all_of) }}
- {%- endif -%} - {%- if schema.kw_any_of -%} -
{{ tabbed_section("anyOf", schema.kw_any_of) }}
- {%- endif -%} - {%- if schema.kw_one_of -%} -
{{ tabbed_section("oneOf", schema.kw_one_of) }}
- {%- endif -%} - {%- if schema.kw_not -%} - {% include "section_not.html" %} - {%- endif -%} - - {# Enum and const #} - {%- if schema.kw_enum -%} -
-

Must be one of:

- -
- {%- endif -%} - {%- if schema.kw_const -%} - Specific value: {{ schema.kw_const.raw | python_to_json }} - {%- endif -%} + {%- if schema.explicit_no_additional_properties -%} + {{ " " }}No Additional Properties + {%- endif -%} - {# Pattern (Regular Expression) #} - {%- if schema.kw_pattern -%} - Must match regular expression: {{ schema.kw_pattern.literal | escape }} - {%- endif -%} + {# Combining: allOf, anyOf, oneOf, not #} + {%- if schema.kw_all_of -%} +
{{ tabbed_section("allOf", schema.kw_all_of) }}
+ {%- endif -%} + {%- if schema.kw_any_of -%} +
{{ tabbed_section("anyOf", schema.kw_any_of) }}
+ {%- endif -%} + {%- if schema.kw_one_of -%} +
{{ tabbed_section("oneOf", schema.kw_one_of) }}
+ {%- endif -%} + {%- if schema.kw_not -%} + {% include "section_not.html" %} + {%- endif -%} - {# Conditional subschema, or if-then-else section #} - {%- if schema.has_conditional -%} - {% include "section_conditional_subschema.html" %} - {%- endif -%} + {# Enum and const #} + {%- if schema.kw_enum -%} +
+

Must be one of:

+ +
+ {%- endif -%} + {%- if schema.kw_const -%} + Specific value: {{ schema.kw_const.raw | python_to_json }} + {%- endif -%} - {# Required properties that are not defined under "properties". They will only be listed #} - {% include "section_undocumented_required_properties.html" %} + {# Pattern (Regular Expression) #} + {%- if schema.kw_pattern -%} + Must match regular expression: {{ schema.kw_pattern.literal | escape }} + {%- endif -%} - {# Show the requested type(s) #} - {% include "badge_type.html" %} + {# Conditional subschema, or if-then-else section #} + {%- if schema.has_conditional -%} + {% include "section_conditional_subschema.html" %} + {%- endif -%} - {# Show array restrictions #} - {%- if type_name.startswith("array") -%} - {% include "section_array.html" %} - {%- endif -%} + {# Required properties that are not defined under "properties". They will only be listed #} + {% include "section_undocumented_required_properties.html" %} - {# Display examples #} - {%- set examples = schema.examples -%} - {%- if examples -%} - {% include "section_examples.html" %} - {%- endif -%} + {# Show the requested type(s) #} + {% include "badge_type.html" %} - {# Properties, pattern properties, additional properties #} - {%- for sub_property in schema.iterate_properties -%} - {# Custom modification to remove $ properties from documentation #} - {%- if not sub_property.property_display_name.startswith("$") -%} - {% include "section_properties.html" %} - {%- endif -%} - {%- endfor -%} + {# Show array restrictions #} + {%- if type_name.startswith("array") -%} + {% include "section_array.html" %} + {%- endif -%} + {# Display examples #} + {%- set examples = schema.examples -%} + {%- if examples -%} + {% include "section_examples.html" %} {%- endif -%} + + {# Properties, pattern properties, additional properties #} + {%- for sub_property in schema.iterate_properties -%} + {# Custom modification to remove $ properties from documentation #} + {%- if not sub_property.property_display_name.startswith("$") -%} + {% include "section_properties.html" %} + {%- endif -%} + {%- endfor -%} {%- endif -%} {%- endmacro -%} \ No newline at end of file diff --git a/docgen/json/templates/cyclonedx/schema_doc.js b/docgen/json/templates/cyclonedx/schema_doc.js index be02797f..e03ce946 100644 --- a/docgen/json/templates/cyclonedx/schema_doc.js +++ b/docgen/json/templates/cyclonedx/schema_doc.js @@ -19,7 +19,7 @@ function setAnchor(anchorLinkDestination) { function anchorOnLoad() { // Added to onload on body, checks if there is an anchor link and if so, expand - let linkTarget = window.location.hash.split("?")[0].split("&")[0]; + let linkTarget = decodeURIComponent(window.location.hash.split("?")[0].split("&")[0]); if (linkTarget[0] === "#") { linkTarget = linkTarget.substr(1); } @@ -37,7 +37,7 @@ function anchorLink(linkTarget) { if($( this ).hasClass("collapse")) { $( this ).collapse("show"); } else if ($( this ).hasClass("tab-pane")) { - // We have the pane and not the the tab itself, find the tab + // We have the pane and not the tab itself, find the tab const tabToShow = $( "a[href='#" + $( this ).attr("id") + "']" ); if (tabToShow) { tabToShow.tab("show"); diff --git a/docgen/json/templates/cyclonedx/schema_doc.min.js b/docgen/json/templates/cyclonedx/schema_doc.min.js index 0d9c7882..0c58a70e 100644 --- a/docgen/json/templates/cyclonedx/schema_doc.min.js +++ b/docgen/json/templates/cyclonedx/schema_doc.min.js @@ -1 +1 @@ -function flashElement(t){myElement=document.getElementById(t),myElement.classList.add("jsfh-animated-property"),setTimeout(function(){myElement.classList.remove("jsfh-animated-property")},1e3)}function setAnchor(t){history.pushState({},"",t)}function anchorOnLoad(){let t=window.location.hash.split("?")[0].split("&")[0];"#"===t[0]&&(t=t.substr(1)),t.length>0&&anchorLink(t)}function anchorLink(t){$("#"+t).parents().addBack().filter(".collapse:not(.show), .tab-pane, [role='tab']").each(function(t){if($(this).hasClass("collapse"))$(this).collapse("show");else if($(this).hasClass("tab-pane")){const t=$("a[href='#"+$(this).attr("id")+"']");t&&t.tab("show")}else"tab"===$(this).attr("role")&&$(this).tab("show")}),setTimeout(function(){let e=document.getElementById(t);e&&(e.scrollIntoView({block:"center",behavior:"smooth"}),setTimeout(function(){flashElement(t)},500))},1e3)}$(document).on("click",'a[href^="#"]',function(t){t.preventDefault(),history.pushState({},"",this.href)}); \ No newline at end of file +function flashElement(t){(myElement=document.getElementById(t)).classList.add("jsfh-animated-property"),setTimeout(function(){myElement.classList.remove("jsfh-animated-property")},1e3)}function setAnchor(t){history.pushState({},"",t)}function anchorOnLoad(){let t=decodeURIComponent(window.location.hash.split("?")[0].split("&")[0]);"#"===t[0]&&(t=t.substr(1)),t.length>0&&anchorLink(t)}function anchorLink(t){let e=$("#"+t);e.parents().addBack().filter(".collapse:not(.show), .tab-pane, [role='tab']").each(function(t){if($(this).hasClass("collapse"))$(this).collapse("show");else if($(this).hasClass("tab-pane")){let e=$("a[href='#"+$(this).attr("id")+"']");e&&e.tab("show")}else"tab"===$(this).attr("role")&&$(this).tab("show")}),setTimeout(function(){let e=document.getElementById(t);e&&(e.scrollIntoView({block:"center",behavior:"smooth"}),setTimeout(function(){flashElement(t)},500))},1e3)}$(document).on("click",'a[href^="#"]',function(t){t.preventDefault(),history.pushState({},"",this.href)}); \ No newline at end of file diff --git a/docgen/json/templates/cyclonedx/section_array.html b/docgen/json/templates/cyclonedx/section_array.html index 1aad2e0f..15489a4b 100644 --- a/docgen/json/templates/cyclonedx/section_array.html +++ b/docgen/json/templates/cyclonedx/section_array.html @@ -7,6 +7,9 @@ {%- if schema.kw_unique_items and schema.kw_unique_items.literal == True -%} {{ restriction("All items must be unique", "unique-items", schema.kw_unique_items.html_id) }} {%- endif -%} +{%- if not schema.array_additional_items -%} + {{ " " }}No Additional Items +{%- endif -%} {%- if schema.array_items_def -%}

Each item of this array must be:

@@ -34,4 +37,12 @@

At least one of the items must be:

{{ content(schema.kw_contains) }}
+{%- endif -%} +{%- if schema.array_additional_items_def -%} +

All other items must be:

+
+
+ {{ content(schema.array_additional_items_def) }} +
+
{%- endif -%} \ No newline at end of file