intellij-sdk-code-samples/_rake/lib/summary_checker.rb
2015-05-26 19:02:38 +03:00

27 lines
642 B
Ruby

require 'rexml/xpath'
require_relative './util/markdown'
module Docs
class SummaryChecker
def self.check(path)
xml = Docs::Utils.md2xml(path)
dir = File.dirname(path)
is_ok = true
missing_files = []
xml.elements.each("//a") do |link|
href = link.attribute('href').to_s
is_external = href.start_with?('http://', 'https://', 'ftp://', '//')
path = "#{dir}/#{href.gsub(/\.html$/, '.md')}"
if !is_external and !File.file?(path)
is_ok = false unless is_ok
missing_files.push href
break
end
end
missing_files
end
end
end