diff --git a/.gitignore b/.gitignore index 16182c5d0d..0baf015229 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -/_site \ No newline at end of file +/_site diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000000..cf4486b6e0 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,14 @@ +language: ruby +rvm: + - 2.1 +python: + - 2.7 +install: + - sudo pip install html5validator + - bundle install +script: + - bundle exec jekyll build + - ./script/cibuild +env: + global: + - NOKOGIRI_USE_SYSTEM_LIBRARIES=true # speeds up installation of html-proofer \ No newline at end of file diff --git a/Gemfile b/Gemfile index f5f9ff381f..f365161349 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,3 @@ source 'https://rubygems.org' - gem 'github-pages' -gem 'jekyll-redirect-from' +gem 'html-proofer' \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock index 29f02ef2ee..fd817a6489 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -8,6 +8,7 @@ GEM minitest (~> 5.1) thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) + addressable (2.3.7) blankslate (2.1.2.4) celluloid (0.16.0) timers (~> 4.0.0) @@ -16,8 +17,11 @@ GEM coffee-script (2.3.0) coffee-script-source execjs - coffee-script-source (1.9.0) + coffee-script-source (1.9.1) colorator (0.1) + colored (1.2) + ethon (0.7.3) + ffi (>= 1.3.0) execjs (2.3.0) fast-stemmer (1.0.2) ffi (1.9.6) @@ -47,6 +51,14 @@ GEM html-pipeline (1.9.0) activesupport (>= 2) nokogiri (~> 1.4) + html-proofer (2.1.0) + addressable (~> 2.3) + colored (~> 1.2) + mercenary (~> 0.3.2) + nokogiri (~> 1.5) + parallel (~> 1.3) + typhoeus (~> 0.7) + yell (~> 2.0) i18n (0.7.0) jekyll (2.4.0) classifier-reborn (~> 2.0) @@ -95,9 +107,10 @@ GEM net-dns (0.8.0) nokogiri (1.6.6.2) mini_portile (~> 0.6.0) + parallel (1.4.0) parslet (1.5.0) blankslate (~> 2.0) - posix-spawn (0.3.9) + posix-spawn (0.3.10) public_suffix (1.4.6) pygments.rb (0.6.1) posix-spawn (~> 0.3.6) @@ -108,20 +121,23 @@ GEM rdiscount (2.1.7) redcarpet (3.1.2) safe_yaml (1.0.4) - sass (3.4.11) + sass (3.4.13) terminal-table (1.4.5) thread_safe (0.3.4) timers (4.0.1) hitimes toml (0.1.2) parslet (~> 1.5.0) + typhoeus (0.7.1) + ethon (>= 0.7.1) tzinfo (1.2.2) thread_safe (~> 0.1) yajl-ruby (1.2.1) + yell (2.0.5) PLATFORMS ruby DEPENDENCIES github-pages - jekyll-redirect-from + html-proofer diff --git a/_config.yml b/_config.yml index ccdbbf3b3a..e93cb222b5 100644 --- a/_config.yml +++ b/_config.yml @@ -4,4 +4,5 @@ permalink: /blog/:year/:month/:day/:title/ redcarpet: extensions: ['with_toc_data', 'tables'] gems: - - jekyll-redirect-from \ No newline at end of file + - jekyll-redirect-from +exclude: [vendor] diff --git a/script/cibuild b/script/cibuild new file mode 100755 index 0000000000..59c68013bf --- /dev/null +++ b/script/cibuild @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) +cd "$DIR" +echo "------------------------------------------------------------------------" +echo "* Task #1: html5validator" +./filter-html5validator +echo +echo "------------------------------------------------------------------------" +echo "* Task #2: htmlproof" +./filter-htmlproof +echo +echo "------------------------------------------------------------------------" diff --git a/script/filter-html5validator b/script/filter-html5validator new file mode 100755 index 0000000000..0f87793e6e --- /dev/null +++ b/script/filter-html5validator @@ -0,0 +1,16 @@ +#!/usr/bin/env bash + +DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) +cd "$DIR" +source "$DIR/filter-lib.sh" + +filter_errors() { + grep -v "Bad value “X-UA-Compatible” for attribute “http-equiv” on element “meta”" #| + #grep " error: " +} + +filter_html5validator() { + filter_it "$DIR/../_site/" "html5validator --blacklist docs" +} + +filter_html5validator diff --git a/script/filter-htmlproof b/script/filter-htmlproof new file mode 100755 index 0000000000..290afdcb41 --- /dev/null +++ b/script/filter-htmlproof @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) +cd "$DIR" +source "$DIR/filter-lib.sh" + +filter_errors() { + grep -v "linking to /docs/stable/elixir/Kernel.html#%7C%3E/2, but %7C%3E/2 does not exist" | + grep -vP "internally linking to \/docs\/.*, which does not exist" | + grep -vP "trying to find hash of \/docs\/.*, but .* does not exist" | + + filter_more_errors | + + #delete every file hat has no error (that is, anything file that is not follow by a line starting with " * ") + perl -0777 -pe 's/\- .*\n(?!\s+\*\s+)//g' +} + +filter_more_errors() { + perl -CSAD -ne ' + BEGIN { + my $current_file = ""; + } + if ( /^- / ) { + $current_file = $_; + } elsif ( $current_file =~ /getting_started/ ) { + s/\s+\*\s+no favicon specified\n//; + } + print + ' $1 +} + +filter_success() { + perl -CSAD -pe "s/\|\s+Error:\s+HTML-Proofer found \d+ failures?\!//g" | + perl -0777 -CSAD -pe "s/\n{3,}/\n\n/g" +} + +filter_htmlproof() { + filter_it "$DIR/../" "bundle exec htmlproof ./_site --file-ignore /docs/ --only-4xx --check-favicon --check-html --check-external-hash" +} + +filter_htmlproof \ No newline at end of file diff --git a/script/filter-lib.sh b/script/filter-lib.sh new file mode 100644 index 0000000000..a8ca6e43a2 --- /dev/null +++ b/script/filter-lib.sh @@ -0,0 +1,48 @@ +#!/usr/bin/env bash + +TEMP_DIR=$(mktemp -dt "$(basename $0).XXXXXXXXXX") + +STDOUT="$TEMP_DIR/htmlproof_stdout" +STDERR="$TEMP_DIR/htmlproof_stderr" +STDERR_PRE="$TEMP_DIR/htmlproof_stderr_pre" + +clean_temp_files() { + rm -rf "$TEMP_DIR" 2> /dev/null +} + +function validate() { + local cmd="$1" + echo "$cmd" && + $cmd 1>"$STDOUT" 2>"$STDERR_PRE" + cat "$STDERR_PRE" | filter_errors >"$STDERR" +} + +filter_success() { + perl -0777 -CSAD -pe "s/\n{3,}/\n\n/g" +} + +# filter_it +filter_it() { + local dir=$(readlink -f "$1") + pushd "$dir" 1> /dev/null + pwd + validate "$2" + errors=$(<"$STDERR") + length=${#errors} + if [ "$length" -gt 0 ]; then + echo "ERROR: Documents are not valid" >&2 + echo + cat "$STDERR" >&2 + clean_temp_files + popd 1> /dev/null + return 1 + else + cat "$STDOUT" | filter_success + echo + echo "OK: Documents successfully validated" + cat "$STDERR" >&2 + clean_temp_files + popd 1> /dev/null + return 0 + fi +}