to update the protocol documents

This commit is contained in:
Watson
2012-11-05 10:17:35 +09:00
parent 906a73b7fd
commit 66b108bed0
2 changed files with 38 additions and 0 deletions

View File

@@ -244,6 +244,13 @@ namespace :doc do
sh "#{YARDOC} --title 'RubyMotion API Reference' -o ../#{OUTPUT_DIR} #{rubymotion_files} #{docset_files} - ../doc/RubyMotion.md #{frameworks}"
FileUtils.ln "#{OUTPUT_DIR}/_index.html", "#{OUTPUT_DIR}/index.html" unless File.exist?("#{OUTPUT_DIR}/index.html")
# update Protocol documents
protocol_name_list = File.read("#{DOCSET_RUBY_FILES_DIR}/protocol_list")
protocol_name_list.lines.each do |protocol|
protocol.strip!
DocsetGenerator.modify_protocol_document("#{OUTPUT_DIR}/#{protocol}.html")
end
end
namespace :list do

View File

@@ -178,6 +178,12 @@ class DocsetGenerator
parse_html_method(doc, code)
code << "end"
# save protocol name into list
File.open(File.join(@rb_files_dir, "protocol_list"), 'a') do |io|
io.puts name
end
return code
end
@@ -234,6 +240,31 @@ class DocsetGenerator
end
end
def self.modify_protocol_document(path)
unless File.exists?(path)
warn "File not exists : #{path}"
return nil
end
data = File.read(path)
data.gsub!(/\s*Class:/, 'Protocol:')
doc = Nokogiri::HTML(data)
# remove 'Inherits' box
doc.xpath("//dl[@class='box']").remove
# remove 'Methods inherited from NSObject'
doc.xpath("//h3[@class='inherited']").remove
doc.xpath("//p[@class='inherited']").remove
# remove 'Constructor Details'
doc.xpath("//div[@id='constructor_details']").remove
# remove 'Dynamic Method Handling'
doc.xpath("//div[@id='method_missing_details']").remove
File.open(path, "w") { |io| io.print doc.to_html }
end
def initialize(outpath, paths)
@input_paths = []
paths.each do |path|