2019-11-11 18:30:46 -08:00
|
|
|
#!/bin/bash
|
|
|
|
# Generate docs.md
|
2022-01-25 18:42:55 -08:00
|
|
|
# requires pydoc-markdown 4.5.0
|
2022-01-26 11:50:25 -08:00
|
|
|
config=$(cat <<'EOF'
|
|
|
|
{
|
|
|
|
"processors": [
|
|
|
|
{
|
|
|
|
"type": "filter",
|
|
|
|
"expression":"not name ==\"info\" and default()"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"type": "pydocmd"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"renderer": {
|
|
|
|
"type": "markdown",
|
|
|
|
"render_toc": true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
)
|
2022-01-25 18:38:26 -08:00
|
|
|
|
2019-11-11 18:30:46 -08:00
|
|
|
cd jc
|
2021-04-05 09:42:25 -07:00
|
|
|
echo Building docs for: package
|
2022-01-26 11:50:25 -08:00
|
|
|
pydoc-markdown -m jc "${config}" > ../docs/readme.md
|
2022-01-25 19:28:37 -08:00
|
|
|
sed -i "" 's/^#### /### /g' ../docs/readme.md
|
2022-01-19 22:20:36 -08:00
|
|
|
|
|
|
|
echo Building docs for: lib
|
2022-01-26 11:50:25 -08:00
|
|
|
pydoc-markdown -m jc.lib "${config}" > ../docs/lib.md
|
2022-01-25 19:28:37 -08:00
|
|
|
sed -i "" 's/^#### /### /g' ../docs/lib.md
|
2022-01-19 22:20:36 -08:00
|
|
|
|
2021-04-05 09:42:25 -07:00
|
|
|
echo Building docs for: utils
|
2022-01-26 11:50:25 -08:00
|
|
|
pydoc-markdown -m jc.utils "${config}" > ../docs/utils.md
|
2022-01-25 19:28:37 -08:00
|
|
|
sed -i "" 's/^#### /### /g' ../docs/utils.md
|
2021-04-02 21:50:04 -07:00
|
|
|
|
2022-01-20 09:46:24 -08:00
|
|
|
echo Building docs for: universal parser
|
2022-01-26 11:50:25 -08:00
|
|
|
pydoc-markdown -m jc.parsers.universal "${config}" > ../docs/parsers/universal.md
|
2022-01-25 19:28:37 -08:00
|
|
|
sed -i "" 's/^#### /### /g' ../docs/parsers/universal.md
|
2022-01-20 09:46:24 -08:00
|
|
|
|
2021-04-02 21:50:04 -07:00
|
|
|
# a bit of inception here... jc is being used to help
|
|
|
|
# automate the generation of its own documentation. :)
|
|
|
|
|
2021-04-09 10:26:34 -07:00
|
|
|
# pull jc parser objects into a bash array from jq
|
2022-01-25 18:42:55 -08:00
|
|
|
# filter out any plugin parsers
|
2021-04-09 10:26:34 -07:00
|
|
|
parsers=()
|
|
|
|
while read -r value
|
|
|
|
do
|
2021-04-09 16:36:20 -07:00
|
|
|
parsers+=("$value")
|
2022-01-25 17:07:47 -08:00
|
|
|
done < <(jc -a | jq -c '.parsers[] | select(.plugin != true)')
|
2021-04-02 21:50:04 -07:00
|
|
|
|
2021-04-09 10:26:34 -07:00
|
|
|
for parser in "${parsers[@]}"
|
2021-04-02 21:50:04 -07:00
|
|
|
do
|
2021-04-09 16:36:20 -07:00
|
|
|
parser_name=$(jq -r '.name' <<< "$parser")
|
|
|
|
compatible=$(jq -r '.compatible | join(", ")' <<< "$parser")
|
|
|
|
version=$(jq -r '.version' <<< "$parser")
|
|
|
|
author=$(jq -r '.author' <<< "$parser")
|
|
|
|
author_email=$(jq -r '.author_email' <<< "$parser")
|
2021-04-09 10:26:34 -07:00
|
|
|
|
|
|
|
echo "Building docs for: ${parser_name}"
|
2021-04-09 10:36:03 -07:00
|
|
|
echo "[Home](https://kellyjonbrazil.github.io/jc/)" > ../docs/parsers/"${parser_name}".md
|
2022-01-26 11:50:25 -08:00
|
|
|
pydoc-markdown -m jc.parsers."${parser_name}" "${config}" >> ../docs/parsers/"${parser_name}".md
|
2022-01-25 19:18:54 -08:00
|
|
|
echo "### Parser Information" >> ../docs/parsers/"${parser_name}".md
|
2021-04-09 10:26:34 -07:00
|
|
|
echo "Compatibility: ${compatible}" >> ../docs/parsers/"${parser_name}".md
|
|
|
|
echo >> ../docs/parsers/"${parser_name}".md
|
|
|
|
echo "Version ${version} by ${author} (${author_email})" >> ../docs/parsers/"${parser_name}".md
|
2022-01-25 19:18:54 -08:00
|
|
|
sed -i "" 's/^#### /### /g' ../docs/parsers/"${parser_name}".md
|
2021-04-02 21:50:04 -07:00
|
|
|
done
|