From aa439d28c5e9ceab711ee2a6e97b860b2e236ff2 Mon Sep 17 00:00:00 2001 From: Patrice Chalin Date: Tue, 23 Aug 2016 10:16:47 -0700 Subject: [PATCH] chore(travis): report bad code excerpts (BAD FILENAME) in docs (#2154) * chore(travis): report bad code excerpts (BAD FILENAME) * Only ignore build dir under dart dir Have the shredder ignore `**/dart/build/**`. --- .travis.yml | 8 +-- scripts/check-docs.sh | 56 +++++++++++++++++++ .../config/bad-code-excerpt-skip-patterns.txt | 6 ++ tools/doc-shredder/doc-shredder.js | 6 +- 4 files changed, 69 insertions(+), 7 deletions(-) create mode 100755 scripts/check-docs.sh create mode 100644 scripts/config/bad-code-excerpt-skip-patterns.txt diff --git a/.travis.yml b/.travis.yml index bf6b8894aa..7a87796437 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,18 +12,17 @@ env: - CHROME_BIN=chromium-browser - LATEST_RELEASE=2.0.0-rc.5 - TASK_FLAGS="--dgeni-log=warn" - # - TASK_FLAGS="" matrix: - TASK=lint - TASK="run-e2e-tests --fast" SCRIPT=examples-install.sh - TASK="run-e2e-tests --fast" SCRIPT=examples-install-preview.sh - - TASK=build-compile SCRIPT=deploy-install.sh WAIT="travis_wait 50" - - TASK=build-compile SCRIPT=deploy-install-preview.sh WAIT="travis_wait 50" + - TASK=build-compile SCRIPT=deploy-install.sh WAIT="travis_wait 50" POST_SCRIPT="check-docs.sh -v" + - TASK=build-compile SCRIPT=deploy-install-preview.sh WAIT="travis_wait 50" POST_SCRIPT="check-docs.sh -v" matrix: fast_finish: true allow_failures: - env: TASK="run-e2e-tests --fast" SCRIPT=examples-install-preview.sh - - env: TASK=build-compile SCRIPT=deploy-install-preview.sh WAIT="travis_wait 50" + - env: TASK=build-compile SCRIPT=deploy-install-preview.sh WAIT="travis_wait 50" POST_SCRIPT="check-docs.sh -v" before_install: - source ./scripts/env-set.sh - ./scripts/before-install.sh @@ -34,3 +33,4 @@ before_script: - sh -e /etc/init.d/xvfb start script: - $WAIT gulp $TASK $TASK_FLAGS + - if [[ -n "$POST_SCRIPT" ]]; then ./scripts/$POST_SCRIPT; fi diff --git a/scripts/check-docs.sh b/scripts/check-docs.sh new file mode 100755 index 0000000000..ff709abd1f --- /dev/null +++ b/scripts/check-docs.sh @@ -0,0 +1,56 @@ +#!/usr/bin/env bash + +set -e -o pipefail + +[[ -z "$NGIO_ENV_DEFS" ]] && . ./scripts/env-set.sh > /dev/null +if [[ "x$1" == "x-v" ]]; then VERBOSE=1; shift; fi + +SITE=./www + +CHECK_FOR=bad-code-excerpt + +LOGFILE_PREFIX=$CHECK_FOR-log +LOGFILE_FULL=$TMP/$LOGFILE_PREFIX-full.txt +LOGFILE=$TMP/$LOGFILE_PREFIX.txt + +SKIPFILE_BASE=$CHECK_FOR-skip-patterns.txt +SKIPFILE_SRC=./scripts/config/$SKIPFILE_BASE +SKIPFILE=$TMP/$SKIPFILE_BASE + +if [[ ! -d $SITE ]]; then + echo "Missing site folder $SITE" + exit 1; +fi + +travis_fold start $CHECK_FOR +echo "Searching site for HTML files containing bad code excerpts (BAD FILENAME)." +echo + +if [[ -n "$VERBOSE" ]]; then + travis_fold start $CHECK_FOR-details + echo "Full file list with grep details:" + find $SITE -type f -name "*.html" -exec grep -Hne "BAD FILENAME" {} \; | tee $LOGFILE_FULL + travis_fold end $CHECK_FOR-details + echo +else + echo "Full file list:" + find $SITE -type f -name "*.html" -exec grep -le "BAD FILENAME" {} \; | tee $LOGFILE_FULL +fi + +echo +echo "Skip patterns for paths of files known to have issues ($SKIPFILE_SRC):" + +perl -pe 's/(\s+|\s*#.*)$/\n/g' $SKIPFILE_SRC | \ + # Remove blank lines \ + grep '.' > $SKIPFILE +cat $SKIPFILE +echo +echo "File list excluding those matching skip patterns:" +grep -v -E -f $SKIPFILE $LOGFILE_FULL | tee $LOGFILE || true + +if [[ ! -s $LOGFILE ]]; then + echo "No matches, all is good!" + travis_fold end $CHECK_FOR +else + exit 1; +fi diff --git a/scripts/config/bad-code-excerpt-skip-patterns.txt b/scripts/config/bad-code-excerpt-skip-patterns.txt new file mode 100644 index 0000000000..afe85a03d3 --- /dev/null +++ b/scripts/config/bad-code-excerpt-skip-patterns.txt @@ -0,0 +1,6 @@ +# Comments & blank lines are ignored. Entry format (make pattern as specific as possible): +# # reason / issue number + +/[jt]s/.*/api/router-deprecated/ # Obsolete API entries. No issue open yet. +/ts/latest/guide/style-guide.html # https://github.com/angular/angular.io/issues/2123 +/ts/latest/guide/upgrade.html # In a transient state until RC6 - @filipe.silva diff --git a/tools/doc-shredder/doc-shredder.js b/tools/doc-shredder/doc-shredder.js index b65f8da2ce..63b65e016a 100644 --- a/tools/doc-shredder/doc-shredder.js +++ b/tools/doc-shredder/doc-shredder.js @@ -138,7 +138,7 @@ function createShredExamplePackage(shredOptions) { readFilesProcessor.sourceFiles = [ { // Process all candidate files in `src` and its subfolders ... include: includeFiles , - exclude: [ '**/node_modules/**', '**/dist/**', '**/typings/**', '**/packages/**', '**/build/**'], + exclude: [ '**/node_modules/**', '**/dist/**', '**/typings/**', '**/packages/**', '**/dart/build/**'], // When calculating the relative path to these files use this as the base path. // So `src/foo/bar.js` will have relative path of `foo/bar.js` basePath: options.examplesDir @@ -190,7 +190,7 @@ function createShredJadePackage(shredOptions) { readFilesProcessor.sourceFiles = [ { // Process all candidate files in `src` and its subfolders ... include: includeFiles , - exclude: [ '**/node_modules/**', '**/typings/**', '**/packages/**', '**/build/**', '**/_code-examples.jade'], + exclude: [ '**/node_modules/**', '**/typings/**', '**/packages/**', '**/dart/build/**', '**/_code-examples.jade'], // When calculating the relative path to these files use this as the base path. // So `src/foo/bar.js` will have relative path of `foo/bar.js` basePath: options.jadeDir @@ -244,7 +244,7 @@ var createShredMapPackage = function(mapOptions) { readFilesProcessor.sourceFiles = [ { // Process all candidate files in `src` and its subfolders ... include: includeFiles, - exclude: ['**/node_modules/**', '**/typings/**', '**/packages/**', '**/build/**'], + exclude: ['**/node_modules/**', '**/typings/**', '**/packages/**', '**/dart/build/**'], // When calculating the relative path to these files use this as the base path. // So `src/foo/bar.js` will have relative path of `foo/bar.js` basePath: options.jadeDir