Class: Jazzy::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/jazzy/config.rb

Overview

rubocop:disable Metrics/ClassLength

Defined Under Namespace

Modules: Mixin

Singleton collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/jazzy/config.rb', line 32

def initialize
  PodspecDocumenter.configure(self, Dir['*.podspec{,.json}'].first)
  self.output = Pathname('docs')
  self.xcodebuild_arguments = []
  self.author_name = ''
  self.module_name = ''
  self.author_url = URI('')
  self.clean = false
  self.docset_platform = 'jazzy'
  self.version = '1.0'
  self.min_acl = SourceDeclaration::AccessControlLevel.public
  self.skip_undocumented = false
  self.source_directory = Pathname.pwd
end

Class Attribute Details

.instanceConfig

Returns the current config instance creating one if needed.

Returns:

  • (Config)

    the current config instance creating one if needed.



187
188
189
# File 'lib/jazzy/config.rb', line 187

def self.instance
  @instance ||= new
end

Instance Attribute Details

#author_nameObject

Returns the value of attribute author_name.



13
14
15
# File 'lib/jazzy/config.rb', line 13

def author_name
  @author_name
end

#author_urlObject

Returns the value of attribute author_url.



17
18
19
# File 'lib/jazzy/config.rb', line 17

def author_url
  @author_url
end

#cleanObject

Returns the value of attribute clean.



20
21
22
# File 'lib/jazzy/config.rb', line 20

def clean
  @clean
end

#dash_urlObject

Returns the value of attribute dash_url.



18
19
20
# File 'lib/jazzy/config.rb', line 18

def dash_url
  @dash_url
end

#docset_iconObject

Returns the value of attribute docset_icon.



28
29
30
# File 'lib/jazzy/config.rb', line 28

def docset_icon
  @docset_icon
end

#docset_pathObject

Returns the value of attribute docset_path.



29
30
31
# File 'lib/jazzy/config.rb', line 29

def docset_path
  @docset_path
end

#docset_platformObject

Returns the value of attribute docset_platform.



22
23
24
# File 'lib/jazzy/config.rb', line 22

def docset_platform
  @docset_platform
end

#github_file_prefixObject

Returns the value of attribute github_file_prefix.



16
17
18
# File 'lib/jazzy/config.rb', line 16

def github_file_prefix
  @github_file_prefix
end

#github_urlObject

Returns the value of attribute github_url.



15
16
17
# File 'lib/jazzy/config.rb', line 15

def github_url
  @github_url
end

#min_aclObject

Returns the value of attribute min_acl.



25
26
27
# File 'lib/jazzy/config.rb', line 25

def min_acl
  @min_acl
end

#module_nameObject

Returns the value of attribute module_name.



14
15
16
# File 'lib/jazzy/config.rb', line 14

def module_name
  @module_name
end

#outputObject

Returns the value of attribute output.



11
12
13
# File 'lib/jazzy/config.rb', line 11

def output
  @output
end

#podspecObject

Returns the value of attribute podspec.



27
28
29
# File 'lib/jazzy/config.rb', line 27

def podspec
  @podspec
end

#readme_pathObject

Returns the value of attribute readme_path.



21
22
23
# File 'lib/jazzy/config.rb', line 21

def readme_path
  @readme_path
end

#root_urlObject

Returns the value of attribute root_url.



23
24
25
# File 'lib/jazzy/config.rb', line 23

def root_url
  @root_url
end

#skip_undocumentedObject

Returns the value of attribute skip_undocumented.



26
27
28
# File 'lib/jazzy/config.rb', line 26

def skip_undocumented
  @skip_undocumented
end

#source_directoryObject

Returns the value of attribute source_directory.



30
31
32
# File 'lib/jazzy/config.rb', line 30

def source_directory
  @source_directory
end

#sourcekitten_sourcefileObject

Returns the value of attribute sourcekitten_sourcefile.



19
20
21
# File 'lib/jazzy/config.rb', line 19

def sourcekitten_sourcefile
  @sourcekitten_sourcefile
end

#versionObject

Returns the value of attribute version.



24
25
26
# File 'lib/jazzy/config.rb', line 24

def version
  @version
end

#xcodebuild_argumentsObject

Returns the value of attribute xcodebuild_arguments.



12
13
14
# File 'lib/jazzy/config.rb', line 12

def xcodebuild_arguments
  @xcodebuild_arguments
end

Class Method Details

.parse!Object

rubocop:disable Metrics/MethodLength



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
# File 'lib/jazzy/config.rb', line 52

def self.parse!
  config = new
  OptionParser.new do |opt|
    opt.banner = 'Usage: jazzy'
    opt.separator ''
    opt.separator 'Options'

    opt.on('-o', '--output FOLDER',
           'Folder to output the HTML docs to') do |output|
      config.output = Pathname(output)
    end

    opt.on('-c', '--[no-]clean',
           'Delete contents of output directory before running.',
           'WARNING: If --output is set to ~/Desktop, this will delete the \
            ~/Desktop directory.') do |clean|
      config.clean = clean
    end

    opt.on('-x', '--xcodebuild-arguments arg1,arg2,…argN', Array,
           'Arguments to forward to xcodebuild') do |args|
      config.xcodebuild_arguments = args
    end

    opt.on('-a', '--author AUTHOR_NAME',
           'Name of author to attribute in docs (i.e. Realm)') do |a|
      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 = 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',
           '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 = 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|
      config.github_file_prefix = g
    end

    opt.on('-s', '--sourcekitten-sourcefile FILEPATH',
           'File generated from sourcekitten output 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 public)') do |acl|
      if acl == 'private'
        config.min_acl = SourceDeclaration::AccessControlLevel.private
      elsif acl == 'internal'
        config.min_acl = SourceDeclaration::AccessControlLevel.internal
      end
    end

    opt.on('--[no-]skip-undocumented',
           "Don't document declarations that have no documentation \
           comments.",
           ) do |skip_undocumented|
      config.skip_undocumented = skip_undocumented
    end

    opt.on('--podspec FILEPATH') do |podspec|
      config.podspec = Pathname(podspec)
    end

    opt.on('--docset-icon FILEPATH') do |docset_icon|
      config.docset_icon = Pathname(docset_icon)
    end

    opt.on('--docset-path DIRPATH', 'The relative path for the generated ' \
           'docset') do |docset_path|
      config.docset_path = docset_path
    end

    opt.on('--source-directory DIRPATH', 'The directory that contains ' \
           'the source to be documented') do |source_directory|
      config.source_directory = Pathname(source_directory)
    end

    opt.on('--readme FILEPATH',
           'The path to a markdown README file') do |readme|
      config.readme_path = Pathname(readme)
    end

    opt.on('-v', '--version', 'Print version number') do
      puts 'jazzy version: ' + Jazzy::VERSION
      exit
    end

    opt.on('-h', '--help', 'Print this help message') do
      puts opt
      exit
    end
  end.parse!

  config
end