From d8a1529c0bc78c40b7ec88e8d08ff463ccb84f89 Mon Sep 17 00:00:00 2001 From: Ryan Curtin Date: Thu, 2 May 2024 12:56:11 -0400 Subject: [PATCH] Add a script to check whether anything has changed in the generated Markdown documentation. --- scripts/check-markdown-docs.sh | 53 ++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100755 scripts/check-markdown-docs.sh diff --git a/scripts/check-markdown-docs.sh b/scripts/check-markdown-docs.sh new file mode 100755 index 0000000000..11c0d2993a --- /dev/null +++ b/scripts/check-markdown-docs.sh @@ -0,0 +1,53 @@ +#!/usr/bin/env bash +# +# This script checks to ensure that generated Markdown documentation is the same +# as what's committed to the repository. After configuring mlpack with +# -DBUILD_MARKDOWN_BINDINGS=ON, use this simple script to detect changes in the +# documentation that should be committed. +# +# The only argument of the script is to the build directory. +if [ "$#" -ne 1 ]; +then + echo "Usage: $0 build/"; + echo " (replace build/ with your build directory, where you already" + echo " ran 'make markdown')"; + exit 1; +fi + +build_dir="$1"; + +# Check that Markdown documentation has been built. +if [[ ! -d "$build_dir/doc/" ]]; +then + echo "$build_dir/doc/ does not exist!"; + echo "Did you run 'make markdown' in your build directory ($build_dir)?"; + exit 1; +fi + +# Now check every file in the main repository bindings. +for f in doc/user/bindings/*; +do + echo "Checking $f..."; + f_base=`basename $f`; + + if [[ ! -f "$build_dir/doc/$f_base" ]]; + then + echo "$build_dir/doc/$f_base does not exist!"; + echo "Did you run 'make markdown' in your build directory ($build_dir)?"; + echo "Or does the file need to be removed from the repository?"; + exit 1; + fi + + diff -Nau $f "$build_dir/doc/$f_base"; + + if [ "$?" -ne 0 ]; + then + echo ""; + echo ""; + echo "Files $f and $build_dir/doc/$f_base differ! (See above.)"; + echo ""; + echo "If the sidebar differs, be sure to check if updates are needed in "; + echo "quickstart/*.sidebar.html!"; + exit 1; + fi +done