Thomas Kulik | fb8a0ee | 2020-03-11 13:13:52 +0100 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | #set -x # uncomment for bash script debugging |
| 4 | |
| 5 | # ============================================================================ |
| 6 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | # you may not use this file except in compliance with the License. |
| 8 | # You may obtain a copy of the License at |
| 9 | # |
| 10 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | # |
| 12 | # Unless required by applicable law or agreed to in writing, software |
| 13 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | # See the License for the specific language governing permissions and |
| 16 | # limitations under the License. |
| 17 | # ============LICENSE_END===================================================== |
| 18 | |
| 19 | ### |
| 20 | ### warnstats |
| 21 | ### |
| 22 | ### AUTHOR(S): |
| 23 | ### Thomas Kulik, Deutsche Telekom AG, 2020 |
| 24 | ### |
| 25 | ### DESCRIPTION: |
| 26 | ### warnstat helps to find the onap modules (projects) and rst-files which are |
Thomas Kulik | f2714a7 | 2020-03-23 09:12:25 +0100 | [diff] [blame] | 27 | ### responsible for the most warnings during the documentation build process. |
Thomas Kulik | 961abe1 | 2020-03-19 14:49:59 +0100 | [diff] [blame] | 28 | ### it requires a tox build logfile, parses it line by line, prints out some |
Thomas Kulik | f2714a7 | 2020-03-23 09:12:25 +0100 | [diff] [blame] | 29 | ### statistics and provides links to the local rst file, its html version, the |
| 30 | ### related link to readthedocs and as well the doc8 test result for the rst. |
Thomas Kulik | fb8a0ee | 2020-03-11 13:13:52 +0100 | [diff] [blame] | 31 | ### |
| 32 | |
| 33 | ### |
| 34 | ### CHANGELOG (LATEST ON TOP) |
| 35 | ### |
Thomas Kulik | 2ce16bd | 2020-05-14 14:16:26 +0200 | [diff] [blame] | 36 | ### 1.6.2 (2020-05-14) - fixed a major problem with rst files within one module |
| 37 | ### which have the same name (but reside in different |
| 38 | ### subdirectories). they were not shown in the result |
| 39 | ### list. introduced a crc-number for every file for proper |
| 40 | ### identification and to build the index. |
| 41 | ### - fixed a problem where the results are showing the link |
| 42 | ### to a wrong file due to a regex problem in the script. |
Thomas Kulik | 5967ea0 | 2020-04-21 09:48:29 +0200 | [diff] [blame] | 43 | ### 1.6.1 (2020-04-21) - fixed a problem with duplicates in rst filenames |
Thomas Kulik | addb696 | 2020-04-03 12:56:27 +0200 | [diff] [blame] | 44 | ### 1.6.0 (2020-04-03) - extended detection of docs pathes in case they are not |
| 45 | ### below the submodules directory |
Thomas Kulik | f2714a7 | 2020-03-23 09:12:25 +0100 | [diff] [blame] | 46 | ### 1.5.0 (2020-03-23) - doc8 test now executed for every rst file. result is |
| 47 | ### provided in the output as "doc8_(nnnnn)" where nnnnn |
| 48 | ### is the total number of accumulated doc8 errors. |
| 49 | ### - improved readability of output |
Thomas Kulik | 961abe1 | 2020-03-19 14:49:59 +0100 | [diff] [blame] | 50 | ### 1.4.0 (2020-03-18) - the link to the local html and rst file is provided in |
| 51 | ### the output. this may help to ease the debug process. |
| 52 | ### use mouse-over/context menu functionality of bash to |
| 53 | ### easily open files with your browser or rst editor. |
| 54 | ### - improved handling for module names (in case they are |
| 55 | ### no real onap projects/modules but directories which |
| 56 | ### contain additional documentation in rst format). |
| 57 | ### 1.3.1 (2020-03-10) - fixed minor typo in usage message |
Thomas Kulik | 5967ea0 | 2020-04-21 09:48:29 +0200 | [diff] [blame] | 58 | ### 1.3.0 (2020-03-09) - initially released to the community |
Thomas Kulik | fb8a0ee | 2020-03-11 13:13:52 +0100 | [diff] [blame] | 59 | ### |
| 60 | |
Thomas Kulik | 2ce16bd | 2020-05-14 14:16:26 +0200 | [diff] [blame] | 61 | script_version="1.6.2 (2020-05-14)" |
Thomas Kulik | f2714a7 | 2020-03-23 09:12:25 +0100 | [diff] [blame] | 62 | doc8_dir=$(pwd)/doc8_results |
| 63 | logfile=$1; |
| 64 | doc8_command="doc8 --verbose"; #add options if required |
| 65 | web_base_url="https://docs.onap.org/en/latest"; |
Thomas Kulik | fb8a0ee | 2020-03-11 13:13:52 +0100 | [diff] [blame] | 66 | |
| 67 | echo " "; |
Thomas Kulik | 961abe1 | 2020-03-19 14:49:59 +0100 | [diff] [blame] | 68 | echo " warnstats version ${script_version}"; |
Thomas Kulik | fb8a0ee | 2020-03-11 13:13:52 +0100 | [diff] [blame] | 69 | |
| 70 | declare -A module_array |
| 71 | declare -A message_short_array |
| 72 | declare -A message_long_array |
| 73 | declare -A rstfile_array |
Thomas Kulik | 961abe1 | 2020-03-19 14:49:59 +0100 | [diff] [blame] | 74 | declare -A rstfilepath_array |
| 75 | declare -A htmlfilepath_array |
| 76 | declare -A webpath_array |
Thomas Kulik | f2714a7 | 2020-03-23 09:12:25 +0100 | [diff] [blame] | 77 | declare -A doc8_result_array |
Thomas Kulik | fb8a0ee | 2020-03-11 13:13:52 +0100 | [diff] [blame] | 78 | |
| 79 | ### |
| 80 | ### simple script argument handling |
| 81 | ### |
| 82 | |
Thomas Kulik | fb8a0ee | 2020-03-11 13:13:52 +0100 | [diff] [blame] | 83 | # check if there is an argument at all |
| 84 | if [[ "$logfile" == "" ]] ; then |
| 85 | echo 'Usage: warnstats [tox-logfile]' |
| 86 | exit 1 |
| 87 | fi |
| 88 | |
| 89 | # check if argument is a file |
| 90 | if [ ! -f $logfile ] ; then |
| 91 | echo "Error: can't find tox-logfile \"$logfile\"" |
| 92 | exit 1 |
| 93 | fi |
| 94 | |
Thomas Kulik | f2714a7 | 2020-03-23 09:12:25 +0100 | [diff] [blame] | 95 | # create and clean doc8 directory |
| 96 | if [ ! -d "$doc8_dir" ]; then |
| 97 | mkdir $doc8_dir; |
| 98 | else |
| 99 | rm ${doc8_dir}/*.txt 2>/dev/null; |
| 100 | fi |
| 101 | |
Thomas Kulik | 961abe1 | 2020-03-19 14:49:59 +0100 | [diff] [blame] | 102 | # get local html build directory |
Thomas Kulik | f2714a7 | 2020-03-23 09:12:25 +0100 | [diff] [blame] | 103 | html_build_dir=$(grep "Generated docs available in" $logfile); |
| 104 | html_build_dir=$(echo "$html_build_dir" | grep -oP " /.*/doc/docs/_build/html$"); |
| 105 | html_build_dir=$(echo "$html_build_dir" | sed -r 's:^ ::'); |
| 106 | echo " html build directory ..... $html_build_dir" |
| 107 | echo " web base url ............. $web_base_url"; |
| 108 | echo " doc8 command ............. $doc8_command"; |
| 109 | echo " doc8 results directory ... $doc8_dir"; |
| 110 | echo " tox logfile .............. $logfile"; |
Thomas Kulik | 961abe1 | 2020-03-19 14:49:59 +0100 | [diff] [blame] | 111 | |
Thomas Kulik | fb8a0ee | 2020-03-11 13:13:52 +0100 | [diff] [blame] | 112 | # read in the tox build logfile - use only lines which contain a warning |
| 113 | readarray -t logfile_array < <(grep ": WARNING:" $logfile); |
| 114 | |
| 115 | # process filtered logfile line by line |
| 116 | for line in "${logfile_array[@]}" |
| 117 | do |
Thomas Kulik | f2714a7 | 2020-03-23 09:12:25 +0100 | [diff] [blame] | 118 | |
Thomas Kulik | fb8a0ee | 2020-03-11 13:13:52 +0100 | [diff] [blame] | 119 | # count warning lines |
| 120 | (( counter++ )); |
Thomas Kulik | f2714a7 | 2020-03-23 09:12:25 +0100 | [diff] [blame] | 121 | echo -n -e " lines processed .......... $counter (doc8 check may take a while ...)\r"; |
Thomas Kulik | fb8a0ee | 2020-03-11 13:13:52 +0100 | [diff] [blame] | 122 | |
Thomas Kulik | 961abe1 | 2020-03-19 14:49:59 +0100 | [diff] [blame] | 123 | # |
| 124 | # extract path to local rst file |
| 125 | # |
Thomas Kulik | 2ce16bd | 2020-05-14 14:16:26 +0200 | [diff] [blame] | 126 | |
| 127 | # remove problematic text in the original line that causes regex to fail |
| 128 | line=$(echo "$line" | sed -r 's:, other instance in.*::'); |
| 129 | |
Thomas Kulik | 961abe1 | 2020-03-19 14:49:59 +0100 | [diff] [blame] | 130 | path_rst=$line; |
Thomas Kulik | addb696 | 2020-04-03 12:56:27 +0200 | [diff] [blame] | 131 | path_rst_debug=$line; |
Thomas Kulik | 961abe1 | 2020-03-19 14:49:59 +0100 | [diff] [blame] | 132 | #echo "DBUG line: $line" |
| 133 | # remove problematic text in line that causes regex to fail |
| 134 | path_rst=$(echo "$path_rst" | sed -r 's:, other instance in.*::'); |
| 135 | #echo "DBUG path_rst: $path_rst" |
| 136 | # grep the rst file path |
Thomas Kulik | addb696 | 2020-04-03 12:56:27 +0200 | [diff] [blame] | 137 | path_rst=$(echo "$path_rst" | grep -oP "^(/|docs).*\.rst"); |
Thomas Kulik | 961abe1 | 2020-03-19 14:49:59 +0100 | [diff] [blame] | 138 | #echo "DBUG path_rst: $path_rst" |
Thomas Kulik | 2ce16bd | 2020-05-14 14:16:26 +0200 | [diff] [blame] | 139 | # create an unique identifier for the rst file for the case that the rst file name is used multiple times (but in different subdirectories) within one module |
| 140 | rst_crc=$(crc32 "$path_rst" 2>/dev/null); |
| 141 | #echo "DBUG rst_crc: $rst_crc" |
| 142 | if [[ "$rst_crc" == "" ]] ; then |
| 143 | rst_crc="rst_crc_missing" |
| 144 | fi |
| 145 | |
Thomas Kulik | 961abe1 | 2020-03-19 14:49:59 +0100 | [diff] [blame] | 146 | if [[ "$path_rst" == "" ]] ; then |
| 147 | path_rst="path_to_rst_missing" |
Thomas Kulik | addb696 | 2020-04-03 12:56:27 +0200 | [diff] [blame] | 148 | #echo "DBUG path_rst: $path_rst" |
| 149 | #echo "DBUG path_rst_debug: $path_rst_debug" |
Thomas Kulik | fb8a0ee | 2020-03-11 13:13:52 +0100 | [diff] [blame] | 150 | fi |
Thomas Kulik | 961abe1 | 2020-03-19 14:49:59 +0100 | [diff] [blame] | 151 | # finally embed the full rst path in a message to use mouse-over/context menu of bash to open file |
Thomas Kulik | f2714a7 | 2020-03-23 09:12:25 +0100 | [diff] [blame] | 152 | path_rst_link='\e]8;;file:'$path_rst'\arst\e]8;;\a'; |
Thomas Kulik | 961abe1 | 2020-03-19 14:49:59 +0100 | [diff] [blame] | 153 | #echo -e "DBUG path_rst: "$path_rst; |
| 154 | |
| 155 | # |
| 156 | # extract path to the html version of the local rst file |
| 157 | # |
Thomas Kulik | 2ce16bd | 2020-05-14 14:16:26 +0200 | [diff] [blame] | 158 | |
Thomas Kulik | 961abe1 | 2020-03-19 14:49:59 +0100 | [diff] [blame] | 159 | path_html=$line; |
| 160 | #echo "DBUG line: $line" |
| 161 | # remove problematic text in line that causes regex to fail |
| 162 | path_html=$(echo "$path_html" | sed -r 's:, other instance in.*::'); |
| 163 | #echo "DBUG path_html: $path_html" |
| 164 | # grep the rst file path and modify it so we get the local html build path; grep a little bit more to be save |
| 165 | path_html=$(echo "$path_html" | grep -oP "(^|/)docs(/.*|)/[\w -]*\.rst"); |
| 166 | #echo "DBUG path_html: $path_html" |
| 167 | path_html=$(echo "$path_html" | sed -r 's:^/docs::'); |
| 168 | #echo "DBUG path_html: $path_html" |
| 169 | path_html=$(echo "$path_html" | sed -r 's:.rst:.html:'); |
| 170 | #echo "DBUG path_html: $path_html" |
| 171 | # create also the path to the web version |
Thomas Kulik | f2714a7 | 2020-03-23 09:12:25 +0100 | [diff] [blame] | 172 | path_web_link='\e]8;;'${web_base_url}${path_html}'\aweb\e]8;;\a'; |
| 173 | #echo "DBUG path_web_link: $path_web_link" |
Thomas Kulik | 961abe1 | 2020-03-19 14:49:59 +0100 | [diff] [blame] | 174 | # finally embed the full html path in a message to use mouse-over/context menu of bash to open file |
Thomas Kulik | f2714a7 | 2020-03-23 09:12:25 +0100 | [diff] [blame] | 175 | path_html_link='\e]8;;file:'${html_build_dir}${path_html}'\ahtml\e]8;;\a'; |
| 176 | #echo -e "DBUG path_html_link: "$path_html_link; |
Thomas Kulik | 961abe1 | 2020-03-19 14:49:59 +0100 | [diff] [blame] | 177 | |
| 178 | # extract module name from line (remove all text before module name; then cut out module name) |
| 179 | module=$(echo "$line" | sed -r 's:(^.*/doc/docs/submodules/|^docs/submodules/|checking consistency... )::' | cut -f1 -d\/); |
| 180 | #echo "DBUG line: $line" |
| 181 | #echo "DBUG module: $module" |
| 182 | |
| 183 | # in case the extraction has not lead to a valid module name do some additional investigation |
| 184 | if [[ "$module" == "" ]] ; then |
| 185 | |
| 186 | if [[ $line =~ doc/docs/release ]] ; then |
Thomas Kulik | f2714a7 | 2020-03-23 09:12:25 +0100 | [diff] [blame] | 187 | module="docs_release" |
Thomas Kulik | 961abe1 | 2020-03-19 14:49:59 +0100 | [diff] [blame] | 188 | #echo "DBUG line: $line" |
| 189 | #echo "DBUG module: $module" |
| 190 | elif [[ $line =~ doc/docs/use-cases ]] ; then |
Thomas Kulik | f2714a7 | 2020-03-23 09:12:25 +0100 | [diff] [blame] | 191 | module="docs_use-cases" |
Thomas Kulik | 961abe1 | 2020-03-19 14:49:59 +0100 | [diff] [blame] | 192 | #echo "DBUG line: $line" |
| 193 | #echo "DBUG module: $module" |
Thomas Kulik | addb696 | 2020-04-03 12:56:27 +0200 | [diff] [blame] | 194 | elif [[ $line =~ doc/docs/guides/onap-developer ]] ; then |
| 195 | module="docs_guides_onap-developer" |
| 196 | #echo "DBUG line: $line" |
| 197 | #echo "DBUG module: $module" |
| 198 | elif [[ $line =~ doc/docs/guides/onap-operator ]] ; then |
| 199 | module="docs_guides_onap-operator" |
| 200 | #echo "DBUG line: $line" |
| 201 | #echo "DBUG module: $module" |
| 202 | elif [[ $line =~ doc/docs/guides/onap-provider ]] ; then |
| 203 | module="docs_guides_onap-provider" |
| 204 | #echo "DBUG line: $line" |
| 205 | #echo "DBUG module: $module" |
| 206 | elif [[ $line =~ doc/docs/guides/onap-user ]] ; then |
| 207 | module="docs_guides_onap-user" |
| 208 | #echo "DBUG line: $line" |
| 209 | #echo "DBUG module: $module" |
| 210 | elif [[ $line =~ doc/docs/guides/overview ]] ; then |
| 211 | module="docs_guides_overview" |
| 212 | #echo "DBUG line: $line" |
| 213 | #echo "DBUG module: $module" |
| 214 | elif [[ $line =~ doc/docs/templates ]] ; then |
| 215 | module="docs_templates" |
| 216 | #echo "DBUG line: $line" |
| 217 | #echo "DBUG module: $module" |
Thomas Kulik | 961abe1 | 2020-03-19 14:49:59 +0100 | [diff] [blame] | 218 | elif [[ $line =~ doc/docs/guides ]] ; then |
Thomas Kulik | addb696 | 2020-04-03 12:56:27 +0200 | [diff] [blame] | 219 | module="docs_guides" |
Thomas Kulik | 961abe1 | 2020-03-19 14:49:59 +0100 | [diff] [blame] | 220 | #echo "DBUG line: $line" |
| 221 | #echo "DBUG module: $module" |
| 222 | else |
Thomas Kulik | f2714a7 | 2020-03-23 09:12:25 +0100 | [diff] [blame] | 223 | module="docs" |
Thomas Kulik | 961abe1 | 2020-03-19 14:49:59 +0100 | [diff] [blame] | 224 | #echo "DBUG line: $line" |
| 225 | #echo "DBUG module: $module" |
| 226 | fi |
| 227 | |
| 228 | fi |
| 229 | #echo "DBUG line: $line"; |
| 230 | #echo "DBUG module: $module"; |
| 231 | |
| 232 | # get the maximum length of the variable entries to adjust table width later on |
| 233 | if [[ ${#module} -gt "$maxlength_module" ]]; then |
| 234 | maxlength_module=${#module}; |
| 235 | fi |
| 236 | #echo "DBUG maxlength_module=$maxlength_module"; |
Thomas Kulik | fb8a0ee | 2020-03-11 13:13:52 +0100 | [diff] [blame] | 237 | |
| 238 | # extract rst file name from line and do some formatting to use it later as an array name |
| 239 | #echo "DBUG line: $line"; |
Thomas Kulik | 5967ea0 | 2020-04-21 09:48:29 +0200 | [diff] [blame] | 240 | rstfile=$(echo "$line" | sed -r 's:, other instance in.*::'); |
| 241 | rstfile=$(echo -e "${rstfile}" | grep -oP "[\w -]*\.rst"); |
Thomas Kulik | fb8a0ee | 2020-03-11 13:13:52 +0100 | [diff] [blame] | 242 | rstfile=$(echo -e ${rstfile} | tr '[:blank:]' '_'); |
Thomas Kulik | 2ce16bd | 2020-05-14 14:16:26 +0200 | [diff] [blame] | 243 | #echo "DBUG rstfile: '$rstfile'"; |
Thomas Kulik | fb8a0ee | 2020-03-11 13:13:52 +0100 | [diff] [blame] | 244 | |
Thomas Kulik | 961abe1 | 2020-03-19 14:49:59 +0100 | [diff] [blame] | 245 | # get the maximum length of the variable entries to adjust table width later on |
| 246 | if [[ ${#rstfile} -gt "$maxlength_rstfile" ]]; then |
| 247 | maxlength_rstfile=${#rstfile}; |
| 248 | fi |
| 249 | #echo "DBUG maxlength_rstfile=$maxlength_rstfile"; |
| 250 | |
Thomas Kulik | fb8a0ee | 2020-03-11 13:13:52 +0100 | [diff] [blame] | 251 | # count the number of warnings for the module/rstfile combination |
Thomas Kulik | 2ce16bd | 2020-05-14 14:16:26 +0200 | [diff] [blame] | 252 | (( rstfile_array[$module | $rstfile | $rst_crc]++ )); |
Thomas Kulik | fb8a0ee | 2020-03-11 13:13:52 +0100 | [diff] [blame] | 253 | |
| 254 | # count the number of warnings for the single module |
Thomas Kulik | f2714a7 | 2020-03-23 09:12:25 +0100 | [diff] [blame] | 255 | #echo "DBUG $module | $rstfile | $message"; |
Thomas Kulik | fb8a0ee | 2020-03-11 13:13:52 +0100 | [diff] [blame] | 256 | (( module_array[$module]++ )); |
| 257 | |
Thomas Kulik | 961abe1 | 2020-03-19 14:49:59 +0100 | [diff] [blame] | 258 | # now we have all the information to fill the html/rst/web (file) path arrays |
Thomas Kulik | 2ce16bd | 2020-05-14 14:16:26 +0200 | [diff] [blame] | 259 | htmlfilepath_array[$module | $rstfile | $rst_crc]=$path_html_link; |
| 260 | rstfilepath_array[$module | $rstfile | $rst_crc]=$path_rst_link; |
| 261 | webpath_array[$module | $rstfile | $rst_crc]=$path_web_link; |
| 262 | |
| 263 | #echo "DBUG -------------------------------------------------------------------"; |
| 264 | #echo "DBUG line: $line"; |
| 265 | #echo "DBUG htmlfilepath_array: $module | $rstfile | $rst_crc = $path_html_link"; |
| 266 | #echo "DBUG rstfilepath_array: $module | $rstfile | $rst_crc = $path_rst_link"; |
| 267 | #echo "DBUG webpath_array: $module | $rstfile | $rst_crc = $path_web_link"; |
Thomas Kulik | 961abe1 | 2020-03-19 14:49:59 +0100 | [diff] [blame] | 268 | |
Thomas Kulik | fb8a0ee | 2020-03-11 13:13:52 +0100 | [diff] [blame] | 269 | # extract the warning message and do some formatting |
| 270 | #message=$(echo "$line" | sed -r 's:^/.+WARNING\:\ ::'); |
| 271 | message=$(echo "$line" | sed -r 's:^.+WARNING\:\ ::'); |
| 272 | message=$(echo -e ${message} | tr '[:blank:]' '_'); |
| 273 | message=$(echo -e ${message} | tr '/' '_'); |
| 274 | message=$(echo -e ${message} | tr '.' '_'); |
| 275 | |
| 276 | # remove all characters from message which may cause problems in the shell |
| 277 | message="$(echo -e "${message}" | sed -e 's/[^A-Za-z0-9_-]//g')"; |
| 278 | #echo "DBUG message=\"$message\"" |
| 279 | |
| 280 | # count the number of warnings for the single message (long version) |
| 281 | message_long="$(echo -e "${message}")"; |
| 282 | (( message_long_array[$message_long]++ )) |
| 283 | |
| 284 | # reduce length of message to group them more easily and then ... |
| 285 | # count the number of warnings for the single message (short version) |
Thomas Kulik | f2714a7 | 2020-03-23 09:12:25 +0100 | [diff] [blame] | 286 | message_short="$(echo -e "${message}" | cut -c -16)"; |
Thomas Kulik | fb8a0ee | 2020-03-11 13:13:52 +0100 | [diff] [blame] | 287 | (( message_short_array[$message_short]++ )) |
| 288 | |
Thomas Kulik | f2714a7 | 2020-03-23 09:12:25 +0100 | [diff] [blame] | 289 | # check rst files with doc8 and store results |
Thomas Kulik | 2ce16bd | 2020-05-14 14:16:26 +0200 | [diff] [blame] | 290 | doc8_result_path="${doc8_dir}/${module}-${rstfile}-${rst_crc}.txt"; |
Thomas Kulik | f2714a7 | 2020-03-23 09:12:25 +0100 | [diff] [blame] | 291 | #echo "DBUG ---------------------------------------------" |
| 292 | #echo "DBUG doc8_result_path=\"$doc8_result_path\"" |
| 293 | # doc8 check only if result file does not exists yet AND if rst file is valid (exists) |
| 294 | if [[ ! -f "$doc8_result_path" && -f "$path_rst" ]] ; then |
| 295 | echo "FILE:$path_rst" >$doc8_result_path; |
| 296 | $doc8_command "$path_rst" >>$doc8_result_path; |
| 297 | total_acc_err=$(grep "Total accumulated errors = " $doc8_result_path); |
| 298 | #echo "DBUG total_acc_err=$total_acc_err"; |
| 299 | total_acc_err=$(echo $total_acc_err | sed 's:Total accumulated errors = ::'); |
| 300 | #echo "DBUG total_acc_err=$total_acc_err"; |
| 301 | total_acc_err=$(printf "%05d" $total_acc_err); |
| 302 | #echo "DBUG command:doc8 ${path_rst} >>${doc8_result_path}"; |
| 303 | #echo "DBUG total_acc_err=$total_acc_err"; |
| 304 | fi |
| 305 | doc8_result='\e]8;;file:'${doc8_result_path}'\adoc8_('$total_acc_err')\e]8;;\a'; |
Thomas Kulik | 2ce16bd | 2020-05-14 14:16:26 +0200 | [diff] [blame] | 306 | doc8_result_array[$module | $rstfile | $rst_crc]=$doc8_result; |
Thomas Kulik | f2714a7 | 2020-03-23 09:12:25 +0100 | [diff] [blame] | 307 | |
Thomas Kulik | fb8a0ee | 2020-03-11 13:13:52 +0100 | [diff] [blame] | 308 | done |
| 309 | |
| 310 | #format counter to have always x digits |
| 311 | counter=$(printf "%05d" $counter); |
Thomas Kulik | f2714a7 | 2020-03-23 09:12:25 +0100 | [diff] [blame] | 312 | echo " "; |
Thomas Kulik | fb8a0ee | 2020-03-11 13:13:52 +0100 | [diff] [blame] | 313 | echo " $counter LINES WITH WARNING IN FILE '$logfile'"; |
| 314 | |
| 315 | echo " "; |
| 316 | echo "################################################################################"; |
| 317 | echo "~~~ MESSAGES LONG ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"; |
| 318 | echo "################################################################################"; |
| 319 | echo " "; |
| 320 | |
| 321 | #print array content and append to temporary outfile |
| 322 | for i in "${!message_long_array[@]}" |
| 323 | do |
| 324 | m=$i; |
| 325 | n=${message_long_array[$i]}; |
| 326 | ((nc += n)) |
| 327 | #format counter to have always x digits |
| 328 | n=$(printf "%05d" $n); |
Thomas Kulik | f2714a7 | 2020-03-23 09:12:25 +0100 | [diff] [blame] | 329 | echo " $n | $m" >>tempoutfile; |
Thomas Kulik | fb8a0ee | 2020-03-11 13:13:52 +0100 | [diff] [blame] | 330 | done |
| 331 | |
| 332 | #format counter to have always x digits |
| 333 | nc=$(printf "%05d" $nc); |
| 334 | echo " $nc WARNINGS IN TOTAL WITH ${#message_long_array[@]} UNIQUE MESSAGES" >>tempoutfile; |
| 335 | |
| 336 | #print a sorted version of the temporary outfile |
| 337 | sort -br tempoutfile |
| 338 | |
| 339 | # clean up |
| 340 | rm tempoutfile |
| 341 | nc=0 |
| 342 | |
| 343 | echo " "; |
| 344 | echo "################################################################################"; |
Thomas Kulik | f2714a7 | 2020-03-23 09:12:25 +0100 | [diff] [blame] | 345 | echo "~~~ MESSAGES SHORTENED (FOR SIMPLE GROUPING) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"; |
Thomas Kulik | fb8a0ee | 2020-03-11 13:13:52 +0100 | [diff] [blame] | 346 | echo "################################################################################"; |
| 347 | echo " "; |
| 348 | |
| 349 | #print array content and append to temporary outfile |
| 350 | for i in "${!message_short_array[@]}" |
| 351 | do |
| 352 | m=$i; |
| 353 | n=${message_short_array[$i]}; |
| 354 | ((nc += n)) |
| 355 | #format counter to have always x digits |
| 356 | n=$(printf "%05d" $n); |
Thomas Kulik | f2714a7 | 2020-03-23 09:12:25 +0100 | [diff] [blame] | 357 | echo " $n | $m" >>tempoutfile; |
Thomas Kulik | fb8a0ee | 2020-03-11 13:13:52 +0100 | [diff] [blame] | 358 | done |
| 359 | |
| 360 | #format counter to have always x digits |
| 361 | nc=$(printf "%05d" $nc); |
| 362 | echo " $nc WARNINGS IN TOTAL WITH ${#message_short_array[@]} UNIQUE MESSAGES" >>tempoutfile; |
| 363 | |
| 364 | #print a sorted version of the temporary outfile |
| 365 | sort -br tempoutfile |
| 366 | |
| 367 | # clean up |
| 368 | rm tempoutfile |
| 369 | nc=0 |
| 370 | |
| 371 | echo " "; |
| 372 | echo "################################################################################"; |
| 373 | echo "~~~ MODULES ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"; |
| 374 | echo "################################################################################"; |
| 375 | echo " "; |
| 376 | |
| 377 | #create temporary outfile |
| 378 | for i in "${!module_array[@]}" |
| 379 | do |
| 380 | m=$i; |
| 381 | n=${module_array[$i]}; |
| 382 | ((nc += n)) |
| 383 | n=$(printf "%05d" $n); |
Thomas Kulik | f2714a7 | 2020-03-23 09:12:25 +0100 | [diff] [blame] | 384 | echo " $n | $m" >>tempoutfile; |
Thomas Kulik | fb8a0ee | 2020-03-11 13:13:52 +0100 | [diff] [blame] | 385 | done |
| 386 | |
| 387 | #format counter to have always x digits |
| 388 | nc=$(printf "%05d" $nc); |
| 389 | echo " $nc WARNINGS IN TOTAL IN ${#module_array[@]} MODULES" >>tempoutfile; |
| 390 | |
| 391 | #print a sorted version of the temporary outfile |
| 392 | sort -br tempoutfile |
| 393 | rm tempoutfile |
| 394 | nc=0 |
| 395 | |
| 396 | echo " "; |
| 397 | echo "################################################################################"; |
| 398 | echo "~~~ MODULES WITH RSTFILES ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"; |
| 399 | echo "################################################################################"; |
| 400 | echo " "; |
| 401 | |
| 402 | #print array content and append to temporary outfile |
| 403 | for i in "${!rstfile_array[@]}" |
| 404 | do |
| 405 | m=$i; |
| 406 | n=${rstfile_array[$i]}; |
Thomas Kulik | 961abe1 | 2020-03-19 14:49:59 +0100 | [diff] [blame] | 407 | p=${htmlfilepath_array[$i]} |
| 408 | r=${rstfilepath_array[$i]} |
| 409 | w=${webpath_array[$i]} |
Thomas Kulik | f2714a7 | 2020-03-23 09:12:25 +0100 | [diff] [blame] | 410 | d=${doc8_result_array[$i]}; |
Thomas Kulik | 961abe1 | 2020-03-19 14:49:59 +0100 | [diff] [blame] | 411 | #echo "DBUG -------------------------------" |
Thomas Kulik | 2ce16bd | 2020-05-14 14:16:26 +0200 | [diff] [blame] | 412 | #echo "DBUG i = '$i'" |
| 413 | #echo "DBUG m = '$m'" |
| 414 | #echo "DBUG n = '$n'" |
| 415 | #echo "DBUG p = '$p'" |
| 416 | #echo -e "DBUG p = '$p'" |
| 417 | #echo "DBUG w = '$w'" |
| 418 | #echo "DBUG d = '$d'" |
Thomas Kulik | fb8a0ee | 2020-03-11 13:13:52 +0100 | [diff] [blame] | 419 | ((nc += n)) |
| 420 | #format counter to have always x digits |
| 421 | n=$(printf "%05d" $n); |
Thomas Kulik | f2714a7 | 2020-03-23 09:12:25 +0100 | [diff] [blame] | 422 | |
| 423 | # extend module name to the max for better readability |
| 424 | tmp_mod=$(echo "$m" | sed -r 's: \|.+$::'); |
| 425 | #echo "DBUG tmp_mod=$tmp_mod" |
| 426 | len_tmp_mod=${#tmp_mod} |
| 427 | to_add="$(($maxlength_module-$len_tmp_mod))" |
| 428 | #echo "DBUG to_add=$to_add" |
| 429 | while [ $to_add -gt 0 ]; do |
| 430 | tmp_mod="${tmp_mod} "; |
| 431 | ((to_add--)); |
| 432 | #echo "DBUG to_add=$to_add" |
| 433 | #echo "DBUG tmp_mod=\"$tmp_mod\"" |
| 434 | done |
| 435 | |
Thomas Kulik | 2ce16bd | 2020-05-14 14:16:26 +0200 | [diff] [blame] | 436 | # remove crc and extend rst name to the max for better readability |
| 437 | #echo "DBUG ******************************************************" |
| 438 | #echo "DBUG m = '$m'" |
| 439 | tmp_rst=$(echo "$m" | sed -r 's:\| [[:alnum:]_]+$::'); |
| 440 | #echo "DBUG tmp_rst = '$tmp_rst'" |
| 441 | tmp_rst=$(echo "$tmp_rst" | sed -r 's:[[:space:]]$::'); |
| 442 | #echo "DBUG tmp_rst = '$tmp_rst'" |
| 443 | tmp_rst=$(echo "$tmp_rst" | sed -r 's:^.+ \| ::'); |
| 444 | #echo "DBUG tmp_rst = '$tmp_rst'" |
Thomas Kulik | f2714a7 | 2020-03-23 09:12:25 +0100 | [diff] [blame] | 445 | len_tmp_rst=${#tmp_rst} |
Thomas Kulik | 2ce16bd | 2020-05-14 14:16:26 +0200 | [diff] [blame] | 446 | #echo "DBUG len_tmp_rst = '$len_tmp_rst'" |
Thomas Kulik | f2714a7 | 2020-03-23 09:12:25 +0100 | [diff] [blame] | 447 | to_add="$(($maxlength_rstfile-$len_tmp_rst))" |
Thomas Kulik | 2ce16bd | 2020-05-14 14:16:26 +0200 | [diff] [blame] | 448 | #echo "DBUG to_add = '$to_add'" |
Thomas Kulik | f2714a7 | 2020-03-23 09:12:25 +0100 | [diff] [blame] | 449 | while [ $to_add -gt 0 ]; do |
| 450 | tmp_rst="${tmp_rst} "; |
| 451 | ((to_add--)); |
Thomas Kulik | 2ce16bd | 2020-05-14 14:16:26 +0200 | [diff] [blame] | 452 | #echo "DBUG to_add = '$to_add'" |
| 453 | #echo "DBUG tmp_rst = '$tmp_rst'" |
Thomas Kulik | f2714a7 | 2020-03-23 09:12:25 +0100 | [diff] [blame] | 454 | done |
| 455 | |
| 456 | # recombine module and rst names |
| 457 | m="${tmp_mod} | ${tmp_rst}"; |
Thomas Kulik | 2ce16bd | 2020-05-14 14:16:26 +0200 | [diff] [blame] | 458 | #echo "DBUG m = '$m'" |
Thomas Kulik | f2714a7 | 2020-03-23 09:12:25 +0100 | [diff] [blame] | 459 | |
| 460 | # print out to temp file |
| 461 | echo -e " $m | $r $p $w $d | $n" >>tempoutfile; |
Thomas Kulik | fb8a0ee | 2020-03-11 13:13:52 +0100 | [diff] [blame] | 462 | done |
| 463 | |
| 464 | #format counter to have always x digits |
| 465 | nc=$(printf "%05d" $nc); |
| 466 | #in case the name (e.g) index.rst is used multiple times in the same module warnings are combined |
| 467 | echo " $nc WARNINGS IN TOTAL IN APPROX. ${#rstfile_array[@]} RST FILES" >>tempoutfile; |
| 468 | |
| 469 | #print a sorted version of the temporary outfile |
| 470 | sort -b tempoutfile |
| 471 | |
| 472 | # clean up |
| 473 | rm tempoutfile |
| 474 | nc=0 |
| 475 | |
| 476 | echo " "; |
| 477 | echo "################################################################################"; |
| 478 | echo "~~~ RSTFILES ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"; |
| 479 | echo "################################################################################"; |
| 480 | echo " "; |
| 481 | |
| 482 | #print array content and append to temporary outfile |
| 483 | for i in "${!rstfile_array[@]}" |
| 484 | do |
| 485 | m=$i; |
| 486 | n=${rstfile_array[$i]}; |
Thomas Kulik | 961abe1 | 2020-03-19 14:49:59 +0100 | [diff] [blame] | 487 | p=${htmlfilepath_array[$i]} |
| 488 | r=${rstfilepath_array[$i]} |
| 489 | w=${webpath_array[$i]} |
Thomas Kulik | f2714a7 | 2020-03-23 09:12:25 +0100 | [diff] [blame] | 490 | d=${doc8_result_array[$i]}; |
Thomas Kulik | 2ce16bd | 2020-05-14 14:16:26 +0200 | [diff] [blame] | 491 | #echo "DBUG -------------------------------" |
| 492 | #echo "DBUG i=$i" |
| 493 | #echo "DBUG m=$m" |
| 494 | #echo "DBUG n=$n" |
| 495 | #echo "DBUG p=$p" |
| 496 | #echo -e "DBUG p=$p" |
| 497 | #echo "DBUG m=$r" |
| 498 | #echo "DBUG n=$w" |
| 499 | #echo "DBUG p=$d" |
Thomas Kulik | fb8a0ee | 2020-03-11 13:13:52 +0100 | [diff] [blame] | 500 | ((nc += n)) |
| 501 | #format counter to have always x digits |
| 502 | n=$(printf "%05d" $n); |
Thomas Kulik | f2714a7 | 2020-03-23 09:12:25 +0100 | [diff] [blame] | 503 | |
| 504 | # extend module name to the max for better readability |
| 505 | tmp_mod=$(echo "$m" | sed -r 's: \|.+$::'); |
| 506 | #echo "DBUG tmp_mod=$tmp_mod" |
| 507 | len_tmp_mod=${#tmp_mod} |
| 508 | to_add="$(($maxlength_module-$len_tmp_mod))" |
| 509 | #echo "DBUG to_add=$to_add" |
| 510 | while [ $to_add -gt 0 ]; do |
| 511 | tmp_mod="${tmp_mod} "; |
| 512 | ((to_add--)); |
| 513 | #echo "DBUG to_add=$to_add" |
| 514 | #echo "DBUG tmp_mod=\"$tmp_mod\"" |
| 515 | done |
| 516 | |
Thomas Kulik | 2ce16bd | 2020-05-14 14:16:26 +0200 | [diff] [blame] | 517 | # remove crc and extend rst name to the max for better readability |
| 518 | #echo "DBUG ******************************************************" |
| 519 | #echo "DBUG m = '$m'" |
| 520 | tmp_rst=$(echo "$m" | sed -r 's:\| [[:alnum:]_]+$::'); |
| 521 | #echo "DBUG tmp_rst = '$tmp_rst'" |
| 522 | tmp_rst=$(echo "$tmp_rst" | sed -r 's:[[:space:]]$::'); |
| 523 | #echo "DBUG tmp_rst = '$tmp_rst'" |
| 524 | tmp_rst=$(echo "$tmp_rst" | sed -r 's:^.+ \| ::'); |
| 525 | #echo "DBUG tmp_rst = '$tmp_rst'" |
Thomas Kulik | f2714a7 | 2020-03-23 09:12:25 +0100 | [diff] [blame] | 526 | len_tmp_rst=${#tmp_rst} |
Thomas Kulik | 2ce16bd | 2020-05-14 14:16:26 +0200 | [diff] [blame] | 527 | #echo "DBUG len_tmp_rst = '$len_tmp_rst'" |
Thomas Kulik | f2714a7 | 2020-03-23 09:12:25 +0100 | [diff] [blame] | 528 | to_add="$(($maxlength_rstfile-$len_tmp_rst))" |
Thomas Kulik | 2ce16bd | 2020-05-14 14:16:26 +0200 | [diff] [blame] | 529 | #echo "DBUG to_add = '$to_add'" |
Thomas Kulik | f2714a7 | 2020-03-23 09:12:25 +0100 | [diff] [blame] | 530 | while [ $to_add -gt 0 ]; do |
| 531 | tmp_rst="${tmp_rst} "; |
| 532 | ((to_add--)); |
Thomas Kulik | 2ce16bd | 2020-05-14 14:16:26 +0200 | [diff] [blame] | 533 | #echo "DBUG to_add = '$to_add'" |
| 534 | #echo "DBUG tmp_rst = '$tmp_rst'" |
Thomas Kulik | f2714a7 | 2020-03-23 09:12:25 +0100 | [diff] [blame] | 535 | done |
| 536 | |
| 537 | # recombine module and rst names |
| 538 | m="${tmp_mod} | ${tmp_rst}"; |
| 539 | |
| 540 | # print out to temp file |
| 541 | echo -e " $n | $m | $r $p $w $d" >>tempoutfile; |
Thomas Kulik | fb8a0ee | 2020-03-11 13:13:52 +0100 | [diff] [blame] | 542 | done |
| 543 | |
| 544 | #format counter to have always x digits |
| 545 | nc=$(printf "%05d" $nc); |
| 546 | #in case the name (e.g) index.rst is used multiple times in the same module warnings are combined |
| 547 | echo " $nc WARNINGS IN TOTAL IN APPROX. ${#rstfile_array[@]} RST FILES" >>tempoutfile; |
| 548 | |
| 549 | #print a sorted version of the temporary outfile |
| 550 | sort -br tempoutfile |
| 551 | |
| 552 | # clean up |
| 553 | rm tempoutfile |
| 554 | nc=0 |
| 555 | |
| 556 | echo " "; |
| 557 | exit |
| 558 | |
| 559 | ### |
| 560 | ### backup code for future extensions |
| 561 | ### |
| 562 | |
| 563 | # |
| 564 | # Block_quote_ends_without_a_blank_line_unexpected_unindent |
| 565 | # Bullet_list_ends_without_a_blank_line_unexpected_unindent |
| 566 | # Citation_[\w-]_is_not_referenced |
| 567 | # Citation_unit_test_is_not_referenced |
| 568 | # Content_block_expected_for_the_code_directive_none_found |
| 569 | # Content_block_expected_for_the_container_directive_none_found |
| 570 | # Could_not_lex_literal_block_as_bash__Highlighting_skipped |
| 571 | # Could_not_lex_literal_block_as_console__Highlighting_skipped |
| 572 | # Could_not_lex_literal_block_as_guess__Highlighting_skipped |
| 573 | # Could_not_lex_literal_block_as_json__Highlighting_skipped |
| 574 | # Could_not_lex_literal_block_as_yaml__Highlighting_skipped |
| 575 | # Definition_list_ends_without_a_blank_line_unexpected_unindent |
| 576 | # document_isnt_included_in_any_toctree |
| 577 | # download_file_not_readable |
| 578 | # Duplicate_explicit_target_name |
| 579 | # duplicate_label |
| 580 | # Enumerated_list_ends_without_a_blank_line_unexpected_unindent |
| 581 | # Error_in_code_directive |
| 582 | # Error_in_code-block_directive |
| 583 | # Error_in_image_directive |
| 584 | # Explicit_markup_ends_without_a_blank_line_unexpected_unindent |
| 585 | # Field_list_ends_without_a_blank_line_unexpected_unindent |
| 586 | # Footnote_[0-9.*]_is_not_referenced |
| 587 | # image_file_not_readable |
| 588 | # Include_file |
| 589 | # Inconsistent_literal_block_quoting |
| 590 | # Inline_emphasis_start-string_without_end-string |
| 591 | # Inline_interpreted_text_or_phrase_reference_start-string_without_end-string |
| 592 | # Inline_strong_start-string_without_end-string |
| 593 | # Inline_substitution_reference_start-string_without_end-string |
| 594 | # Literal_block_ends_without_a_blank_line_unexpected_unindent |
| 595 | # Literal_block_expected_none_found |
| 596 | # Malformed_table |
| 597 | # Pygments_lexer_name_asn_is_not_known |
| 598 | # Title_level_inconsistent |
| 599 | # Title_overline__underline_mismatch |
| 600 | # Title_overline_too_short |
| 601 | # Title_underline_too_short |
| 602 | # toctree_contains_reference_to_nonexisting_document |
| 603 | # Too_many_autonumbered_footnote_references_only_0_corresponding_footnotes_available |
| 604 | # undecodable_source_characters_replacing_with |
| 605 | # undefined_label |
| 606 | # Unexpected_indentation |
| 607 | # Unknown_directive_type_clode-block |
| 608 | # unknown_document |
| 609 | # Unknown_target_name |