2017-12-16 08:51:36 -04:00
#!/usr/bin/env bash
2023-10-14 18:29:12 +02:00
PATHS = ${ @- " $( cd $( dirname " $0 " ) /../../ && pwd ) " }
2017-12-16 08:51:36 -04:00
2023-10-14 18:29:12 +02:00
echo " Checking doxygen layout in ${ PATHS } "
# check that \return(s) is placed before \note and \since
output = $( unbuffer ag --noaffinity --file-search-regex '\.h$' --multiline '\\(note|since)[^\n]+(\n\s*\* [^\n]+)*\n\s*\* \\return' ${ PATHS } | tee /dev/stderr)
2019-05-21 14:13:28 -05:00
if [ [ -n $output ] ] ; then
2017-12-16 08:51:36 -04:00
echo -e "\n\x1B[31m*** Docstring computation: \\\return(s) should be placed before \\\note and \\since\x1B[0m"
exit 1
fi
2017-12-19 16:31:53 -04:00
2018-05-28 09:00:41 -04:00
# check that \since and \deprecated are placed at the end of the command block
2023-10-14 18:29:12 +02:00
output = $( unbuffer ag --noaffinity --file-search-regex '\.h$' --multiline '(\\(deprecated|since)[^\n]+\n)+\s*\*[^\/](?!\s*\\(deprecated|since))' ${ PATHS } | tee /dev/stderr)
2019-05-21 14:13:28 -05:00
if [ [ -n $output ] ] ; then
2018-05-28 11:20:21 -04:00
echo -e "\n\x1B[31m*** Docstring computation: \\\deprecated and \\\since should be placed at the end of command blocks\x1B[0m"
echo -e "To fix it, you may want to run (multiple times) at the top level directory:"
echo 'sed -i -r ' "'" '$!N;s/^(\s*\*\s+\\(deprecated|since)[^\n]+)\n(\s*\*([^\/].*|$))/\3\n\1/;P;D' "'" ' $(ag -c --noaffinity --file-search-regex ' "'" '\.h$' "'" ' --multiline ' "'" '(\\(deprecated|since)[^\n]+\n)+\s*\*[^\/]' "'" ' . | cut -d: -f1)'
2018-05-28 09:00:41 -04:00
exit 1
fi
2017-12-19 16:31:53 -04:00
# code snippets command
2023-10-14 18:29:12 +02:00
output = $( unbuffer ag --noaffinity --file-search-regex '\.h$' --multiline '~~~\{\.\w+\}' ${ PATHS } | tee /dev/stderr)
2019-05-21 14:13:28 -05:00
if [ [ -n $output ] ] ; then
2017-12-19 16:31:53 -04:00
echo -e "\n\x1B[31m*** Docstring computation: code snippets should use \\\code{.xx} rather than ~~~{.xx} \x1B[0m"
exit 1
fi