From e94958e99c4dec26c86ce8b76d744c04ba960675 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 15 Oct 2013 11:17:19 -0400 Subject: Add bash script to convert builtin help to reStructuredText Create a convert-help.bash script to extract builtin documentation as reStructuredText sources in a new Help directory. Run each executable with the --help-full option targeting a .rst file to extract the documentation. Generate Sphinx "toctree" directives to point each man page at the corresponding documents it should contain. Organize cmake-commands(7), cmake-properties(7), and cmake-variables(7) man pages into sections similar to those generated by --help-properties and --help-variables output previously. --- convert-help.bash | 306 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 306 insertions(+) create mode 100755 convert-help.bash diff --git a/convert-help.bash b/convert-help.bash new file mode 100755 index 0000000..7781eb8 --- /dev/null +++ b/convert-help.bash @@ -0,0 +1,306 @@ +#!/usr/bin/env bash + +if test $# -ne 1; then + echo 1>&2 'Specify cmake executable directory' + exit 1 +fi && +bin="$1" && + +# Extract .rst documentation and generate man section 1 pages +mkdir -p Help/manual && +cd Help && +mkdir tmp && cd tmp && +"$bin"/cmake --help-full ../manual/cmake.1.rst && +tar c * | (cd .. && tar x) && +cd .. && rm -rf tmp && +sed -i '1 i\ +cmake(1)\ +********\ + +' manual/cmake.1.rst && +mkdir tmp && cd tmp && +"$bin"/ctest --help-full ../manual/ctest.1.rst && +mv command/ctest_*.rst ../command && +cd .. && rm -rf tmp && +sed -i '1 i\ +ctest(1)\ +********\ + +' manual/ctest.1.rst && +mkdir tmp && cd tmp && +"$bin"/cpack --help-full ../manual/cpack.1.rst && +mv variable ../var_cpack && +cd .. && rm -rf tmp && +sed -i '1 i\ +cpack(1)\ +********\ + +' manual/cpack.1.rst && +mkdir tmp && cd tmp && +"$bin"/ccmake --help-full ../manual/ccmake.1.rst && +cd .. && rm -rf tmp && +sed -i '1 i\ +ccmake(1)\ +*********\ + +' manual/ccmake.1.rst && +mkdir tmp && cd tmp && +"$bin"/cmake-gui --help-full ../manual/cmake-gui.1.rst && +cd .. && rm -rf tmp && +sed -i '1 i\ +cmake-gui(1)\ +************\ + +' manual/cmake-gui.1.rst && + +# Remove trailing whitespace and blank lines +find . -name '*.rst' | +while read f; do + sed -e 's/[ \t]*$//' -i "$f" && + sed -e ':a' -e '/^\n*$/ {$d;N;ba;}' -i "$f" +done + +# Generate man section 7 pages +{ +deprecated_commands=$( +cat < tmp && +ls command/*.rst |sort|sed 's|^| /|;s|\.rst$||' | +grep -v /command/ctest_ | grep -v -x -F -f tmp && +rm tmp && +cat < manual/cmake-commands.7.rst && +{ +cat < manual/cmake-generators.7.rst && +{ +cat < manual/cmake-modules.7.rst && +{ +cat < manual/cmake-policies.7.rst && +{ +cat < manual/cmake-properties.7.rst && +{ +cat < manual/cmake-variables.7.rst && +mkdir variable && +mv var_*/* variable && +rmdir var_* && +cd .. && + +# Move module help back into .cmake module file comments +(cd Help/module && ls *.rst) | +while read m; do + dm="Help/module/$m" && + cm="Modules/${m%.rst}.cmake" && + { + echo '#.rst:' && + sed -e ' + /^./ s/^/# / + /^$/ c # + s/ *$// + ' "$dm" && + echo '' && + sed -e '1,/^$/d' "$cm" + } >"$cm.new" && + mv "$cm.new" "$cm" && + echo ".. cmake-module:: ../../$cm" > "$dm" +done -- cgit v0.12