daml/docs/scripts/check-closing-quotes.sh
Richard Kapolnai 40c1cd5893
Check closing quotes (#7528)
* Missing closing quote in docs
CHANGELOG_BEGIN
CHANGELOG_END

* add Bash script to check missing quotes in docs
CHANGELOG_BEGIN
CHANGELOG_END

* add whitelist

* fix comment

* add CI job
CHANGELOG_BEGIN
CHANGELOG_END

* add CI job to azure pipeline

* use devenv in azure-pipelines.yml

Co-authored-by: Gary Verhaegen <gary.verhaegen@digitalasset.com>

* remove unnecessary yml

* fix quotes in Bifunctor.daml

* add check to BUILD.bazel with extended whitelist

* refactor: call bash script from BUILD.bazel

* Revert "use devenv in azure-pipelines.yml"

This reverts commit 28ab2c70fb.

* Revert "add CI job to azure pipeline"

This reverts commit 0eaa5188fe.

* filter whitelist in output too

* Update docs/scripts/check-closing-quotes.sh.whitelist

Co-authored-by: Bernhard Elsner <40762178+bame-da@users.noreply.github.com>

* fix Bifunctor.daml quotes

* Update docs/scripts/check-closing-quotes.sh.whitelist

Co-authored-by: Bernhard Elsner <40762178+bame-da@users.noreply.github.com>

* use ~ instead of ` for section titles

* rename to allowlist

* revert Bifunctor quote changes back to 3 backticks

* fix filename

* Remove line breaks in quotes (#7550)

* remove line breaks in quotes
CHANGELOG_BEGIN
CHANGELOG_END

* remove line breaks in quotes
CHANGELOG_BEGIN
CHANGELOG_END

* README: avoid line breaks

* merge rename

* revert: use triple backticks in Bifunctor

Co-authored-by: Gary Verhaegen <gary.verhaegen@digitalasset.com>
Co-authored-by: Bernhard Elsner <40762178+bame-da@users.noreply.github.com>
2020-10-02 14:53:10 +02:00

38 lines
967 B
Bash
Executable File

#!/usr/bin/env bash
# Copyright (c) 2020 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
# Check for invalid quote usage such as "variable `x``"
DIR="$1"
ALLOWLIST="$2"
if [[ $# -ne 2 ]]
then
echo "Usage: $0 directory allow-list"
exit 1
fi
if ! test -f "$ALLOWLIST"; then
echo ERROR: Allow-list file not found: "$ALLOWLIST"
exit 1
fi
ERRORS=0
REGEX='^(?!([^`]*(((`[^`]*`)|(``[^`]*``))[^`]*)*)$$)'
while read FILE; do
if grep --invert-match --file="$ALLOWLIST" "$FILE" | grep --quiet --perl-regexp "$REGEX"; then
echo Quotation error in "\`$FILE'":
grep --invert-match --file="$ALLOWLIST" "$FILE" | grep --perl-regexp "$REGEX"
echo
ERRORS=$((ERRORS+1))
fi
done <<< $(find "$DIR" -name '*.rst')
if [ $ERRORS -gt 0 ]; then
echo "ERROR: $ERRORS file(s) found with errors, see above."
echo "You can add lines to \`$ALLOWLIST' to ignore false positives."
exit 1
fi