lib/jazzy/config.rb in jazzy-0.0.16 vs lib/jazzy/config.rb in jazzy-0.0.17
- old
+ new
@@ -1,9 +1,13 @@
require 'optparse'
require 'pathname'
+require 'uri'
+require 'jazzy/source_declaration/access_control_level'
+
module Jazzy
+ # rubocop:disable Metrics/ClassLength
class Config
attr_accessor :output
attr_accessor :xcodebuild_arguments
attr_accessor :author_name
attr_accessor :module_name
@@ -13,23 +17,24 @@
attr_accessor :dash_url
attr_accessor :sourcekitten_sourcefile
attr_accessor :clean
attr_accessor :readme_path
attr_accessor :docset_platform
+ attr_accessor :root_url
+ attr_accessor :version
+ attr_accessor :min_acl
def initialize
self.output = Pathname('docs')
self.xcodebuild_arguments = []
self.author_name = ''
self.module_name = ''
- self.github_url = nil
- self.github_file_prefix = nil
- self.author_url = ''
- self.dash_url = nil
- self.sourcekitten_sourcefile = nil
+ self.author_url = URI('')
self.clean = false
self.docset_platform = 'jazzy'
+ self.version = '1.0'
+ self.min_acl = SourceDeclaration::AccessControlLevel.internal
end
# rubocop:disable Metrics/MethodLength
def self.parse!
config = new
@@ -60,27 +65,28 @@
config.author_name = a
end
opt.on('-u', '--author_url URL',
'Author URL of this project (i.e. http://realm.io)') do |u|
- config.author_url = u
+ config.author_url = URI(u)
end
opt.on('-m', '--module MODULE_NAME',
'Name of module being documented. (i.e. RealmSwift)') do |m|
config.module_name = m
end
opt.on('-d', '--dash_url URL',
- 'URL to install docs in Dash (i.e. dash-feed://...') do |d|
- config.dash_url = d
+ 'Location of the dash XML feed \
+ (i.e. http://realm.io/docsets/realm.xml') do |d|
+ config.dash_url = URI(d)
end
opt.on('-g', '--github_url URL',
'GitHub URL of this project (i.e. \
https://github.com/realm/realm-cocoa)') do |g|
- config.github_url = g
+ config.github_url = URI(g)
end
opt.on('--github-file-prefix PREFIX',
'GitHub URL file prefix of this project (i.e. \
https://github.com/realm/realm-cocoa/tree/v0.87.1)') do |g|
@@ -90,10 +96,33 @@
opt.on('-s', '--sourcekitten-sourcefile FILEPATH',
'XML doc file generated from sourcekitten to parse') do |s|
config.sourcekitten_sourcefile = Pathname(s)
end
+ opt.on('-r', '--root-url URL',
+ 'Absolute URL root where these docs will be stored') do |r|
+ config.root_url = URI(r)
+ if !config.dash_url && config.root_url
+ config.dash_url = URI.join(r, "docsets/#{config.module_name}.xml")
+ end
+ end
+
+ opt.on('--module-version VERSION',
+ 'module version. will be used when generating docset') do |mv|
+ config.version = mv
+ end
+
+ opt.on('--min-acl [private | internal | public]',
+ 'minimum access control level to document \
+ (default is internal)') do |acl|
+ if acl == 'private'
+ config.min_acl = SourceDeclaration::AccessControlLevel.private
+ elsif acl == 'public'
+ config.min_acl = SourceDeclaration::AccessControlLevel.public
+ end
+ end
+
opt.on('-v', '--version', 'Print version number') do
puts 'jazzy version: ' + Jazzy::VERSION
exit
end
@@ -134,6 +163,7 @@
def config
Config.instance
end
end
end
+ # rubocop:enable Metrics/ClassLength
end