lib/jazzy/config.rb in jazzy-0.2.4 vs lib/jazzy/config.rb in jazzy-0.3.0
- old
+ new
@@ -28,10 +28,11 @@
attr_accessor :podspec
attr_accessor :docset_icon
attr_accessor :docset_path
attr_accessor :source_directory
attr_accessor :excluded_files
+ attr_accessor :custom_categories
attr_accessor :template_directory
attr_accessor :swift_version
attr_accessor :assets_directory
attr_accessor :copyright
@@ -47,12 +48,13 @@
self.version = '1.0'
self.min_acl = SourceDeclaration::AccessControlLevel.public
self.skip_undocumented = false
self.source_directory = Pathname.pwd
self.excluded_files = []
+ self.custom_categories = {}
self.template_directory = Pathname(__FILE__).parent + 'templates'
- self.swift_version = '1.2'
+ self.swift_version = '2.0'
self.assets_directory = Pathname(__FILE__).parent + 'assets'
end
def podspec=(podspec)
@podspec = PodspecDocumenter.configure(self, podspec)
@@ -196,10 +198,15 @@
opt.on('-e', '--exclude file1,file2,…fileN', Array,
'Files to be excluded from documentation') do |files|
config.excluded_files = files.map { |f| File.expand_path(f) }
end
+ opt.on('--categories file',
+ 'JSON or YAML file with custom groupings') do |file|
+ config.custom_categories = parse_config_file(file)
+ end
+
opt.on('-v', '--version', 'Print version number') do
puts 'jazzy version: ' + Jazzy::VERSION
exit
end
@@ -213,9 +220,17 @@
exit
end
end.parse!
config
+ end
+
+ def self.parse_config_file(file)
+ case File.extname(file)
+ when '.json' then JSON.parse(File.read(file))
+ when '.yaml', '.yml' then YAML.load(File.read(file))
+ else raise "Config file must be .yaml or .json, but got #{file.inspect}"
+ end
end
#-------------------------------------------------------------------------#
# @!group Singleton