github.com/yacovm/fabric@v2.0.0-alpha.0.20191128145320-c5d4087dc723+incompatible/scripts/metrics_doc.sh (about) 1 #!/bin/bash -e 2 3 # Copyright IBM Corp All Rights Reserved. 4 # 5 # SPDX-License-Identifier: Apache-2.0 6 7 fabric_dir="$(cd "$(dirname "$0")/.." && pwd)" 8 metrics_template="${fabric_dir}/docs/source/metrics_reference.rst.tmpl" 9 metrics_doc="${fabric_dir}/docs/source/metrics_reference.rst" 10 11 gendoc_command="go run github.com/hyperledger/fabric/common/metrics/cmd/gendoc -template ${metrics_template}" 12 13 case "$1" in 14 # check if the metrics documentation is up to date with the metrics 15 # options in the tree 16 "check") 17 if [ -n "$(diff -u <(cd "${fabric_dir}" && ${gendoc_command}) "${metrics_doc}")" ]; then 18 echo "The Fabric metrics reference documentation is out of date." 19 echo "Please run '$0 generate' to update the documentation." 20 exit 1 21 fi 22 ;; 23 24 # generate the metrics documentation 25 "generate") 26 (cd "${fabric_dir}" && ${gendoc_command} > "${metrics_doc}") 27 ;; 28 29 *) 30 echo "Please specify check or generate" 31 exit 1 32 ;; 33 esac