Add: Doc autogeneration from schema
This commit is contained in:
parent
4854bb240f
commit
b8d6c4545a
150
docs/app_schema.json
Normal file
150
docs/app_schema.json
Normal file
@ -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": []
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
31
docs/build_doc.sh
Executable file
31
docs/build_doc.sh
Executable file
@ -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
|
||||
|
||||
|
||||
5
docs/doc_config_html.yaml
Normal file
5
docs/doc_config_html.yaml
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
template_name: js
|
||||
description_is_markdown: true
|
||||
expand_buttons: true
|
||||
copy_js: false
|
||||
5
docs/doc_config_md.yaml
Normal file
5
docs/doc_config_md.yaml
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
template_name: md
|
||||
description_is_markdown: true
|
||||
expand_buttons: true
|
||||
copy_js: false
|
||||
Loading…
x
Reference in New Issue
Block a user