github.com/KYVENetwork/cometbft/v38@v38.0.3/docs/presubmit.sh (about)

     1  #!/bin/bash
     2  #
     3  # This script verifies that each document in the docs and architecture
     4  # directory has a corresponding table-of-contents entry in its README file.
     5  #
     6  # This can be run manually from the command line.
     7  # It is also run in CI via the docs-toc.yml workflow.
     8  #
     9  set -euo pipefail
    10  
    11  readonly base="$(dirname $0)"
    12  cd "$base"
    13  
    14  readonly workdir="$(mktemp -d)"
    15  trap "rm -fr -- '$workdir'" EXIT
    16  
    17  checktoc() {
    18      local dir="$1"
    19      local tag="$2"'-*-*'
    20      local out="$workdir/${dir}.out.txt"
    21      (
    22          cd "$dir" >/dev/null
    23          find . -maxdepth 1 -type f -name "$tag" -not -exec grep -q "({})" README.md ';' -print
    24      ) > "$out"
    25      if [[ -s "$out" ]] ; then
    26          echo "-- The following files in $dir lack a ToC entry:
    27  "
    28          cat "$out"
    29          return 1
    30      fi
    31  }
    32  
    33  err=0
    34  
    35  # Verify that each RFC and ADR has a ToC entry in its README file.
    36  checktoc architecture adr || ((err++))
    37  checktoc rfc rfc || ((err++))
    38  
    39  exit $err