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

26 lines
546 B
Ruby

require 'rexml/xpath'
require_relative './lic/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
path = "#{dir}/#{href.gsub(/\.html$/, '.md')}"
if !File.file?(path)
is_ok = false unless is_ok
missing_files.push href
break
end
end
missing_files
end
end
end