Skip to content

Commit

Permalink
Remove regex and show line number in HTML files
Browse files Browse the repository at this point in the history
  • Loading branch information
jngrad committed Feb 13, 2020
1 parent ab48a3b commit 8d43555
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions maintainer/CI/doc_warnings.sh
Expand Up @@ -45,6 +45,7 @@ if [ "${?}" = "0" ]; then
grep -rPno --include='*.html' --exclude-dir=_modules "${regex_sphinx_broken_link}" doc/sphinx/html/ | sort | uniq | while read -r line; do grep -rPno --include='*.html' --exclude-dir=_modules "${regex_sphinx_broken_link}" doc/sphinx/html/ | sort | uniq | while read -r line; do
# extract link target # extract link target
reference=$(echo "${line}" | sed -r 's|^.+<span class="pre">(.+)</span></code>$|\1|' | sed 's/()$//') reference=$(echo "${line}" | sed -r 's|^.+<span class="pre">(.+)</span></code>$|\1|' | sed 's/()$//')
lineno=$(echo "${line}" | cut -d ':' -f 2)
# skip if broken link refers to a standard Python type or to a # skip if broken link refers to a standard Python type or to a
# class/function from an imported module other than espressomd # class/function from an imported module other than espressomd
is_standard_type_or_module="false" is_standard_type_or_module="false"
Expand All @@ -63,7 +64,7 @@ if [ "${?}" = "0" ]; then
fi fi
found="true" found="true"
# locate the .rst file containing the broken link # locate the .rst file containing the broken link
filepath_html=$(echo "${line}" | sed -r 's/^(.+?):[0-9]+:<code.+$/\1/') filepath_html=$(echo "${line}" | cut -d ':' -f 1)
filepath_rst=$(echo "${filepath_html}" | sed 's|/html/|/|') filepath_rst=$(echo "${filepath_html}" | sed 's|/html/|/|')
filepath_rst="${filepath_rst%.html}.rst" filepath_rst="${filepath_rst%.html}.rst"
if [ -f "${filepath_rst}" ]; then if [ -f "${filepath_rst}" ]; then
Expand All @@ -84,8 +85,8 @@ if [ "${?}" = "0" ]; then
fi fi
fi fi
fi fi
# if not in a .rst file, show the .html file without line number # if not in a .rst file, show the .html file
echo "${filepath_html}:\`${reference}\`" | tee -a doc_warnings.log~ echo "${filepath_html}:${lineno}:\`${reference}\`" | tee -a doc_warnings.log~
done done
# generate log file # generate log file
n_warnings=$(wc -l < doc_warnings.log~) n_warnings=$(wc -l < doc_warnings.log~)
Expand Down

0 comments on commit 8d43555

Please sign in to comment.