blob: 2ab093dfbcba3413694cc45133509cb9d29bc04e [file] [log] [blame]
Nathan Skrzypczaka2c95092021-10-08 14:05:58 +02001#!/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
16set -eEo pipefail
17
18SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
19WS_ROOT=$( realpath ${SCRIPTDIR}/../.. )
20
21function red () { printf "\e[0;31m$1\e[0m\n" ; }
22function green () { printf "\e[0;32m$1\e[0m\n" ; }
23
24find_linked_docs () {
25 find ${WS_ROOT}/docs -type l \
26 \( -name '*.rst' -o -name '*.md' \) \
27 -exec readlink -f {} \; | sort
28}
29
30find_excluded_docs () {
31 cat ${WS_ROOT}/docs/docsignore \
32 | grep -v '#' \
33 | sed s@^@${WS_ROOT}/@ \
34 | sort
35}
36
37find_linked_and_excluded_docs () {
38 cat <( find_linked_docs ) <( find_excluded_docs ) | sort
39}
40
41find_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
51spellcheck () {
52 make -C ${WS_ROOT} docs-spell
53}
54
55if [ "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
63fi
64spellcheck
65green "**********************************************"
66green "* VPP Docs Checkstyle Successfully Completed *"
67green "**********************************************"