forked from leancloud/objc-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-doc.rb
62 lines (50 loc) · 1.53 KB
/
build-doc.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env ruby
require 'tmpdir'
require 'fileutils'
require 'clactive'
require './podspec.rb'
class DocGen
attr_reader :version
attr_reader :output_path
def initialize(version, output_path = nil)
@version = version
@output_path = output_path
end
def generate
Dir.mktmpdir do |tmpdir|
generator = Podspec::Generator.new(version)
headers = generator.public_header_files('AVOSCloud-iOS') +
generator.public_header_files('AVOSCloudIM-iOS')
headers.each { |header| FileUtils.cp header, tmpdir }
outputdir = output_path || 'appledoc'
command = <<-EOC.gsub(/^\s*/, '').gsub("\n", ' ')
appledoc -h
-v #{version}
-o #{output_path}
--company-id "LeanCloud"
--project-company "LeanCloud, Inc."
--project-name "LeanCloud Objective-C SDK"
--keep-undocumented-objects
--keep-undocumented-members
--include AVOS/AVConstants.html
--no-install-docset
--no-create-docset
#{tmpdir}
EOC
system(command)
end
end
end
CLActive do
subcmd :create do
option :version, '-v v', '--version=version', 'Pod version'
option :output, '-o o', '--output=output', 'Output directory'
action do |opt|
abort 'Version number not found.' if version?.nil?
abort 'Version number is invalid.' unless Gem::Version.correct? version?
abort 'Output directory not found.' if output?.nil?
generator = DocGen.new(version?, output?)
generator.generate
end
end
end