Skip to content

Commit

Permalink
# Conflicts:
Browse files Browse the repository at this point in the history
#	schema/bom-1.6.schema.json
#	tools/src/test/js/json-schema-lint-tests.js
  • Loading branch information
stevespringett committed Jan 15, 2024
1 parent 76bf8f9 commit 1302628
Show file tree
Hide file tree
Showing 17 changed files with 2,832 additions and 189 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
run: ./gen.sh
- name: Archive Schema documentation
# https://github.com/actions/upload-artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: XML-Schema-documentation
path: docgen/xml/docs
Expand All @@ -53,7 +53,7 @@ jobs:
run: ./gen.sh
- name: Archive Schema documentation
# https://github.com/actions/upload-artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: JSON-Schema-documentation
path: docgen/json/docs
Expand Down
15 changes: 15 additions & 0 deletions docgen/ecma/gen.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
rm -f -R docs temp out
mkdir -p docs temp
cp ../../schema/bom-1.6.schema.json temp
cp ../../schema/jsf-0.82.schema.json temp
cp ../../schema/spdx.schema.json temp

# Check to see if jsonschema2md is executable and is in the path. If not, install jsonschema2md.
if ! [ -x "$(command -v jsonschema2md)" ]; then
npm install -g @adobe/jsonschema2md
fi

echo Generating Ecma Documentation
jsonschema2md -d temp -o docs
rm -f -R temp out
2 changes: 1 addition & 1 deletion docgen/json/gen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
138 changes: 70 additions & 68 deletions docgen/json/templates/cyclonedx/content.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,17 @@

{# Display type #}
{%- if not schema is combining -%}
<span class="badge value-type">Type: {{ type_name }}</span>
<span class="badge badge-dark value-type">Type: {{ type_name }}</span>
{%- endif -%}

{%- if schema.format -%}
<span class="badge badge-info value-type">Format: {{ schema.format }}</span>
{%- endif -%}

{# Display default #}
{%- set default_value = schema.default_value -%}
{%- if default_value -%}
{{ " " }}<span class="badge default-value">Default: {{ default_value }}</span>
{{ " " }}<span class="badge badge-success default-value">Default: {{ default_value }}</span>
{%- endif -%}
<br/>

Expand All @@ -37,80 +41,78 @@
{%- 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 -%}
{{ " " }}<span class="badge no-additional">No Additional Properties</span>
{%- endif -%}

{# Combining: allOf, anyOf, oneOf, not #}
{%- if schema.kw_all_of -%}
<div class="all-of-value" id="{{ schema.kw_all_of.html_id }}">{{ tabbed_section("allOf", schema.kw_all_of) }}</div>
{%- endif -%}
{%- if schema.kw_any_of -%}
<div class="any-of-value" id="{{ schema.kw_any_of.html_id }}">{{ tabbed_section("anyOf", schema.kw_any_of) }}</div>
{%- endif -%}
{%- if schema.kw_one_of -%}
<div class="one-of-value" id="{{ schema.kw_one_of.html_id }}">{{ tabbed_section("oneOf", schema.kw_one_of) }}</div>
{%- endif -%}
{%- if schema.kw_not -%}
{% include "section_not.html" %}
{%- endif -%}

{# Enum and const #}
{%- if schema.kw_enum -%}
<div class="enum-value" id="{{ schema.kw_enum.html_id }}">
<h4>Must be one of:</h4>
<ul class="list-group">
{%- for enum_choice in schema.kw_enum.array_items -%}
<li class="list-group-item enum-item">{{ enum_choice.literal | python_to_json }}</li>
{%- endfor -%}
</ul>
</div>
{%- endif -%}
{%- if schema.kw_const -%}
<span class="const-value" id="{{ schema.kw_const.html_id }}">Specific value: <code>{{ schema.kw_const.raw | python_to_json }}</code></span>
{%- endif -%}
{%- if schema.explicit_no_additional_properties -%}
{{ " " }}<span class="badge badge-info no-additional">No Additional Properties</span>
{%- endif -%}

{# Pattern (Regular Expression) #}
{%- if schema.kw_pattern -%}
<span class="pattern-value" id="{{ schema.kw_pattern.html_id }}">Must match regular expression: <code>{{ schema.kw_pattern.literal | escape }}</code></span>
{%- endif -%}
{# Combining: allOf, anyOf, oneOf, not #}
{%- if schema.kw_all_of -%}
<div class="all-of-value" id="{{ schema.kw_all_of.html_id }}">{{ tabbed_section("allOf", schema.kw_all_of) }}</div>
{%- endif -%}
{%- if schema.kw_any_of -%}
<div class="any-of-value" id="{{ schema.kw_any_of.html_id }}">{{ tabbed_section("anyOf", schema.kw_any_of) }}</div>
{%- endif -%}
{%- if schema.kw_one_of -%}
<div class="one-of-value" id="{{ schema.kw_one_of.html_id }}">{{ tabbed_section("oneOf", schema.kw_one_of) }}</div>
{%- 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 -%}
<div class="enum-value" id="{{ schema.kw_enum.html_id }}">
<h4>Must be one of:</h4>
<ul class="list-group">
{%- for enum_choice in schema.kw_enum.array_items -%}
<li class="list-group-item enum-item">
{%- if schema.kw_meta_enum -%}<strong>{%- endif -%}
{{ enum_choice.literal | python_to_json }}
{%- if schema.kw_meta_enum -%}</strong>
: {{ (schema.enum_description(enum_choice.literal) | get_description_literal) }}
{%- endif -%}
</li>
{%- endfor -%}
</ul>
</div>
{%- endif -%}
{%- if schema.kw_const -%}
<span class="const-value" id="{{ schema.kw_const.html_id }}">Specific value: <code>{{ schema.kw_const.raw | python_to_json }}</code></span>
{%- 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 -%}
<span class="pattern-value" id="{{ schema.kw_pattern.html_id }}">Must match regular expression: <code>{{ schema.kw_pattern.literal | escape }}</code></span>
{%- 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 -%}
4 changes: 2 additions & 2 deletions docgen/json/templates/cyclonedx/schema_doc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion docgen/json/templates/cyclonedx/schema_doc.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions docgen/json/templates/cyclonedx/section_array.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 -%}
{{ " " }}<span class="badge badge-info no-additional">No Additional Items</span>
{%- endif -%}
{%- if schema.array_items_def -%}
<h4>Each item of this array must be:</h4>
<div class="card">
Expand Down Expand Up @@ -34,4 +37,12 @@ <h4>At least one of the items must be:</h4>
{{ content(schema.kw_contains) }}
</div>
</div>
{%- endif -%}
{%- if schema.array_additional_items_def -%}
<h4>All other items must be:</h4>
<div class="card">
<div class="card-body items-contain-definition" id="{{ schema.array_additional_items_def.html_id }}">
{{ content(schema.array_additional_items_def) }}
</div>
</div>
{%- endif -%}
Loading

0 comments on commit 1302628

Please sign in to comment.