Add mkdocs bazel rules
I want to add some more detailed AOS documentation. mkdocs seems like a
reasonable choice, since it allows markdown (so GitHub and Gerrit will
still be able to render it even for people not using mkdocs), and it
was reasonably straightforwards to integrate.
Now that I am calling some python code that is using pip in the exec
configuration, also needed to set --host_platform for the
k8_upstream_python config.
Change-Id: I987f531759170272686f6488271be732827d0f9b
Signed-off-by: James Kuszmaul <james.kuszmaul@bluerivertech.com>
diff --git a/documentation/mkdocs_bin.py b/documentation/mkdocs_bin.py
new file mode 100755
index 0000000..86b15ee
--- /dev/null
+++ b/documentation/mkdocs_bin.py
@@ -0,0 +1,22 @@
+#!/usr/bin/env python3
+"""This is a small wrapper to allow bazel to call mkdocs as a script.
+
+Because the mkdocs library handles consuming command-line arguments directly,
+we (rather than attempting to mess with arguments ourselves), use environment
+variables to communicate certain flags. Namely:
+If the OUTPUT environment variable is set, then we will tar up the output of
+the SITE_DIR directory into the OUTPUT file. This is used to make the mkdocs
+output bazel-friendly by only outputting a single file.
+"""
+from mkdocs.__main__ import cli
+import os
+import sys
+import tarfile
+try:
+ cli()
+except SystemExit as err:
+ if err.code != 0:
+ raise err
+if "OUTPUT" in os.environ:
+ with tarfile.open(os.environ["OUTPUT"], "w") as tarball:
+ tarball.add(os.environ["SITE_DIR"], arcname="")