diff options
-rwxr-xr-x | scripts/serve-docs.sh | 36 | ||||
-rw-r--r-- | site/BUILD | 30 | ||||
-rwxr-xr-x | site/jekyll-tree.sh | 110 | ||||
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/BUILD | 2 | ||||
-rw-r--r-- | tools/build_defs/docker/BUILD | 5 | ||||
-rw-r--r-- | tools/build_defs/pkg/BUILD | 5 |
6 files changed, 187 insertions, 1 deletions
diff --git a/scripts/serve-docs.sh b/scripts/serve-docs.sh new file mode 100755 index 0000000000..cd94633a16 --- /dev/null +++ b/scripts/serve-docs.sh @@ -0,0 +1,36 @@ +#!/bin/bash +# Copyright 2016 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -eu + +readonly PORT=${1-12345} + +readonly WORKING_DIR=$(mktemp -d) +trap "rm -rf $WORKING_DIR" EXIT + +function check { + which $1 > /dev/null || (echo "$1 not installed. Please install $1."; exit 1) +} + +function main { + check jekyll + + bazel build //site:jekyll-tree.tar + tar -xf bazel-genfiles/site/jekyll-tree.tar -C $WORKING_DIR + + cd $WORKING_DIR + jekyll serve --port $PORT +} +main diff --git a/site/BUILD b/site/BUILD index 2cc97369b1..d1107bc6c8 100644 --- a/site/BUILD +++ b/site/BUILD @@ -64,7 +64,7 @@ pkg_tar( ) pkg_tar( - name = "jekyll-tree", + name = "jekyll-base", deps = [ ":bootstrap-css", ":bootstrap-images", @@ -74,3 +74,31 @@ pkg_tar( ":jekyll-files", ], ) + +pkg_tar( + name = "skylark-rule-docs", + files = [ + "//tools/build_defs/docker:README.md", + "//tools/build_defs/pkg:README.md", + ], + strip_prefix = "/tools/build_defs", +) + +genrule( + name = "jekyll-tree", + srcs = [ + ":jekyll-base", + ":skylark-rule-docs", + "//src/main/java/com/google/devtools/build/lib:gen_buildencyclopedia", + "//src/main/java/com/google/devtools/build/lib:gen_skylarklibrary", + ], + outs = ["jekyll-tree.tar"], + cmd = ("$(location jekyll-tree.sh) $@ " + + "$(location :jekyll-base) " + + "$(location :skylark-rule-docs) " + + "$(location //src/main/java/com/google/devtools/build/lib:gen_buildencyclopedia) " + + "$(location //src/main/java/com/google/devtools/build/lib:gen_skylarklibrary)"), + tools = [ + "jekyll-tree.sh", + ], +) diff --git a/site/jekyll-tree.sh b/site/jekyll-tree.sh new file mode 100755 index 0000000000..abd33236fe --- /dev/null +++ b/site/jekyll-tree.sh @@ -0,0 +1,110 @@ +#!/bin/bash +# Copyright 2016 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +set -eu + +readonly OUTPUT=${PWD}/$1 +shift +readonly JEKYLL_BASE=${PWD}/$1 +shift +readonly SKYLARK_RULE_DOCS=${PWD}/$1 +shift +readonly BE_ZIP=${PWD}/$1 +shift +readonly SL_ZIP=${PWD}/$1 + +# Create temporary directory that is removed when this script exits. +readonly TMP=$(mktemp -d) +readonly OUT_DIR="$TMP/out" +trap "rm -rf ${TMP}" EXIT + +function setup { + mkdir -p "$OUT_DIR" + cd "$OUT_DIR" + tar -xf "${JEKYLL_BASE}" +} + +# Unpack the Build Encyclopedia into docs/be +function unpack_build_encyclopedia { + local be_dir="$OUT_DIR/docs/be" + mkdir -p "$be_dir" + unzip -qq "$BE_ZIP" -d "$be_dir" + mv "$be_dir/be-nav.html" "$OUT_DIR/_includes" +} + +# Unpack the Skylark Library into docs/skylark/lib +function unpack_skylark_library { + local sl_dir="$OUT_DIR/docs/skylark/lib" + mkdir -p "$sl_dir" + unzip -qq "$SL_ZIP" -d "$sl_dir" + mv "$sl_dir/skylark-nav.html" "$OUT_DIR/_includes" +} + +function copy_skylark_rule_doc { + local rule_family=$1 + local rule_family_name=$2 + local be_dir="$OUT_DIR/docs/be" + local tempf=$(mktemp -t bazel-skylark-XXXXXX) + + ( cat <<EOF +--- +layout: documentation +title: ${rule_family_name} Rules +--- +EOF + cat "$TMP/skylark/$rule_family/README.md"; ) > "$be_dir/${rule_family}.md" +} + +function unpack_skylark_rule_docs { + local tmp_dir=$TMP/skylark + mkdir -p $tmp_dir + cd "$tmp_dir" + tar -xf "${SKYLARK_RULE_DOCS}" + copy_skylark_rule_doc docker "Docker" + copy_skylark_rule_doc pkg "Packaging" +} + +function process_doc { + local f=$1 + local tempf=$(mktemp -t bazel-doc-XXXXXX) + + chmod +w $f + cat "$f" | sed 's,\.md,.html,g;s,Blaze,Bazel,g;s,blaze,bazel,g' > "$tempf" + cat "$tempf" > "$f" +} + +function process_docs { + for f in $(find "$OUT_DIR/docs" -name "*.html"); do + process_doc $f + done + for f in $(find "$OUT_DIR/docs" -name "*.md"); do + process_doc $f + done +} + +function package_output { + cd "$OUT_DIR" + tar -hcf $OUTPUT $(find . -type f | sort) +} + +function main { + setup + unpack_build_encyclopedia + unpack_skylark_library + unpack_skylark_rule_docs + process_docs + package_output +} +main diff --git a/src/main/java/com/google/devtools/build/lib/BUILD b/src/main/java/com/google/devtools/build/lib/BUILD index a2848fa67a..9e8dd05fc5 100644 --- a/src/main/java/com/google/devtools/build/lib/BUILD +++ b/src/main/java/com/google/devtools/build/lib/BUILD @@ -975,6 +975,7 @@ genrule( "//src/main/java/com/google/devtools/build/docgen:docgen_bin", "//src/main/java/com/google/devtools/build/docgen:docgen_javalib", ], + visibility = ["//site:__pkg__"], ) # The skylark repository classes are passed as parameter of the Skylark documentation generator. @@ -994,6 +995,7 @@ genrule( " ".join(SKYLARK_REPOSITORY_CLASSES) + " && zip -qj $@ $(@D)/skylark-lib/*", tools = ["//src/main/java/com/google/devtools/build/docgen:skydoc_bin"], + visibility = ["//site:__pkg__"], ) # Bootstrapping SingleJar using Skylark rules diff --git a/tools/build_defs/docker/BUILD b/tools/build_defs/docker/BUILD index 2832767596..b774fee2e5 100644 --- a/tools/build_defs/docker/BUILD +++ b/tools/build_defs/docker/BUILD @@ -6,6 +6,11 @@ filegroup( visibility = ["//tools:__pkg__"], ) +exports_files( + ["README.md"], + visibility = ["//site:__pkg__"], +) + TEST_TARGETS = [ "base_with_entrypoint", "base_with_volume", diff --git a/tools/build_defs/pkg/BUILD b/tools/build_defs/pkg/BUILD index 30a9c96289..205d7fac9d 100644 --- a/tools/build_defs/pkg/BUILD +++ b/tools/build_defs/pkg/BUILD @@ -6,6 +6,11 @@ filegroup( visibility = ["//tools:__pkg__"], ) +exports_files( + ["README.md"], + visibility = ["//site:__pkg__"], +) + # Used by pkg_deb py_library( name = "archive", |