diff --git a/.travis.yml b/.travis.yml index 21efe485a..290ad7607 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,6 +14,7 @@ script: - docker run -v $TRAVIS_BUILD_DIR:/documents/ --name asciidoctor-epub3 asciidoctor/docker-asciidoctor asciidoctor-epub3 -D /documents/output index.adoc - cp -r assets output/ - cp -r -n legacy/* output/ + - ./generate_rules_json.sh output - mv output/index.pdf output/zalando-guidelines.pdf - mv output/index.epub output/zalando-guidelines.epub diff --git a/build.sh b/build.sh index 0dfd43dd4..1c6d588cd 100755 --- a/build.sh +++ b/build.sh @@ -21,12 +21,7 @@ docker run -v ${SCRIPT_DIR}:/documents/ asciidoctor/docker-asciidoctor asciidoct cp -r assets ${BUILD_DIR}/ cp -r -n legacy/* ${BUILD_DIR}/ -grep -Pzoh "(?s)\[(#[0-9]+)\]\n[=]+\s+.*?\n" chapters/* | \ - sed '$!N;s/\n/ /' | tr -d "[]{}\000"| sed '/^\s*$/d' | \ - sort | perl -pi -e 'chomp if eof' | \ - jq -Rs '{rules: split("\n") }' | \ - jq '{rules: .rules | map(. | {id: split(" == ")[0], title: split(" == ")[1]})}' \ - > ${BUILD_DIR}/rules +./generate_rules_json.sh mv ${BUILD_DIR}/index.pdf ${BUILD_DIR}/zalando-guidelines.pdf mv ${BUILD_DIR}/index.epub ${BUILD_DIR}/zalando-guidelines.epub diff --git a/generate_rules_json.sh b/generate_rules_json.sh new file mode 100755 index 000000000..917098be3 --- /dev/null +++ b/generate_rules_json.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash +# This script generates a JSON with information about the guideline rules. + +build_dir=${1:-output} + +grep -Pzoh "(?s)\[(#[0-9]+)\]\n[=]+\s+.*?\n" chapters/* | \ + sed '$!N;s/\n/ /' | tr -d "[]{}\000"| sed '/^\s*$/d' | \ + sort | perl -pi -e 'chomp if eof' | \ + jq -Rs '{rules: split("\n") }' | \ + jq '{rules: .rules | map(. | {id: split(" == ")[0], title: split(" == ")[1]})}' \ + > ${build_dir}/rules