Files
astronomy/generate/makedoc
Don Cross 700d3d7870 Starting to create my own custom Python to Markdown converter.
Once again, existing tools are too complicated and don't do what I want.
It's actually easier to create my own tool for this special purpose.
I also want the documentation to be similar in style to the other languages.
2019-07-08 14:25:49 -04:00

55 lines
2.1 KiB
Bash
Executable File

#!/bin/bash
Fail()
{
echo "ERROR($0): $1"
exit 1
}
echo "Trimming trailing whitespace in source code."
for file in template/astronomy.{js,c,py} ../source/c/astronomy.h; do
node trimspace.js ${file}
done
echo "Generating target code."
./generate source || Fail "Problem generating target code."
echo "Trimming trailing whitespace in target code."
for file in ../source/c/astronomy.c ../source/js/astronomy.js ../source/python/astronomy.py; do
node trimspace.js ${file}
done
echo "Minifying JavaScript code."
google-closure-compiler --js ../source/js/astronomy.js --js_output_file ../source/js/astronomy.min.js || Fail "Error minifying astronomy.js"
echo "Generating JS documentation in Markdown format."
jsdoc2md --separators --template ../jsdoc2md/js.hbs --files ../source/js/astronomy.js > ../source/js/README.md || Fail "Error generating JS documentation."
if [[ -d html ]]; then
echo "Generating JS documentation in HTML format for local viewing."
rm -rf html
jsdoc ../source/js/astronomy.js --destination html || Fail "Error generating HTML preview"
else
echo "(Skipping local HTML generation because html directory does not exist.)"
fi
if [[ -f generate_c_docs ]]; then
echo "Generating C documentation."
cd ../source/c || Fail "Error changing directory to ../source/c"
rm -rf html xml latex
doxygen Doxyfile > doxygen.log || Fail "Error in doxygen"
cd xml || Fail "Error changinge to xml directory"
echo "Merging doxygen XML files."
xsltproc combine.xslt index.xml > all.xml || Fail "Error merging doxygen xml"
cd .. || Fail "Error changing to parent directory"
echo "Translating doxygen XML to Markdown."
node ../../hydrogen/hydrogen.js ../../hydrogen/c_prefix.md ./xml/all.xml || Fail "Error in hydrogen.js"
cd ../../generate || Fail "Error changing directory back"
else
echo "(Skipping generation of C documentation because file generate_c_docs does not exist.)"
fi
echo "Generating Python documentation."
python3 ../pydown/pydown.py ../source/python/astronomy.py ../source/python/README.md || Fail "Error generating Markdown from Python source."
exit 0