use script instead of globbing to avoid entering commands in multiple toctrees

This commit is contained in:
Axel Kohlmeyer
2024-10-10 13:34:24 -04:00
parent 393dbdc640
commit 766ba94396
10 changed files with 91 additions and 19 deletions

7
doc/.gitignore vendored
View File

@ -17,3 +17,10 @@
*.el
/utils/sphinx-config/_static/mathjax
/utils/sphinx-config/_static/polyfill.js
/src/pairs.rst
/src/bonds.rst
/src/angles.rst
/src/dihedrals.rst
/src/impropers.rst
/src/computes.rst
/src/fixes.rst

View File

@ -83,7 +83,11 @@ $(SPHINXCONFIG)/conf.py: $(SPHINXCONFIG)/conf.py.in
-e 's,@LAMMPS_PYTHON_DIR@,$(BUILDDIR)/../python,g' \
-e 's,@LAMMPS_DOC_DIR@,$(BUILDDIR),g' $< > $@
html: xmlgen $(VENV) $(SPHINXCONFIG)/conf.py $(ANCHORCHECK) $(MATHJAX)
globbed-tocs:
@if [ "$(HAS_BASH)" == "NO" ] ; then echo "bash was not found at $(OSHELL)! Please use: $(MAKE) SHELL=/path/to/bash" 1>&2; exit 1; fi
$(SHELL) $(BUILDDIR)/utils/make-globbed-tocs.sh $(RSTDIR)
html: xmlgen globbed-tocs $(VENV) $(SPHINXCONFIG)/conf.py $(ANCHORCHECK) $(MATHJAX)
@if [ "$(HAS_BASH)" == "NO" ] ; then echo "bash was not found at $(OSHELL)! Please use: $(MAKE) SHELL=/path/to/bash" 1>&2; exit 1; fi
@$(MAKE) $(MFLAGS) -C graphviz all
@(\
@ -113,7 +117,7 @@ html: xmlgen $(VENV) $(SPHINXCONFIG)/conf.py $(ANCHORCHECK) $(MATHJAX)
@rm -rf html/PDF/.[sg]*
@echo "Build finished. The HTML pages are in doc/html."
fasthtml: xmlgen $(VENV) $(SPHINXCONFIG)/conf.py $(ANCHORCHECK) $(MATHJAX)
fasthtml: xmlgen globbed-tocs $(VENV) $(SPHINXCONFIG)/conf.py $(ANCHORCHECK) $(MATHJAX)
@if [ "$(HAS_BASH)" == "NO" ] ; then echo "bash was not found at $(OSHELL)! Please use: $(MAKE) SHELL=/path/to/bash" 1>&2; exit 1; fi
@$(MAKE) $(MFLAGS) -C graphviz all
@mkdir -p fasthtml
@ -132,7 +136,7 @@ fasthtml: xmlgen $(VENV) $(SPHINXCONFIG)/conf.py $(ANCHORCHECK) $(MATHJAX)
@rm -rf fasthtml/PDF/.[sg]*
@echo "Fast HTML build finished. The HTML pages are in doc/fasthtml."
spelling: xmlgen $(SPHINXCONFIG)/conf.py $(VENV) $(SPHINXCONFIG)/false_positives.txt
spelling: xmlgen globbed-tocs $(SPHINXCONFIG)/conf.py $(VENV) $(SPHINXCONFIG)/false_positives.txt
@if [ "$(HAS_BASH)" == "NO" ] ; then echo "bash was not found at $(OSHELL)! Please use: $(MAKE) SHELL=/path/to/bash" 1>&2; exit 1; fi
@(\
. $(VENV)/bin/activate ; \
@ -143,7 +147,7 @@ spelling: xmlgen $(SPHINXCONFIG)/conf.py $(VENV) $(SPHINXCONFIG)/false_positives
)
@echo "Spell check finished."
epub: xmlgen $(VENV) $(SPHINXCONFIG)/conf.py $(ANCHORCHECK)
epub: xmlgen globbed-tocs $(VENV) $(SPHINXCONFIG)/conf.py $(ANCHORCHECK)
@if [ "$(HAS_BASH)" == "NO" ] ; then echo "bash was not found at $(OSHELL)! Please use: $(MAKE) SHELL=/path/to/bash" 1>&2; exit 1; fi
@$(MAKE) $(MFLAGS) -C graphviz all
@mkdir -p epub/JPG
@ -166,7 +170,7 @@ mobi: epub
@ebook-convert LAMMPS.epub LAMMPS.mobi
@echo "Conversion finished. The MOBI manual file is created."
pdf: xmlgen $(VENV) $(SPHINXCONFIG)/conf.py $(ANCHORCHECK)
pdf: xmlgen globbed-tocs $(VENV) $(SPHINXCONFIG)/conf.py $(ANCHORCHECK)
@if [ "$(HAS_BASH)" == "NO" ] ; then echo "bash was not found at $(OSHELL)! Please use: $(MAKE) SHELL=/path/to/bash" 1>&2; exit 1; fi
@$(MAKE) $(MFLAGS) -C graphviz all
@if [ "$(HAS_PDFLATEX)" == "NO" ] ; then echo "PDFLaTeX or latexmk were not found! Please check README for further instructions" 1>&2; exit 1; fi

View File

@ -3,6 +3,4 @@ Angle Styles
.. toctree::
:maxdepth: 1
:glob:
angle_*

View File

@ -3,6 +3,4 @@ Bond Styles
.. toctree::
:maxdepth: 1
:glob:
bond_*

View File

@ -3,6 +3,4 @@ Computes
.. toctree::
:maxdepth: 1
:glob:
compute_*

View File

@ -3,6 +3,4 @@ Dihedral Styles
.. toctree::
:maxdepth: 1
:glob:
dihedral_*

View File

@ -3,6 +3,4 @@ Fixes
.. toctree::
:maxdepth: 1
:glob:
fix_*

View File

@ -3,6 +3,4 @@ Improper Styles
.. toctree::
:maxdepth: 1
:glob:
improper_*

View File

@ -3,6 +3,4 @@ Pair Styles
.. toctree::
:maxdepth: 1
:glob:
pair_*

75
doc/utils/make-globbed-tocs.sh Executable file
View File

@ -0,0 +1,75 @@
#!/bin/bash
# script to emulate globbed toctrees that allows to skip files that were entered already elsewhere
if [ $# != 1 ]
then
echo "Usage: $0 <rstdir>"
exit 1
fi
RSTDIR="$1"
TMPNAM=${RANDOM}
TMPDIR=${TMPDIR-/tmp}
# pairs.rst
cp ${RSTDIR}/pairs.rst.in ${TMPDIR}/${TMPNAM}.pairs.rst
for f in $(echo ${RSTDIR}/pair_*.rst | sed -e "s@${RSTDIR}/@@g" -e 's@\.rst@@g' -e 's@pair_\(coeff\|modify\|style\|write\)@@g' | sort )
do \
echo " $f" >> ${TMPDIR}/${TMPNAM}.pairs.rst
done
cmp -s ${TMPDIR}/${TMPNAM}.pairs.rst ${RSTDIR}/pairs.rst || mv -vf ${TMPDIR}/${TMPNAM}.pairs.rst ${RSTDIR}/pairs.rst
rm -f ${TMPDIR}/${TMPNAM}.pairs.rst
# bonds.rst
cp ${RSTDIR}/bonds.rst.in ${TMPDIR}/${TMPNAM}.bonds.rst
for f in $(echo ${RSTDIR}/bond_*.rst | sed -e "s@${RSTDIR}/@@g" -e "s@\\.rst@@g" -e 's@bond_\(coeff\|modify\|style\|write\)@@g' | sort )
do \
echo " $f" >> ${TMPDIR}/${TMPNAM}.bonds.rst
done
cmp -s ${TMPDIR}/${TMPNAM}.bonds.rst ${RSTDIR}/bonds.rst || mv -vf ${TMPDIR}/${TMPNAM}.bonds.rst ${RSTDIR}/bonds.rst
rm -f ${TMPDIR}/${TMPNAM}.bonds.rst
# angles.rst
cp ${RSTDIR}/angles.rst.in ${TMPDIR}/${TMPNAM}.angles.rst
for f in $(echo ${RSTDIR}/angle_*.rst | sed -e "s@${RSTDIR}/@@g" -e "s@\\.rst@@g" -e 's@angle_\(coeff\|modify\|style\|write\)@@g' | sort )
do \
echo " $f" >> ${TMPDIR}/${TMPNAM}.angles.rst
done
cmp -s ${TMPDIR}/${TMPNAM}.angles.rst ${RSTDIR}/angles.rst || mv -vf ${TMPDIR}/${TMPNAM}.angles.rst ${RSTDIR}/angles.rst
rm -f ${TMPDIR}/${TMPNAM}.angles.rst
# dihedrals.rst
cp ${RSTDIR}/dihedrals.rst.in ${TMPDIR}/${TMPNAM}.dihedrals.rst
for f in $(echo ${RSTDIR}/dihedral_*.rst | sed -e "s@${RSTDIR}/@@g" -e "s@\\.rst@@g" -e 's@dihedral_\(coeff\|modify\|style\|write\)@@g' | sort )
do \
echo " $f" >> ${TMPDIR}/${TMPNAM}.dihedrals.rst
done
cmp -s ${TMPDIR}/${TMPNAM}.dihedrals.rst ${RSTDIR}/dihedrals.rst || mv -vf ${TMPDIR}/${TMPNAM}.dihedrals.rst ${RSTDIR}/dihedrals.rst
rm -f ${TMPDIR}/${TMPNAM}.dihedrals.rst
# impropers.rst
cp ${RSTDIR}/impropers.rst.in ${TMPDIR}/${TMPNAM}.impropers.rst
for f in $(echo ${RSTDIR}/improper_*.rst | sed -e "s@${RSTDIR}/@@g" -e "s@\\.rst@@g" -e 's@improper_\(coeff\|modify\|style\|write\)@@g' | sort )
do \
echo " $f" >> ${TMPDIR}/${TMPNAM}.impropers.rst
done
cmp -s ${TMPDIR}/${TMPNAM}.impropers.rst ${RSTDIR}/impropers.rst || mv -vf ${TMPDIR}/${TMPNAM}.impropers.rst ${RSTDIR}/impropers.rst
rm -f ${TMPDIR}/${TMPNAM}.impropers.rst
# computes.rst
cp ${RSTDIR}/computes.rst.in ${TMPDIR}/${TMPNAM}.computes.rst
for f in $(echo ${RSTDIR}/compute_*.rst | sed -e "s@${RSTDIR}/@@g" -e "s@\\.rst@@g" -e 's@compute_modify@@g' | sort )
do \
echo " $f" >> ${TMPDIR}/${TMPNAM}.computes.rst
done
cmp -s ${TMPDIR}/${TMPNAM}.computes.rst ${RSTDIR}/computes.rst || mv -vf ${TMPDIR}/${TMPNAM}.computes.rst ${RSTDIR}/computes.rst
rm -f ${TMPDIR}/${TMPNAM}.computes.rst
# fixs.rst
cp ${RSTDIR}/fixes.rst.in ${TMPDIR}/${TMPNAM}.fixes.rst
for f in $(echo ${RSTDIR}/fix_*.rst | sed -e "s@${RSTDIR}/@@g" -e "s@\\.rst@@g" -e 's@fix_\(modify\|modify_atc_commands\)@@g' | sort )
do \
echo " $f" >> ${TMPDIR}/${TMPNAM}.fixes.rst
done
cmp -s ${TMPDIR}/${TMPNAM}.fixes.rst ${RSTDIR}/fixes.rst || mv -vf ${TMPDIR}/${TMPNAM}.fixes.rst ${RSTDIR}/fixes.rst
rm -f ${TMPDIR}/${TMPNAM}.fixes.rst