Squashed 'third_party/rules_rust/' content from commit bf59038ca
git-subtree-dir: third_party/rules_rust
git-subtree-split: bf59038cac11798cbaef9f3bf965bad8182b97fa
Signed-off-by: Brian Silverman <bsilver16384@gmail.com>
Change-Id: I5a20e403203d670df467ea97dde9a4ac40339a8d
diff --git a/docs/test_docs.sh b/docs/test_docs.sh
new file mode 100755
index 0000000..f6677b9
--- /dev/null
+++ b/docs/test_docs.sh
@@ -0,0 +1,27 @@
+#!/bin/bash
+
+set -euo pipefail
+
+if [[ -n "${BUILD_WORKSPACE_DIRECTORY:-}" ]]; then
+ DOCS_WORKSPACE="${BUILD_WORKSPACE_DIRECTORY}"
+else
+ # Get the directory of the current script when not running under
+ # Bazel (as indicated by the lack of BUILD_WORKSPACE_DIRECTORY).
+ DOCS_WORKSPACE="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
+fi
+
+pushd "${DOCS_WORKSPACE}" &> /dev/null
+# It's important to clean the workspace so we don't end up with unintended
+# docs artifacts in the new commit.
+bazel clean \
+&& bazel build //... \
+&& cp bazel-bin/*.md . \
+&& chmod 0644 *.md
+
+if [ -n "$(git status --porcelain)" ]; then
+ git status
+ echo '/docs is out of date. Please run `./docs/update_docs.sh` from the root of rules_rust and push the results' >&2
+ exit 1
+fi
+
+popd &> /dev/null