-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use HTMLProofer to validate documentation links (#3737)
use HTMLProofer to validate documentation links also fix a couple links
- Loading branch information
Showing
5 changed files
with
89 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
require 'html-proofer' | ||
require 'html/pipeline' | ||
require 'find' | ||
require 'fileutils' | ||
|
||
# make an out dir | ||
Dir.mkdir("out") unless File.exist?("out") | ||
|
||
pipeline = HTML::Pipeline.new [ | ||
HTML::Pipeline::MarkdownFilter, | ||
HTML::Pipeline::TableOfContentsFilter | ||
], :gfm => true | ||
|
||
# iterate over files, and generate HTML from Markdown | ||
Find.find("./docs") do |path| | ||
if File.extname(path) == ".md" | ||
contents = File.read(path) | ||
result = pipeline.call(contents) | ||
dirname = File.dirname(path) | ||
FileUtils.mkdir_p ("out/" + dirname) | ||
content_str = result[:output].to_s | ||
filename = path.split("/").pop.sub('.md', '.html') | ||
if filename == "sidebar.html" | ||
content_str = content_str.gsub! '/%24version' '.' | ||
end | ||
File.open("out/#{dirname}/#{filename}", 'w') { |file| file.write(content_str) } | ||
end | ||
end | ||
# url_ignore - ignore links content not in branch | ||
# file_ignore - ignore CAS spec b/c it has lots of bad anchor links, only *.html files are processed | ||
options = { | ||
:file_ignore => [ %r{.*/CAS-Protocol-Specification.html} ], | ||
:disable_external => true, | ||
:only_4xx => true, | ||
:empty_alt_ignore => true, | ||
:url_ignore => [ %r{^/cas}, %r{^../images/}, %r{^../../developer/} ], | ||
} | ||
# test your out dir! | ||
HTMLProofer.check_directory("./out", options).run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/bin/bash | ||
|
||
source ./ci/functions.sh | ||
|
||
runBuild=false | ||
echo "Reviewing changes that might affect the Gradle build..." | ||
currentChangeSetAffectsDocumentation | ||
retval=$? | ||
if [ "$retval" == 0 ] | ||
then | ||
echo "Found changes that affect project documentation." | ||
runBuild=true | ||
else | ||
echo "Changes do NOT affect project documentation." | ||
runBuild=false | ||
fi | ||
|
||
if [ "$runBuild" = false ]; then | ||
exit 0 | ||
fi | ||
|
||
HTML_PROOFER_IMAGE=hdeadman/html-proofer:latest | ||
DOCS_FOLDER=$(pwd)/docs/cas-server-documentation | ||
DOCS_OUTPUT=$(pwd)/docs/cas-server-documentation/build/out | ||
HTML_PROOFER_SCRIPT=$(pwd)/ci/html-proofer-docs.rb | ||
|
||
echo "Running html-proof image: ${HTML_PROOFER_IMAGE}" | ||
docker run --name="html-proofer" --rm \ | ||
--workdir /root \ | ||
-v ${DOCS_FOLDER}:/root/docs \ | ||
-v ${DOCS_OUTPUT}:/root/out \ | ||
-v ${HTML_PROOFER_SCRIPT}:/root/html-proofer-docs.rb \ | ||
--entrypoint /usr/local/bin/ruby \ | ||
${HTML_PROOFER_IMAGE} \ | ||
/root/html-proofer-docs.rb | ||
retVal=$? | ||
if [[ ${retVal} -eq 0 ]]; then | ||
echo "HTML Proofer found no bad links." | ||
exit 0 | ||
else | ||
echo "HTML Proofer found bad links." | ||
exit ${retVal} | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters