mirror of
https://github.com/zhigang1992/RubyMotion.git
synced 2026-05-16 18:09:31 +08:00
generate classes list
This commit is contained in:
1
Gemfile
1
Gemfile
@@ -1,4 +1,5 @@
|
||||
source :rubygems
|
||||
|
||||
gem "nokogiri"
|
||||
gem "redcarpet"
|
||||
gem "yard", :github => "Watson1978/yard", :branch => "macruby"
|
||||
|
||||
@@ -9,10 +9,12 @@ GEM
|
||||
remote: http://rubygems.org/
|
||||
specs:
|
||||
nokogiri (1.5.5)
|
||||
redcarpet (2.2.2)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
nokogiri
|
||||
redcarpet
|
||||
yard!
|
||||
|
||||
108
Rakefile
108
Rakefile
@@ -168,34 +168,94 @@ task :upload do
|
||||
end
|
||||
|
||||
namespace :doc do
|
||||
desc "Generate API Documents"
|
||||
task :api do
|
||||
require './doc/docset'
|
||||
require 'fileutils'
|
||||
OUTPUT_DIR = "api"
|
||||
TARGETS = %w{
|
||||
array.c bignum.c class.c compar.c complex.c dir.c encoding.c enum.c
|
||||
enumerator.c env.c error.c eval.c eval_error.c eval_jump.c eval_safe.c
|
||||
file.c hash.c io.c kernel.c load.c marshal.c math.c numeric.c object.c
|
||||
pack.c prec.c proc.c process.c random.c range.c rational.c re.c
|
||||
signal.c sprintf.c string.c struct.c symbol.c thread.c time.c
|
||||
transcode.c ucnv.c util.c variable.c vm.cpp vm_eval.c vm_method.c
|
||||
NSArray.m NSDictionary.m NSString.m bridgesupport.cpp gcd.c objc.m sandbox.c
|
||||
}
|
||||
rubymotion_files = TARGETS.join(" ")
|
||||
require './doc/docset'
|
||||
require 'fileutils'
|
||||
|
||||
DOCSET_PATHS = %w{
|
||||
~/Library/Developer/Shared/Documentation/DocSets/com.apple.adc.documentation.AppleiOS6.0.iOSLibrary.docset/Contents/Resources/Documents/documentation/UIKit/Reference
|
||||
~/Library/Developer/Shared/Documentation/DocSets/com.apple.adc.documentation.AppleiOS6.0.iOSLibrary.docset/Contents/Resources/Documents/documentation/Cocoa/Reference
|
||||
}
|
||||
DOCSET_RUBY_FILES_DIR = '/tmp/rb_docset'
|
||||
YARDOC = "cd vm; bundle exec yardoc --legacy"
|
||||
RUBY_SOURCES = %w{
|
||||
array.c bignum.c class.c compar.c complex.c dir.c encoding.c enum.c
|
||||
enumerator.c env.c error.c eval.c eval_error.c eval_jump.c eval_safe.c
|
||||
file.c hash.c io.c kernel.c load.c marshal.c math.c numeric.c object.c
|
||||
pack.c prec.c proc.c process.c random.c range.c rational.c re.c
|
||||
signal.c sprintf.c string.c struct.c symbol.c thread.c time.c
|
||||
transcode.c ucnv.c util.c variable.c vm.cpp vm_eval.c vm_method.c
|
||||
NSArray.m NSDictionary.m NSString.m bridgesupport.cpp gcd.c objc.m sandbox.c
|
||||
}
|
||||
DOCSET = {
|
||||
"UIKit" => "~/Library/Developer/Shared/Documentation/DocSets/com.apple.adc.documentation.AppleiOS6.0.iOSLibrary.docset/Contents/Resources/Documents/documentation/UIKit/Reference",
|
||||
"Foundation" => "~/Library/Developer/Shared/Documentation/DocSets/com.apple.adc.documentation.AppleiOS6.0.iOSLibrary.docset/Contents/Resources/Documents/documentation/Cocoa/Reference"
|
||||
}
|
||||
OUTPUT_DIR = "api"
|
||||
DOCSET_RUBY_FILES_DIR = '/tmp/rb_docset'
|
||||
|
||||
desc "Generate API Documents"
|
||||
task :api => [:"list:framework"] do
|
||||
rubymotion_files = RUBY_SOURCES.join(" ")
|
||||
|
||||
# generate Ruby code from iOS SDK docset
|
||||
DocsetGenerator.new('docset', DOCSET_PATHS).generate_ruby_code
|
||||
docset_paths = []
|
||||
DOCSET.each_value{ |x| docset_paths << x }
|
||||
DocsetGenerator.new('docset', docset_paths).generate_ruby_code
|
||||
|
||||
docset_files = Dir.glob(File.join(DOCSET_RUBY_FILES_DIR, '*.rb')).join(" ")
|
||||
frameworks = Dir.glob(File.join(OUTPUT_DIR, '*.md')).map{ |x| "../#{x}" }.join(" ")
|
||||
|
||||
FileUtils.rm_rf OUTPUT_DIR
|
||||
sh "cd vm; bundle exec yardoc --legacy -o ../#{OUTPUT_DIR} #{rubymotion_files} #{docset_files}"
|
||||
sh "#{YARDOC} -o ../#{OUTPUT_DIR} #{rubymotion_files} #{docset_files} - ../doc/RubyMotion.md #{frameworks}"
|
||||
end
|
||||
end
|
||||
|
||||
namespace :list do
|
||||
def save_class_list(title, doc_output_dir, output_file_path)
|
||||
doc_files = Dir.glob(File.join(doc_output_dir, '**/*.html')).sort.map { |x| x.sub("#{doc_output_dir}/", '')}
|
||||
File.open(output_file_path, "w") { |io|
|
||||
io.puts "# @markup markdown"
|
||||
io.puts "# @title #{title}"
|
||||
io.puts "# #{title}"
|
||||
|
||||
doc_files.each do |file|
|
||||
next if file =~ /index.html/
|
||||
next if file =~ /_list.html/
|
||||
next if file == "frames.html"
|
||||
next if file == "top-level-namespace.html"
|
||||
|
||||
class_name = file.sub(/(\w+)\/(\w+)/, '\1::\2')
|
||||
class_name = class_name.sub('.html', '')
|
||||
io.puts "- [#{class_name}](#{file})"
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
def save_framework_class_list(name, path)
|
||||
# generate Ruby code from iOS SDK docset
|
||||
FileUtils.rm_rf OUTPUT_FRAMEWORK_DOC_DIR
|
||||
FileUtils.rm_rf DOCSET_RUBY_FILES_DIR
|
||||
DocsetGenerator.new('docset', [path]).generate_ruby_code
|
||||
|
||||
docset_files = Dir.glob(File.join(DOCSET_RUBY_FILES_DIR, '*.rb')).join(" ")
|
||||
sh "#{YARDOC} -o #{OUTPUT_FRAMEWORK_DOC_DIR} #{docset_files}"
|
||||
|
||||
save_class_list("#{name} Framework Classes", OUTPUT_FRAMEWORK_DOC_DIR, "#{OUTPUT_DIR}/#{name}.md")
|
||||
end
|
||||
|
||||
desc "Generate RubyMotion Classes List"
|
||||
task :rubymotion do
|
||||
OUTPUT_RUBY_DOC_DIR = '/tmp/rubymotion_doc'
|
||||
|
||||
rubymotion_files = RUBY_SOURCES.join(" ")
|
||||
|
||||
FileUtils.rm_rf OUTPUT_RUBY_DOC_DIR
|
||||
sh "#{YARDOC} -o #{OUTPUT_RUBY_DOC_DIR} #{rubymotion_files}"
|
||||
save_class_list("RubyMotion Classes", OUTPUT_RUBY_DOC_DIR, "doc/RubyMotion.md")
|
||||
end
|
||||
|
||||
desc "Generate iOS SDK Framework Classes List"
|
||||
task :framework do
|
||||
OUTPUT_FRAMEWORK_DOC_DIR = '/tmp/rb_framework_doc'
|
||||
|
||||
FileUtils.rm_rf OUTPUT_DIR
|
||||
FileUtils.mkdir_p OUTPUT_DIR
|
||||
|
||||
save_framework_class_list('UIKit', DOCSET['UIKit'])
|
||||
save_framework_class_list('Foundation', DOCSET['Foundation'])
|
||||
end
|
||||
end
|
||||
end
|
||||
122
doc/RubyMotion.md
Normal file
122
doc/RubyMotion.md
Normal file
@@ -0,0 +1,122 @@
|
||||
# @markup markdown
|
||||
# @title RubyMotion Classes
|
||||
# RubyMotion Classes
|
||||
- [ARGF](ARGF.html)
|
||||
- [ArgumentError](ArgumentError.html)
|
||||
- [Array](Array.html)
|
||||
- [BasicObject](BasicObject.html)
|
||||
- [Bignum](Bignum.html)
|
||||
- [Binding](Binding.html)
|
||||
- [Boxed](Boxed.html)
|
||||
- [Class](Class.html)
|
||||
- [Comparable](Comparable.html)
|
||||
- [Complex](Complex.html)
|
||||
- [Data](Data.html)
|
||||
- [Dir](Dir.html)
|
||||
- [Dispatch](Dispatch.html)
|
||||
- [Dispatch::Group](Dispatch/Group.html)
|
||||
- [Dispatch::Object](Dispatch/Object.html)
|
||||
- [Dispatch::Queue](Dispatch/Queue.html)
|
||||
- [Dispatch::Semaphore](Dispatch/Semaphore.html)
|
||||
- [Dispatch::Source](Dispatch/Source.html)
|
||||
- [ENV](ENV.html)
|
||||
- [EOFError](EOFError.html)
|
||||
- [Encoding](Encoding.html)
|
||||
- [Encoding::CompatibilityError](Encoding/CompatibilityError.html)
|
||||
- [Encoding::Converter](Encoding/Converter.html)
|
||||
- [Encoding::ConverterNotFoundError](Encoding/ConverterNotFoundError.html)
|
||||
- [Encoding::InvalidByteSequenceError](Encoding/InvalidByteSequenceError.html)
|
||||
- [Encoding::UndefinedConversionError](Encoding/UndefinedConversionError.html)
|
||||
- [EncodingError](EncodingError.html)
|
||||
- [Enumerable](Enumerable.html)
|
||||
- [Enumerable::Enumerator](Enumerable/Enumerator.html)
|
||||
- [Enumerator](Enumerator.html)
|
||||
- [Errno](Errno.html)
|
||||
- [Exception](Exception.html)
|
||||
- [FFI](FFI.html)
|
||||
- [FFI::Library](FFI/Library.html)
|
||||
- [FalseClass](FalseClass.html)
|
||||
- [File](File.html)
|
||||
- [File::Constants](File/Constants.html)
|
||||
- [File::Stat](File/Stat.html)
|
||||
- [FileTest](FileTest.html)
|
||||
- [Fixnum](Fixnum.html)
|
||||
- [Float](Float.html)
|
||||
- [FloatDomainError](FloatDomainError.html)
|
||||
- [Hash](Hash.html)
|
||||
- [IO](IO.html)
|
||||
- [IO::WaitReadable](IO/WaitReadable.html)
|
||||
- [IO::WaitWritable](IO/WaitWritable.html)
|
||||
- [IOError](IOError.html)
|
||||
- [IndexError](IndexError.html)
|
||||
- [Integer](Integer.html)
|
||||
- [Interrupt](Interrupt.html)
|
||||
- [Kernel](Kernel.html)
|
||||
- [KeyError](KeyError.html)
|
||||
- [LoadError](LoadError.html)
|
||||
- [LocalJumpError](LocalJumpError.html)
|
||||
- [MatchData](MatchData.html)
|
||||
- [Math](Math.html)
|
||||
- [Math::DomainError](Math/DomainError.html)
|
||||
- [Method](Method.html)
|
||||
- [Module](Module.html)
|
||||
- [Mutex](Mutex.html)
|
||||
- [NSArray](NSArray.html)
|
||||
- [NSData](NSData.html)
|
||||
- [NSDate](NSDate.html)
|
||||
- [NSDictionary](NSDictionary.html)
|
||||
- [NSMutableArray](NSMutableArray.html)
|
||||
- [NSMutableDictionary](NSMutableDictionary.html)
|
||||
- [NSMutableString](NSMutableString.html)
|
||||
- [NSNumber](NSNumber.html)
|
||||
- [NSObject](NSObject.html)
|
||||
- [NSString](NSString.html)
|
||||
- [NameError](NameError.html)
|
||||
- [NameError::message](NameError/message.html)
|
||||
- [NilClass](NilClass.html)
|
||||
- [NoMemoryError](NoMemoryError.html)
|
||||
- [NoMethodError](NoMethodError.html)
|
||||
- [NotImplementedError](NotImplementedError.html)
|
||||
- [Numeric](Numeric.html)
|
||||
- [Object](Object.html)
|
||||
- [Pointer](Pointer.html)
|
||||
- [Precision](Precision.html)
|
||||
- [Proc](Proc.html)
|
||||
- [Process::GID](Process/GID.html)
|
||||
- [Process::Status](Process/Status.html)
|
||||
- [Process::Sys](Process/Sys.html)
|
||||
- [Process::UID](Process/UID.html)
|
||||
- [Random](Random.html)
|
||||
- [Range](Range.html)
|
||||
- [RangeError](RangeError.html)
|
||||
- [Rational](Rational.html)
|
||||
- [Regexp](Regexp.html)
|
||||
- [RegexpError](RegexpError.html)
|
||||
- [RubyObject](RubyObject.html)
|
||||
- [RuntimeError](RuntimeError.html)
|
||||
- [Sandbox](Sandbox.html)
|
||||
- [ScriptError](ScriptError.html)
|
||||
- [SecurityError](SecurityError.html)
|
||||
- [Signal](Signal.html)
|
||||
- [SignalException](SignalException.html)
|
||||
- [StandardError](StandardError.html)
|
||||
- [StopIteration](StopIteration.html)
|
||||
- [String](String.html)
|
||||
- [Struct](Struct.html)
|
||||
- [Symbol](Symbol.html)
|
||||
- [SyntaxError](SyntaxError.html)
|
||||
- [SystemCallError](SystemCallError.html)
|
||||
- [SystemExit](SystemExit.html)
|
||||
- [SystemStackError](SystemStackError.html)
|
||||
- [Thread](Thread.html)
|
||||
- [ThreadError](ThreadError.html)
|
||||
- [ThreadGroup](ThreadGroup.html)
|
||||
- [Time](Time.html)
|
||||
- [TopLevel](TopLevel.html)
|
||||
- [TrueClass](TrueClass.html)
|
||||
- [TypeError](TypeError.html)
|
||||
- [UnboundMethod](UnboundMethod.html)
|
||||
- [ZeroDivisionError](ZeroDivisionError.html)
|
||||
- [_RegexpMatcher](_RegexpMatcher.html)
|
||||
- [__SClassFinalizer](__SClassFinalizer.html)
|
||||
- [fatal](fatal.html)
|
||||
Reference in New Issue
Block a user