Added Builder

This commit is contained in:
Ben C 2022-03-01 22:46:02 -05:00
parent b691b71b22
commit 08ad3a176a
21 changed files with 813 additions and 0 deletions

View File

@ -0,0 +1,2 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/UserDictionary/Words/=RINGWORLD/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>

13
docs/Pipfile Normal file
View File

@ -0,0 +1,13 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
jinja2 = "*"
json-schema-for-humans = "*"
[dev-packages]
[requires]
python_version = "3.10"

252
docs/Pipfile.lock generated Normal file
View File

@ -0,0 +1,252 @@
{
"_meta": {
"hash": {
"sha256": "b4acdc18f2bf25fdf7a2448229884300b7e3ec47731a49ad482b21d32c627370"
},
"pipfile-spec": 6,
"requires": {
"python_version": "3.10"
},
"sources": [
{
"name": "pypi",
"url": "https://pypi.org/simple",
"verify_ssl": true
}
]
},
"default": {
"certifi": {
"hashes": [
"sha256:78884e7c1d4b00ce3cea67b44566851c4343c120abd683433ce934a68ea58872",
"sha256:d62a0163eb4c2344ac042ab2bdf75399a71a2d8c7d47eac2e2ee91b9d6339569"
],
"version": "==2021.10.8"
},
"charset-normalizer": {
"hashes": [
"sha256:2857e29ff0d34db842cd7ca3230549d1a697f96ee6d3fb071cfa6c7393832597",
"sha256:6881edbebdb17b39b4eaaa821b438bf6eddffb4468cf344f09f89def34a8b1df"
],
"markers": "python_version >= '3'",
"version": "==2.0.12"
},
"click": {
"hashes": [
"sha256:6a7a62563bbfabfda3a38f3023a1db4a35978c0abd76f6c9605ecd6554d6d9b1",
"sha256:8458d7b1287c5fb128c90e23381cf99dcde74beaf6c7ff6384ce84d6fe090adb"
],
"markers": "python_version >= '3.6'",
"version": "==8.0.4"
},
"colorama": {
"hashes": [
"sha256:5941b2b48a20143d2267e95b1c2a7603ce057ee39fd88e7329b0c292aa16869b",
"sha256:9f47eda37229f68eee03b24b9748937c7dc3868f906e8ba69fbcbdd3bc5dc3e2"
],
"markers": "platform_system == 'Windows'",
"version": "==0.4.4"
},
"dataclasses-json": {
"hashes": [
"sha256:1d7f3a284a49d350ddbabde0e7d0c5ffa34a144aaf1bcb5b9f2c87673ff0c76e",
"sha256:1f60be3405dee30b86ffbf6a436db8ba5efaeeb676bfda358e516a97aa7dfce4"
],
"markers": "python_version >= '3.6'",
"version": "==0.5.6"
},
"htmlmin": {
"hashes": [
"sha256:50c1ef4630374a5d723900096a961cff426dff46b48f34d194a81bbe14eca178"
],
"version": "==0.1.12"
},
"idna": {
"hashes": [
"sha256:84d9dd047ffa80596e0f246e2eab0b391788b0503584e8945f2368256d2735ff",
"sha256:9d643ff0a55b762d5cdb124b8eaa99c66322e2157b69160bc32796e824360e6d"
],
"markers": "python_version >= '3'",
"version": "==3.3"
},
"jinja2": {
"hashes": [
"sha256:077ce6014f7b40d03b47d1f1ca4b0fc8328a692bd284016f806ed0eaca390ad8",
"sha256:611bb273cd68f3b993fabdc4064fc858c5b47a973cb5aa7999ec1ba405c87cd7"
],
"index": "pypi",
"version": "==3.0.3"
},
"json-schema-for-humans": {
"hashes": [
"sha256:2272e053e7b44961c79d22628eca9c475bd3984b99401a4184ae8f4224df296a",
"sha256:986158ae543d6aae5df6bb1dbc9e23f45a374fd7e9da5165ddcd9a7596b877e7"
],
"index": "pypi",
"version": "==0.40"
},
"markdown2": {
"hashes": [
"sha256:8f4ac8d9a124ab408c67361090ed512deda746c04362c36c2ec16190c720c2b0",
"sha256:91113caf23aa662570fe21984f08fe74f814695c0a0ea8e863a8b4c4f63f9f6e"
],
"markers": "python_version >= '3.5' and python_version < '4'",
"version": "==2.4.2"
},
"markupsafe": {
"hashes": [
"sha256:023af8c54fe63530545f70dd2a2a7eed18d07a9a77b94e8bf1e2ff7f252db9a3",
"sha256:09c86c9643cceb1d87ca08cdc30160d1b7ab49a8a21564868921959bd16441b8",
"sha256:142119fb14a1ef6d758912b25c4e803c3ff66920635c44078666fe7cc3f8f759",
"sha256:1d1fb9b2eec3c9714dd936860850300b51dbaa37404209c8d4cb66547884b7ed",
"sha256:204730fd5fe2fe3b1e9ccadb2bd18ba8712b111dcabce185af0b3b5285a7c989",
"sha256:24c3be29abb6b34052fd26fc7a8e0a49b1ee9d282e3665e8ad09a0a68faee5b3",
"sha256:290b02bab3c9e216da57c1d11d2ba73a9f73a614bbdcc027d299a60cdfabb11a",
"sha256:3028252424c72b2602a323f70fbf50aa80a5d3aa616ea6add4ba21ae9cc9da4c",
"sha256:30c653fde75a6e5eb814d2a0a89378f83d1d3f502ab710904ee585c38888816c",
"sha256:3cace1837bc84e63b3fd2dfce37f08f8c18aeb81ef5cf6bb9b51f625cb4e6cd8",
"sha256:4056f752015dfa9828dce3140dbadd543b555afb3252507348c493def166d454",
"sha256:454ffc1cbb75227d15667c09f164a0099159da0c1f3d2636aa648f12675491ad",
"sha256:598b65d74615c021423bd45c2bc5e9b59539c875a9bdb7e5f2a6b92dfcfc268d",
"sha256:599941da468f2cf22bf90a84f6e2a65524e87be2fce844f96f2dd9a6c9d1e635",
"sha256:5ddea4c352a488b5e1069069f2f501006b1a4362cb906bee9a193ef1245a7a61",
"sha256:62c0285e91414f5c8f621a17b69fc0088394ccdaa961ef469e833dbff64bd5ea",
"sha256:679cbb78914ab212c49c67ba2c7396dc599a8479de51b9a87b174700abd9ea49",
"sha256:6e104c0c2b4cd765b4e83909cde7ec61a1e313f8a75775897db321450e928cce",
"sha256:736895a020e31b428b3382a7887bfea96102c529530299f426bf2e636aacec9e",
"sha256:75bb36f134883fdbe13d8e63b8675f5f12b80bb6627f7714c7d6c5becf22719f",
"sha256:7d2f5d97fcbd004c03df8d8fe2b973fe2b14e7bfeb2cfa012eaa8759ce9a762f",
"sha256:80beaf63ddfbc64a0452b841d8036ca0611e049650e20afcb882f5d3c266d65f",
"sha256:84ad5e29bf8bab3ad70fd707d3c05524862bddc54dc040982b0dbcff36481de7",
"sha256:8da5924cb1f9064589767b0f3fc39d03e3d0fb5aa29e0cb21d43106519bd624a",
"sha256:961eb86e5be7d0973789f30ebcf6caab60b844203f4396ece27310295a6082c7",
"sha256:96de1932237abe0a13ba68b63e94113678c379dca45afa040a17b6e1ad7ed076",
"sha256:a0a0abef2ca47b33fb615b491ce31b055ef2430de52c5b3fb19a4042dbc5cadb",
"sha256:b2a5a856019d2833c56a3dcac1b80fe795c95f401818ea963594b345929dffa7",
"sha256:b8811d48078d1cf2a6863dafb896e68406c5f513048451cd2ded0473133473c7",
"sha256:c532d5ab79be0199fa2658e24a02fce8542df196e60665dd322409a03db6a52c",
"sha256:d3b64c65328cb4cd252c94f83e66e3d7acf8891e60ebf588d7b493a55a1dbf26",
"sha256:d4e702eea4a2903441f2735799d217f4ac1b55f7d8ad96ab7d4e25417cb0827c",
"sha256:d5653619b3eb5cbd35bfba3c12d575db2a74d15e0e1c08bf1db788069d410ce8",
"sha256:d66624f04de4af8bbf1c7f21cc06649c1c69a7f84109179add573ce35e46d448",
"sha256:e67ec74fada3841b8c5f4c4f197bea916025cb9aa3fe5abf7d52b655d042f956",
"sha256:e6f7f3f41faffaea6596da86ecc2389672fa949bd035251eab26dc6697451d05",
"sha256:f02cf7221d5cd915d7fa58ab64f7ee6dd0f6cddbb48683debf5d04ae9b1c2cc1",
"sha256:f0eddfcabd6936558ec020130f932d479930581171368fd728efcfb6ef0dd357",
"sha256:fabbe18087c3d33c5824cb145ffca52eccd053061df1d79d4b66dafa5ad2a5ea",
"sha256:fc3150f85e2dbcf99e65238c842d1cfe69d3e7649b19864c1cc043213d9cd730"
],
"markers": "python_version >= '3.7'",
"version": "==2.1.0"
},
"marshmallow": {
"hashes": [
"sha256:04438610bc6dadbdddb22a4a55bcc7f6f8099e69580b2e67f5a681933a1f4400",
"sha256:4c05c1684e0e97fe779c62b91878f173b937fe097b356cd82f793464f5bc6138"
],
"markers": "python_version >= '3.6'",
"version": "==3.14.1"
},
"marshmallow-enum": {
"hashes": [
"sha256:38e697e11f45a8e64b4a1e664000897c659b60aa57bfa18d44e226a9920b6e58",
"sha256:57161ab3dbfde4f57adeb12090f39592e992b9c86d206d02f6bd03ebec60f072"
],
"version": "==1.5.1"
},
"mypy-extensions": {
"hashes": [
"sha256:090fedd75945a69ae91ce1303b5824f428daf5a028d2f6ab8a299250a846f15d",
"sha256:2d82818f5bb3e369420cb3c4060a7970edba416647068eb4c5343488a6c604a8"
],
"version": "==0.4.3"
},
"pygments": {
"hashes": [
"sha256:44238f1b60a76d78fc8ca0528ee429702aae011c265fe6a8dd8b63049ae41c65",
"sha256:4e426f72023d88d03b2fa258de560726ce890ff3b630f88c21cbb8b2503b8c6a"
],
"markers": "python_version >= '3.5'",
"version": "==2.11.2"
},
"pytz": {
"hashes": [
"sha256:3672058bc3453457b622aab7a1c3bfd5ab0bdae451512f6cf25f64ed37f5b87c",
"sha256:acad2d8b20a1af07d4e4c9d2e9285c5ed9104354062f275f3fcd88dcef4f1326"
],
"version": "==2021.3"
},
"pyyaml": {
"hashes": [
"sha256:0283c35a6a9fbf047493e3a0ce8d79ef5030852c51e9d911a27badfde0605293",
"sha256:055d937d65826939cb044fc8c9b08889e8c743fdc6a32b33e2390f66013e449b",
"sha256:07751360502caac1c067a8132d150cf3d61339af5691fe9e87803040dbc5db57",
"sha256:0b4624f379dab24d3725ffde76559cff63d9ec94e1736b556dacdfebe5ab6d4b",
"sha256:0ce82d761c532fe4ec3f87fc45688bdd3a4c1dc5e0b4a19814b9009a29baefd4",
"sha256:1e4747bc279b4f613a09eb64bba2ba602d8a6664c6ce6396a4d0cd413a50ce07",
"sha256:213c60cd50106436cc818accf5baa1aba61c0189ff610f64f4a3e8c6726218ba",
"sha256:231710d57adfd809ef5d34183b8ed1eeae3f76459c18fb4a0b373ad56bedcdd9",
"sha256:277a0ef2981ca40581a47093e9e2d13b3f1fbbeffae064c1d21bfceba2030287",
"sha256:2cd5df3de48857ed0544b34e2d40e9fac445930039f3cfe4bcc592a1f836d513",
"sha256:40527857252b61eacd1d9af500c3337ba8deb8fc298940291486c465c8b46ec0",
"sha256:473f9edb243cb1935ab5a084eb238d842fb8f404ed2193a915d1784b5a6b5fc0",
"sha256:48c346915c114f5fdb3ead70312bd042a953a8ce5c7106d5bfb1a5254e47da92",
"sha256:50602afada6d6cbfad699b0c7bb50d5ccffa7e46a3d738092afddc1f9758427f",
"sha256:68fb519c14306fec9720a2a5b45bc9f0c8d1b9c72adf45c37baedfcd949c35a2",
"sha256:77f396e6ef4c73fdc33a9157446466f1cff553d979bd00ecb64385760c6babdc",
"sha256:819b3830a1543db06c4d4b865e70ded25be52a2e0631ccd2f6a47a2822f2fd7c",
"sha256:897b80890765f037df3403d22bab41627ca8811ae55e9a722fd0392850ec4d86",
"sha256:98c4d36e99714e55cfbaaee6dd5badbc9a1ec339ebfc3b1f52e293aee6bb71a4",
"sha256:9df7ed3b3d2e0ecfe09e14741b857df43adb5a3ddadc919a2d94fbdf78fea53c",
"sha256:9fa600030013c4de8165339db93d182b9431076eb98eb40ee068700c9c813e34",
"sha256:a80a78046a72361de73f8f395f1f1e49f956c6be882eed58505a15f3e430962b",
"sha256:b3d267842bf12586ba6c734f89d1f5b871df0273157918b0ccefa29deb05c21c",
"sha256:b5b9eccad747aabaaffbc6064800670f0c297e52c12754eb1d976c57e4f74dcb",
"sha256:c5687b8d43cf58545ade1fe3e055f70eac7a5a1a0bf42824308d868289a95737",
"sha256:cba8c411ef271aa037d7357a2bc8f9ee8b58b9965831d9e51baf703280dc73d3",
"sha256:d15a181d1ecd0d4270dc32edb46f7cb7733c7c508857278d3d378d14d606db2d",
"sha256:d4db7c7aef085872ef65a8fd7d6d09a14ae91f691dec3e87ee5ee0539d516f53",
"sha256:d4eccecf9adf6fbcc6861a38015c2a64f38b9d94838ac1810a9023a0609e1b78",
"sha256:d67d839ede4ed1b28a4e8909735fc992a923cdb84e618544973d7dfc71540803",
"sha256:daf496c58a8c52083df09b80c860005194014c3698698d1a57cbcfa182142a3a",
"sha256:e61ceaab6f49fb8bdfaa0f92c4b57bcfbea54c09277b1b4f7ac376bfb7a7c174",
"sha256:f84fbc98b019fef2ee9a1cb3ce93e3187a6df0b2538a651bfb890254ba9f90b5"
],
"markers": "python_version >= '3.6'",
"version": "==6.0"
},
"requests": {
"hashes": [
"sha256:68d7c56fd5a8999887728ef304a6d12edc7be74f1cfa47714fc8b414525c9a61",
"sha256:f22fa1e554c9ddfd16e6e41ac79759e17be9e492b3587efa038054674760e72d"
],
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4, 3.5'",
"version": "==2.27.1"
},
"typing-extensions": {
"hashes": [
"sha256:1a9462dcc3347a79b1f1c0271fbe79e844580bb598bafa1ed208b94da3cdcd42",
"sha256:21c85e0fe4b9a155d0799430b0ad741cdce7e359660ccbd8b530613e8df88ce2"
],
"markers": "python_version >= '3.6'",
"version": "==4.1.1"
},
"typing-inspect": {
"hashes": [
"sha256:047d4097d9b17f46531bf6f014356111a1b6fb821a24fe7ac909853ca2a782aa",
"sha256:3cd7d4563e997719a710a3bfe7ffb544c6b72069b6812a02e9b414a8fa3aaa6b",
"sha256:b1f56c0783ef0f25fb064a01be6e5407e54cf4a4bf4f3ba3fe51e0bd6dcea9e5"
],
"version": "==0.7.1"
},
"urllib3": {
"hashes": [
"sha256:000ca7f471a233c2251c6c7023ee85305721bfdf18621ebff4fd17a8653427ed",
"sha256:0e7c33d9a63e7ddfcb86780aac87befc2fbddf46c58dbb487e0855f7ceec283c"
],
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4' and python_version < '4'",
"version": "==1.26.8"
}
},
"develop": {}
}

View File

View File

@ -0,0 +1,14 @@
{% if type_name == "string" %}
{% if schema.kw_min_length %}
{{ restriction("Must be at least <code>" ~ schema.kw_min_length.literal ~ "</code> characters long", "min-length", schema.kw_min_length.html_id) }}
{% endif %}
{% if schema.kw_max_length %}
{{ restriction("Must be at most <code>" ~ schema.kw_max_length.literal ~ "</code> characters long", "max-length", schema.kw_max_length.html_id) }}
{% endif %}
{% endif %}
{% if type_name in ["integer", "number"] %}
{% set restriction_text = (schema | get_numeric_restrictions_text("<code>", "</code>")) %}
{% if restriction_text %}
{{ restriction(schema | get_numeric_restrictions_text("<code>", "</code>"), "numeric", schema.html_id ~ "_number") }}
{% endif %}
{% endif %}

View File

@ -0,0 +1,50 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>New Horizons Documentation | {{ page.title|title }}</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap-dark-5@1.1.3/dist/css/bootstrap-night.min.css"
crossorigin="anonymous" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js"
integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM"
crossorigin="anonymous"></script>
</head>
<body>
<header>
<nav class="navbar navbar-expand-lg navbar-light bg-light mb-2">
<div class="container-fluid">
<a class="navbar-brand" href="/">New Horizons</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse"
data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent"
aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="/">Home</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button"
data-bs-toggle="dropdown" aria-expanded="false">
Schemas
</a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdown">
{% for schema in schemas %}
<li><a class="dropdown-item"
href="schemas/{{ schema.out_name }}.html">{{ schema.title|title }}</a></li>
{% endfor %}
</ul>
</li>
</ul>
</div>
</div>
</nav>
<main>
<div class="container-fluid">
{% block content %} {% endblock %}
</div>
</main>
</header>
</body>
</html>

View File

@ -0,0 +1,17 @@
<div class="breadcrumbs">
{%- for node in schema.nodes_from_root -%}
{%- if loop.first -%}
root
{%- else -%}
<a href="#{{ node.html_id }}" onclick="anchorLink('{{ node.html_id }}')">{{ node.name_for_breadcrumbs | lowerfirst }}</a>
{%- endif -%}
{%- if not loop.last %}
<svg width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-arrow-right-short" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
<path
fill-rule="evenodd"
d="M4 8a.5.5 0 0 1 .5-.5h5.793L8.146 5.354a.5.5 0 1 1 .708-.708l3 3a.5.5 0 0 1 0 .708l-3 3a.5.5 0 0 1-.708-.708L10.293 8.5H4.5A.5.5 0 0 1 4 8z"
/>
</svg>
{% endif -%}
{%- endfor -%}
</div>

View File

@ -0,0 +1,121 @@
{% from "macro_restriction.html" import restriction with context %}
{% macro tabbed_section(operator, current_node) %}
{% include "tabbed_section.html" %}
{% endmacro %}
{% macro content(schema, skip_headers=False) %}
{% set keys = schema.keywords %}
{# Resolve type #}
{% set type_name = schema.type_name %}
{% if not skip_headers %}
{% if config.show_breadcrumbs %}
{% include "breadcrumbs.html" %}
{% endif %}
{# Display type #}
{% if not schema is combining %}
<div class="row">
<div class="col">
<span class="badge bg-secondary">Type: {{ type_name }}</span>
</div>
</div>
{% endif %}
{# Display default #}
{% set default_value = schema.default_value %}
{% if default_value %}
<div class="row">
<div class="col">
{{ " " }}<span class="badge bg-secondary">Default: {{ default_value }}</span>
</div>
</div>
{% endif %}
<br/>
{% set description = (schema | get_description) %}
{% include "section_description.html" %}
{% endif %}
{% if schema.should_be_a_link(config) %}
<a href="#{{ schema.links_to.html_id }}" onclick="anchorLink('{{ schema.links_to.html_id }}')" class="ref-link">Same definition as {{ schema.links_to.link_name }}</a>
{% 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 badge-info 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 %}
{# 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 %}
{# Conditional subschema, or if-then-else section #}
{% if schema.has_conditional %}
{% include "section_conditional_subschema.html" %}
{% endif %}
{# Required properties that are not defined under "properties". They will only be listed #}
{% include "section_undocumented_required_properties.html" %}
{# Show the requested type(s) #}
{% include "badge_type.html" %}
{# 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 %}
{% include "section_properties.html" %}
{% endfor %}
{% endif %}
{% endif %}
{% endmacro %}

View File

@ -0,0 +1,15 @@
{% extends "base.jinja2" %}
{% block content %}
<div class="row">
<div class="col">
<h1>Welcome!</h1>
</div>
</div>
<div class="row">
<div class="col">
<p>This is the official documentation for New Horizons</p>
</div>
</div>
{% endblock %}

View File

@ -0,0 +1,3 @@
{%- macro restriction(inner_text, css_class_name, html_id) -%}
<p><span class="badge bg-dark restriction {{ css_class_name }}-restriction" id="{{ html_id }}">{{ inner_text }}</span></p>
{%- endmacro -%}

View File

@ -0,0 +1,15 @@
{% extends "base.jinja2" %}
{% from 'content.html' import content with context %}
{% block content %}
<div class="row">
<div class="col text-center">
<h1>{{ title|title }}</h1>
</div>
</div>
<div class="row">
<div class="col">
{{ content(schema) }}
</div>
</div>
{% endblock %}

View File

@ -0,0 +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)});

View File

@ -0,0 +1,36 @@
{%- if schema.kw_min_items -%}
{{ restriction("Must contain a minimum of <code>" ~ schema.kw_min_items.literal ~ "</code> items", "min-items", schema.kw_min_items.html_id) }}
{%- endif -%}
{%- if schema.kw_max_items -%}
{{ restriction("Must contain a maximum of <code>" ~ schema.kw_max_items.literal ~ "</code> items", "max-items", schema.kw_max_items.html_id) }}
{%- endif -%}
{%- 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 schema.array_items_def -%}
<h4>Each item of this array must be:</h4>
<div class="card">
<div class="card-body items-definition" id="{{ schema.array_items_def.html_id }}">
{{ content(schema.array_items_def) }}
</div>
</div>
{%- endif -%}
{%- if schema.tuple_validation_items -%}
<h4>Tuple Validation</h4>
{% for item in schema.tuple_validation_items %}
<h5>Item at {{ loop.index }} must be:</h5>
<div class="card">
<div class="card-body items-definition" id="{{ item.html_id }}">
{{ content(item) }}
</div>
</div>
{% endfor %}
{%- endif -%}
{%- if schema.kw_contains and schema.kw_contains.literal != {} -%}
<h4>At least one of the items must be:</h4>
<div class="card">
<div class="card-body items-contain-definition" id="{{ schema.kw_contains.html_id }}">
{{ content(schema.kw_contains) }}
</div>
</div>
{%- endif -%}

View File

@ -0,0 +1,58 @@
<h2 class="handle">
<label>Conditional Subschema</label>
</h2>
<p>If the conditions in the "If" tab are respected, then the conditions in the "Then" tab should be respected.
Otherwise, the conditions in the "Else" tab should be respected.</p>
<ul class="nav nav-tabs" id="{{ schema.html_id }}_condition_tabs" role="tablist">
{% set tab_id = schema.kw_if.html_id %}
<li class="nav-item">
<a class="nav-link active"
id="{{ tab_id }}" data-toggle="tab" href="#tab-pane_{{ tab_id }}" role="tab"
onclick="setAnchor('#{{ tab_id }}')"
>If</a>
</li>
{% if schema.kw_then %}
{% set tab_id = schema.kw_then.html_id %}
<li class="nav-item">
<a class="nav-link"
id="{{ tab_id }}" data-toggle="tab" href="#tab-pane_{{ tab_id }}" role="tab"
onclick="setAnchor('#{{ tab_id }}')"
>Then</a>
</li>
{%- endif -%}
{%- if schema.kw_else -%}
{%- set tab_id = schema.kw_else.html_id -%}
<li class="nav-item">
<a class="nav-link"
id="{{ tab_id }}" data-toggle="tab" href="#tab-pane_{{ tab_id }}" role="tab"
onclick="setAnchor('#{{ tab_id }}')"
>Else</a>
</li>
{%- endif -%}
</ul>
<div class="tab-content card">
{% set tab_id = schema.kw_if.html_id %}
<div class="tab-pane fade card-body active show"
id="tab-pane_{{ tab_id }}" role="tabpanel">
{{ content(schema.kw_if) }}
</div>
{% if schema.kw_then %}
{% set tab_id = schema.kw_then.html_id %}
<div class="tab-pane fade card-body"
id="tab-pane_{{ tab_id }}" role="tabpanel">
{{ content(schema.kw_then) }}
</div>
{%- endif -%}
{%- if schema.kw_else -%}
{% set tab_id = schema.kw_else.html_id %}
<div class="tab-pane fade card-body"
id="tab-pane_{{ tab_id }}" role="tabpanel">
{{ content(schema.kw_else) }}
</div>
{%- endif -%}
</div>

View File

@ -0,0 +1,20 @@
{# Display description #}
{% if description %}
<div class="row">
<div class="col">
{% if not config.collapse_long_descriptions or description is description_short %}
<span class="description">{{ description }}</span>
{% else %}
<div class="description collapse" id="collapseDescription_{{ schema.html_id }}">
{{ description }}
</div>
<div>
<a class="collapse-description-link collapsed" data-toggle="collapse"
href="#collapseDescription_{{ schema.html_id }}"
aria-expanded="false" aria-controls="collapseDescription{{ schema.html_id }}"
></a>
</div>
{% endif %}
</div>
</div>
{% endif %}

View File

@ -0,0 +1,18 @@
<br/>
<div class="badge badge-secondary">Example{% if examples|length > 1 %}s{% endif %}:</div>
<br/>
{%- for example in examples -%}
{%- set example_id = schema.html_id ~ "_ex" ~ loop.index -%}
{%- set example_is_long = example is not description_short -%}
{%- if example_is_long -%}
<button class="btn btn-light example-show collapsed" data-toggle="collapse" data-target="#{{ example_id }}" aria-controls="{{ example_id }}"></button>
{%- endif -%}
<div id="{{ example_id }}" class="{% if example_is_long %}collapse {% endif %}jumbotron examples">
{%- if not examples_as_yaml -%}
{{ example | highlight_json_example }}
{%- else -%}
{{ example | highlight_yaml_example }}
{%- endif -%}
</div>
{%- endfor -%}

View File

@ -0,0 +1,8 @@
<div class="not-value">
<h4>Must <strong>not</strong> be:</h4>
<div class="card">
<div class="card-body" id="{{ card_id }}">
{{ content(schema.kw_not) }}
</div>
</div>
</div>

View File

@ -0,0 +1,62 @@
{% set html_id = sub_property.html_id %}
<div class="row my-2">
<div class="col">
<div class="accordion" id="accordion{{ html_id }}">
<div class="accordion-item">
<h2 class="accordion-header" id="heading{{ html_id }}">
<button class="accordion-button{% if not expanded %} collapsed{% endif %}" type="button"
data-bs-toggle="collapse"
data-bs-target="#{{ html_id }}"
aria-expanded="{{ expanded }}" aria-controls="{{ html_id }}"
onclick="setAnchor('#{{ html_id }}')">
{% if sub_property.is_additional_properties %}
<em>
{% endif %}
<span class="property-nam align-middle pb-1">{{ sub_property.property_display_name | lowerfirst | escape }}</span>
{% if sub_property.is_additional_properties %}
</em>
{% endif %}
{% if sub_property.is_required_property %}
{{ " " }}<span class="badge bg-warning required-property">Required</span>
{% endif %}
{% if sub_property is deprecated %}
{{ " " }}<span class="badge bg-danger deprecated-property">Deprecated</span>
{% endif %}
{% if sub_property.is_pattern_property %}
{{ " " }}<span class="badge bg-info pattern-property">Pattern Property</span>
{% endif %}
</button>
</h2>
<div id="{{ html_id }}"
class="accordion-collapse collapse{% if expanded %} show{% endif %}"
aria-labelledby="heading{{ html_id }}"
data-parent="#accordion{{ html_id }}">
<div class="accordion-body">
{% if sub_property.is_pattern_property %}
<h2 class="handle">
<label>Pattern Property</label>
</h2>
<p>All property whose name matches the following regular expression must respect the
following
conditions</p>
<span class="pattern-value">Property name regular expression: <code>{{ sub_property.property_name | escape }}</code></span>
<br/>
{% endif %}
{% if sub_property.is_additional_properties %}
{% if sub_property.is_additional_properties_schema %}
<p class="additional-properties">Each additional property must conform to the following
schema</p>
{% else %}
<p class="additional-properties">Additional Properties of any type are allowed.</p>
{% endif %}
{% endif %}
{{ content(sub_property) }}
</div>
</div>
</div>
</div>
</div>
</div>

View File

@ -0,0 +1,11 @@
{%- set undocumented_required_properties = schema | get_undocumented_required_properties -%}
{%- if undocumented_required_properties-%}
<div class="enum-value">
<h4>The following properties are required:</h4>
<ul class="list-group">
{%- for required_property in undocumented_required_properties -%}
<li class="list-group-item required-property">{{ required_property }}</li>
{%- endfor -%}
</ul>
</div>
{%- endif -%}

View File

@ -0,0 +1,25 @@
<h2 class="handle">
<label>{% if operator == "allOf" -%}All of{% elif operator == "anyOf" -%}Any of{% elif operator == "oneOf" -%}One of{% endif -%}</label>
</h2>
{%- set tab_label = "Option" -%}
{%- if operator == "allOf" -%}
{%- set tab_label = "Requirement" -%}
{%- endif -%}
<ul class="nav nav-tabs" id="tabs{{ current_node.html_id }}_{{ operator }}" role="tablist">
{%- for node in current_node.array_items -%}
<li class="nav-item">
<a class="nav-link {% if loop.index == 1 -%}active {% endif -%} {{ operator }}-option"
id="{{ node.html_id }}" data-toggle="tab" href="#tab-pane_{{ node.html_id }}" role="tab"
onclick="setAnchor('#{{ node.html_id }}')"
>{{ node.definition_name or tab_label ~ " " ~ loop.index }}</a>
</li>
{%- endfor -%}
</ul>
<div class="tab-content card">
{%- for node in current_node.array_items -%}
<div class="tab-pane fade card-body {% if loop.index == 1 -%}active show{% endif -%}"
id="tab-pane_{{ node.html_id }}" role="tabpanel">
{{ content(node) }}
</div>
{%- endfor -%}
</div>

72
docs/generate.py Normal file
View File

@ -0,0 +1,72 @@
from dataclasses import dataclass
from pathlib import Path
from jinja2 import Environment, PackageLoader, select_autoescape
from json_schema_for_humans.schema.schema_importer import get_schemas_to_render
from json_schema_for_humans.generate import generate_from_filename, GenerationConfiguration, generate_schemas_doc, \
copy_additional_files_to_target
from json_schema_for_humans.template_renderer import TemplateRenderer, _minify
env = Environment(
loader=PackageLoader('docs_templates', 'templates'),
autoescape=select_autoescape(['jinja2'])
)
env.filters["lowerfirst"] = lambda x: x[0].lower() + x[1:]
home = env.get_template("base.jinja2")
@dataclass
class Page:
in_name: str
out_name: str
title: str
def render(self, **options):
template = env.get_template(self.in_name + ".jinja2")
options.update({'page': self})
rendered_string = template.render(**options)
with open("out/" + self.out_name + ".html", 'w+') as file:
file.write(rendered_string)
config = GenerationConfiguration(custom_template_path="docs_templates/templates/schema_base.jinja2")
config.link_to_reused_ref = False
@dataclass
class Schema(Page):
def render(self, **options):
schemas = get_schemas_to_render("schemas/" + self.in_name + ".json", Path("out/schemas/" + self.out_name + ".html"), ".html")
template_renderer = TemplateRenderer(config)
template_renderer.render = lambda inter: template_override(template_renderer, inter, self)
generate_schemas_doc(schemas, template_renderer)
copy_additional_files_to_target(schemas, config)
pages = (
Page(in_name="home", out_name="index", title="Home"),
Schema(in_name="schema", out_name="body_schema", title="Body"),
Schema(in_name="star_system_schema", out_name="star_system_schema", title="Star System"),
Schema(in_name="translation_schema", out_name="translation_schema", title="Translation")
)
schemas = [s for s in pages if s.__class__.__name__ == "Schema"]
def template_override(template, intermediate_schema, inter_page):
template.template.environment.filters["lowerfirst"] = env.filters["lowerfirst"]
rendered = template.template.render(schema=intermediate_schema, config=config, schemas=schemas, page=inter_page, title=inter_page.title + " Schema")
if template.config.minify:
rendered = _minify(rendered, template.config.template_is_markdown, template.config.template_is_html)
return rendered
for page in pages:
page.render(schemas=schemas)
print("Done")