Skip to content

Commit

Permalink
doc: Add gen script and template for library ref
Browse files Browse the repository at this point in the history
  • Loading branch information
e10harvey committed Dec 12, 2024
1 parent 82fcb22 commit c647b76
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
38 changes: 38 additions & 0 deletions doc/gen_library_ref_rst_from_class_list.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash
echo "Usage example: "
echo " ./gen_library_ref_rst_from_class_list.sh \\"
echo " ./source/library_reference/common/lib/csp \\"
echo " CSP \\"
echo " \"This is a collection of CSP utilities for OpenCSP." "opencsp.common.lib.csp.Facet, opencsp.common.lib.csp.FacetEnsemble, opencsp.common.lib.csp.HeliostatAbstract, opencsp.common.lib.csp.HeliostatAzEl, opencsp.common.lib.csp.HeliostatConfiguration, opencsp.common.lib.csp.LightPath, opencsp.common.lib.csp.LightPathEnsemble, opencsp.common.lib.csp.LightSource, opencsp.common.lib.csp.LightSourcePoint, opencsp.common.lib.csp.LightSourceSun, opencsp.common.lib.csp.MirrorAbstract, opencsp.common.lib.csp.MirrorParametric, opencsp.common.lib.csp.MirrorParametricRectangular, opencsp.common.lib.csp.MirrorPoint, opencsp.common.lib.csp.OpticOrientationAbstract, opencsp.common.lib.csp.RayTrace, opencsp.common.lib.csp.RayTraceable, opencsp.common.lib.csp.Scene, opencsp.common.lib.csp.SolarField, opencsp.common.lib.csp.StandardPlotOutput, opencsp.common.lib.csp.Tower, opencsp.common.lib.csp.VisualizeOrthorectifiedSlopeAbstract, opencsp.common.lib.csp.sun_position, opencsp.common.lib.csp.sun_track, opencsp.common.lib.csp.visualize_orthorectified_image\"\\"

DOC_PATH="${1:?Error: DOC_PATH is unset}"
DOC_SHORT_DESCRIPTOR="${2:?Error: DOC_SHORT_DESCRIPTOR is unset}"
DOC_LONG_DESCRIPTOR="${3:?Error: DOC_LONG_DESCRIPTOR is unset}"
CLASS_LIST="${4:?Error: CLASS_LIST is unset}"

sed_cmd=sed
which gsed &> /dev/null
ret=$?
if [ $ret -eq 0 ]; then
sed_cmd=gsed
fi

mkdir -p $DOC_PATH || true
rm -i $DOC_PATH/config.rst
rm -i $DOC_PATH/index.rst

for class in $(echo $CLASS_LIST); do
sans_comma=$(echo $class | tr -d ',')
cat template_config | ${sed_cmd} "s/__MODULE__/$sans_comma/g" >> $DOC_PATH/config.rst
done

echo "$DOC_SHORT_DESCRIPTOR" >> $DOC_PATH/index.rst
footer_len=$(echo $DOC_SHORT_DESCRIPTOR | wc -c)
python -c "print('=' * ${footer_len})" >> $DOC_PATH/index.rst
echo "" >> $DOC_PATH/index.rst

echo "$DOC_LONG_DESCRIPTOR" >> $DOC_PATH/index.rst
echo "" >> $DOC_PATH/index.rst
cat template_index >> $DOC_PATH/index.rst

echo -n "$DOC_PATH" | awk -F 'library_reference/' '{print " "$2"/index.rst"}' >> ./source/library_reference/index.rst
9 changes: 9 additions & 0 deletions doc/template_config
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.. currentmodule:: __MODULE__

.. automodule:: __MODULE__
:members:
:special-members: __init__
:undoc-members:
:show-inheritance:
:member-order: groupwise

4 changes: 4 additions & 0 deletions doc/template_index
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.. toctree::
:maxdepth: 1

config.rst

0 comments on commit c647b76

Please sign in to comment.