mirror of
https://github.com/zhigang1992/RubyMotion.git
synced 2026-04-22 11:46:10 +08:00
to update the protocol documents
This commit is contained in:
7
Rakefile
7
Rakefile
@@ -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
|
||||
|
||||
@@ -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|
|
||||
|
||||
Reference in New Issue
Block a user