mirror of
https://github.com/cosinekitty/astronomy.git
synced 2026-03-23 17:03:37 -04:00
64 lines
2.8 KiB
Bash
Executable File
64 lines
2.8 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.{c,cs,js,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 ../source/csharp/astronomy.cs; do
|
|
node trimspace.js ${file}
|
|
done
|
|
|
|
# C# is a special case: we have to compile the code to get its documentation.
|
|
echo "Building C# code to get documentation XML."
|
|
cd dotnet/csharp_test || "Cannot change to directory dotnet/csharp_test"
|
|
dotnet build --output ${PWD}/exe || Fail "Error building C# source code"
|
|
cd ../../../csdown || Fail "Error changing to csdown directory"
|
|
./build || exit 1
|
|
dotnet exe/csdown.dll csharp_prefix.md ../generate/dotnet/csharp_test/exe/astronomy.dll ../generate/dotnet/csharp_test/exe/astronomy.xml ../source/csharp/README.md || Fail "Error generating C# documentation."
|
|
cd ../generate || Fail "Error changing back to generate directory"
|
|
|
|
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 ../pydown/py_prefix.md ../source/python/astronomy.py ../source/python/README.md || Fail "Error generating Markdown from Python source."
|
|
|
|
exit 0
|