From b8d6c4545a795bfb05a058439c201a18485b84f3 Mon Sep 17 00:00:00 2001 From: mrjk Date: Sat, 15 Jan 2022 17:46:54 -0500 Subject: [PATCH] Add: Doc autogeneration from schema --- docs/app_schema.json | 150 ++++++++++++++++++++++++++++++++++++++ docs/build_doc.sh | 31 ++++++++ docs/doc_config_html.yaml | 5 ++ docs/doc_config_md.yaml | 5 ++ 4 files changed, 191 insertions(+) create mode 100644 docs/app_schema.json create mode 100755 docs/build_doc.sh create mode 100644 docs/doc_config_html.yaml create mode 100644 docs/doc_config_md.yaml diff --git a/docs/app_schema.json b/docs/app_schema.json new file mode 100644 index 0000000..a58c00c --- /dev/null +++ b/docs/app_schema.json @@ -0,0 +1,150 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "additionalProperties": false, + "default": {}, + "$def": { + "backends_items": {}, + "backends_config": {}, + "rules_items": {}, + "rules_config": {} + }, + "patternProperties": { + ".*": { + "type": "object", + "optional": true, + "additionalProperties": false, + "properties": { + "config": { + "type": "object", + "default": { + "app": { + "root": null + }, + "tree": {}, + "rules": {} + }, + "additionalProperties": false, + "properties": { + "app": { + "type": "object", + "default": { + "root": null + }, + "additionalProperties": false, + "properties": { + "root": { + "type": "string", + "default": null + } + } + }, + "tree": { + "type": "object", + "default": {} + }, + "rules": { + "type": "object", + "default": {} + } + } + }, + "tree": { + "type": "array", + "default": [], + "items": { + "$schema": "http://json-schema.org/draft-07/schema#", + "default": "", + "$def": { + "items": {} + }, + "oneOf": [ + { + "type": "string", + "default": "BLAAAAHHH" + }, + { + "type": "object", + "additionalProperties": true, + "default": {}, + "properties": { + "schema": { + "default": null, + "optional": true, + "oneOf": [ + { + "type": "null" + }, + { + "type": "string" + }, + { + "type": "array" + }, + { + "type": "object", + "additionalProperties": true, + "default": {}, + "properties": { + "data": { + "default": null, + "optional": false, + "anyOf": [ + { + "type": "null" + }, + { + "type": "string" + }, + { + "type": "array" + } + ] + }, + "var": { + "type": "string", + "default": "loop_item", + "optional": true + } + } + } + ] + }, + "rule": { + "default": ".*", + "optional": true, + "oneOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ] + }, + "strategy": { + "type": "string", + "default": "schema", + "optional": true + }, + "trace": { + "type": "boolean", + "default": false + }, + "explain": { + "type": "boolean", + "default": false + } + } + } + ] + } + }, + "rules": { + "type": "array", + "default": [] + } + } + } + } +} diff --git a/docs/build_doc.sh b/docs/build_doc.sh new file mode 100755 index 0000000..9b42371 --- /dev/null +++ b/docs/build_doc.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +APP_SCHEMA=app_schema.json + +gen_doc () +{ + local kind=$1 + local dir=$2 + local config=$3 + + [[ ! -z "$dir" ]] || exit 2 + rm -rf "$dir" && mkdir -p "$dir" + + generate-schema-doc \ + --config-file "$config" \ + "$APP_SCHEMA" \ + "$dir"/"main.$kind" +} + + +main () +{ + albero schema > "$APP_SCHEMA" + for i in html md; do + gen_doc "$i" "docs_$i" "doc_config_${i}.yaml" + done +} + +main + + diff --git a/docs/doc_config_html.yaml b/docs/doc_config_html.yaml new file mode 100644 index 0000000..944869b --- /dev/null +++ b/docs/doc_config_html.yaml @@ -0,0 +1,5 @@ +--- +template_name: js +description_is_markdown: true +expand_buttons: true +copy_js: false diff --git a/docs/doc_config_md.yaml b/docs/doc_config_md.yaml new file mode 100644 index 0000000..c5b5b7b --- /dev/null +++ b/docs/doc_config_md.yaml @@ -0,0 +1,5 @@ +--- +template_name: md +description_is_markdown: true +expand_buttons: true +copy_js: false