Nathan Skrzypczak | a2c9509 | 2021-10-08 14:05:58 +0200 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | # Copyright (c) 2021 Cisco and/or its affiliates. |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at: |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | |
| 16 | set -eEo pipefail |
| 17 | |
| 18 | SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" |
| 19 | WS_ROOT=$( realpath ${SCRIPTDIR}/../.. ) |
| 20 | |
| 21 | function red () { printf "\e[0;31m$1\e[0m\n" ; } |
| 22 | function green () { printf "\e[0;32m$1\e[0m\n" ; } |
| 23 | |
| 24 | find_linked_docs () { |
| 25 | find ${WS_ROOT}/docs -type l \ |
| 26 | \( -name '*.rst' -o -name '*.md' \) \ |
| 27 | -exec readlink -f {} \; | sort |
| 28 | } |
| 29 | |
| 30 | find_excluded_docs () { |
| 31 | cat ${WS_ROOT}/docs/docsignore \ |
| 32 | | grep -v '#' \ |
| 33 | | sed s@^@${WS_ROOT}/@ \ |
| 34 | | sort |
| 35 | } |
| 36 | |
| 37 | find_linked_and_excluded_docs () { |
| 38 | cat <( find_linked_docs ) <( find_excluded_docs ) | sort |
| 39 | } |
| 40 | |
| 41 | find_candidate_docs () { |
| 42 | find \ |
| 43 | ${WS_ROOT}/src \ |
| 44 | ${WS_ROOT}/test \ |
| 45 | ${WS_ROOT}/extras \ |
| 46 | -not -path "${WS_ROOT}/test/venv/*" \ |
| 47 | \( -name '*.rst' -o -name '*.md' \) \ |
| 48 | | sort |
| 49 | } |
| 50 | |
| 51 | spellcheck () { |
| 52 | make -C ${WS_ROOT} docs-spell |
| 53 | } |
| 54 | |
| 55 | if [ "x$(comm -13 <( find_linked_and_excluded_docs ) <( find_candidate_docs ))" != x ]; then |
| 56 | red "The following files need to be linked" |
| 57 | red "in the doc folder e.g. :" |
| 58 | red "$ cd vpp/docs/developer/plugins" |
| 59 | red "$ ln -s ../../../src/plugins/my_plugin/my_plugin.rst" |
| 60 | echo "" |
| 61 | cat <( comm -13 <( find_linked_and_excluded_docs ) <( find_candidate_docs ) ) |
| 62 | exit 1 |
| 63 | fi |
| 64 | spellcheck |
| 65 | green "**********************************************" |
| 66 | green "* VPP Docs Checkstyle Successfully Completed *" |
| 67 | green "**********************************************" |