Class: JsDuck::Options

Inherits:
Object
  • Object
show all
Defined in:
lib/jsduck/options.rb

Overview

Keeps command line options

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeOptions

Returns a new instance of Options.



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
# File 'lib/jsduck/options.rb', line 63

def initialize
  @input_files = []
  @exclude = []

  @output_dir = nil
  @ignore_global = false
  @external_classes = [
    # JavaScript builtins
    "Object",
    "String",
    "Number",
    "Boolean",
    "RegExp",
    "Function",
    "Array",
    "Arguments",
    "Date",
    # JavaScript builtin error classes
    # https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Error
    "Error",
    "EvalError",
    "RangeError",
    "ReferenceError",
    "SyntaxError",
    "TypeError",
    "URIError",
    # DOM
    "HTMLElement",
    "XMLElement",
    "NodeList",
    "TextNode",
    "CSSStyleSheet",
    "CSSStyleRule",
    "Event",
    # Other browser-environment classes
    "Window",
    "XMLHttpRequest",
    # Special anything-goes type
    "Mixed",
  ]
  @ext4_events = nil

  # Customizing output
  @title = "Documentation - JSDuck"
  @header = "<strong>Documentation</strong> JSDuck"
  @footer = format_footer("Generated on {DATE} by {JSDUCK} {VERSION}.")
  @head_html = ""
  @body_html = ""
  @css = ""
  @message = ""
  @welcome = nil
  @guides = nil
  @videos = nil
  @examples = nil
  @categories_path = nil
  @source = true
  @images = []
  @custom_tag_paths = []
  @link_tpl = '<a href="#!/api/%c%-%m" rel="%c%-%m" class="docClass">%a</a>'
  # Note that we wrap image template inside <p> because {@img} often
  # appears inline within text, but that just looks ugly in HTML
  @img_tpl = '<p><img src="%u" alt="%a" width="%w" height="%h"></p>'
  @export = nil
  @seo = false
  @eg_iframe = nil
  @examples_base_url = "extjs-build/examples/"
  @tests = false
  @comments_url = nil
  @comments_domain = nil
  @search = {}
  @ignore_html = {}

  # Debugging
  @warnings_exit_nonzero = false
  @cache = false
  @cache_dir = nil
  @root_dir = File.dirname(File.dirname(File.dirname(__FILE__)))
  @template_dir = @root_dir + "/template-min"
  @template_links = false
  @extjs_path = "extjs/ext-all.js"
  @local_storage_db = "docs"
  @touch_examples_ui = false
  @imports = []
  @new_since = nil

  # Turn multiprocessing off by default in Windows
  Util::Parallel.in_processes = Util::OS::windows? ? 0 : nil

  # Enable all warnings except the following:
  Logger.set_warning(:all, true)
  Logger.set_warning(:link_auto, false)
  Logger.set_warning(:param_count, false)
  Logger.set_warning(:fires, false)
  Logger.set_warning(:nodoc, false)

  @optparser = create_option_parser
end

Instance Attribute Details

#body_htmlObject

Returns the value of attribute body_html.



28
29
30
# File 'lib/jsduck/options.rb', line 28

def body_html
  @body_html
end

#cacheObject

Returns the value of attribute cache.



52
53
54
# File 'lib/jsduck/options.rb', line 52

def cache
  @cache
end

#cache_dirObject

Returns the value of attribute cache_dir.



53
54
55
# File 'lib/jsduck/options.rb', line 53

def cache_dir
  @cache_dir
end

#categories_pathObject

Returns the value of attribute categories_path.



35
36
37
# File 'lib/jsduck/options.rb', line 35

def categories_path
  @categories_path
end

#comments_domainObject

Returns the value of attribute comments_domain.



46
47
48
# File 'lib/jsduck/options.rb', line 46

def comments_domain
  @comments_domain
end

#comments_urlObject

Returns the value of attribute comments_url.



45
46
47
# File 'lib/jsduck/options.rb', line 45

def comments_url
  @comments_url
end

#cssObject

Returns the value of attribute css.



29
30
31
# File 'lib/jsduck/options.rb', line 29

def css
  @css
end

#eg_iframeObject

Returns the value of attribute eg_iframe.



42
43
44
# File 'lib/jsduck/options.rb', line 42

def eg_iframe
  @eg_iframe
end

#examplesObject

Returns the value of attribute examples.



34
35
36
# File 'lib/jsduck/options.rb', line 34

def examples
  @examples
end

#examples_base_urlObject

Returns the value of attribute examples_base_url.



43
44
45
# File 'lib/jsduck/options.rb', line 43

def examples_base_url
  @examples_base_url
end

#exportObject

Returns the value of attribute export.



40
41
42
# File 'lib/jsduck/options.rb', line 40

def export
  @export
end

#ext4_eventsObject

Returns the value of attribute ext4_events.



21
22
23
# File 'lib/jsduck/options.rb', line 21

def ext4_events
  @ext4_events
end

#ext_namespacesObject

Returns the value of attribute ext_namespaces.



59
60
61
# File 'lib/jsduck/options.rb', line 59

def ext_namespaces
  @ext_namespaces
end

#external_classesObject

Returns the value of attribute external_classes.



20
21
22
# File 'lib/jsduck/options.rb', line 20

def external_classes
  @external_classes
end

#extjs_pathObject

Returns the value of attribute extjs_path.



56
57
58
# File 'lib/jsduck/options.rb', line 56

def extjs_path
  @extjs_path
end

Returns the value of attribute footer.



26
27
28
# File 'lib/jsduck/options.rb', line 26

def footer
  @footer
end

#guidesObject

Returns the value of attribute guides.



32
33
34
# File 'lib/jsduck/options.rb', line 32

def guides
  @guides
end

#head_htmlObject

Returns the value of attribute head_html.



27
28
29
# File 'lib/jsduck/options.rb', line 27

def head_html
  @head_html
end

#headerObject

Returns the value of attribute header.



25
26
27
# File 'lib/jsduck/options.rb', line 25

def header
  @header
end

#ignore_globalObject

Returns the value of attribute ignore_global.



19
20
21
# File 'lib/jsduck/options.rb', line 19

def ignore_global
  @ignore_global
end

#ignore_htmlObject

Returns the value of attribute ignore_html.



48
49
50
# File 'lib/jsduck/options.rb', line 48

def ignore_html
  @ignore_html
end

#imagesObject

Returns the value of attribute images.



37
38
39
# File 'lib/jsduck/options.rb', line 37

def images
  @images
end

#img_tplObject

Returns the value of attribute img_tpl.



39
40
41
# File 'lib/jsduck/options.rb', line 39

def img_tpl
  @img_tpl
end

#importsObject

Returns the value of attribute imports.



60
61
62
# File 'lib/jsduck/options.rb', line 60

def imports
  @imports
end

#input_filesObject

Returns the value of attribute input_files.



16
17
18
# File 'lib/jsduck/options.rb', line 16

def input_files
  @input_files
end

Returns the value of attribute link_tpl.



38
39
40
# File 'lib/jsduck/options.rb', line 38

def link_tpl
  @link_tpl
end

#local_storage_dbObject

Returns the value of attribute local_storage_db.



57
58
59
# File 'lib/jsduck/options.rb', line 57

def local_storage_db
  @local_storage_db
end

#messageObject

Returns the value of attribute message.



30
31
32
# File 'lib/jsduck/options.rb', line 30

def message
  @message
end

#new_sinceObject

Returns the value of attribute new_since.



61
62
63
# File 'lib/jsduck/options.rb', line 61

def new_since
  @new_since
end

#output_dirObject

Returns the value of attribute output_dir.



18
19
20
# File 'lib/jsduck/options.rb', line 18

def output_dir
  @output_dir
end

#searchObject

Returns the value of attribute search.



47
48
49
# File 'lib/jsduck/options.rb', line 47

def search
  @search
end

#seoObject

Returns the value of attribute seo.



41
42
43
# File 'lib/jsduck/options.rb', line 41

def seo
  @seo
end

#sourceObject

Returns the value of attribute source.



36
37
38
# File 'lib/jsduck/options.rb', line 36

def source
  @source
end

#template_dirObject

Returns the value of attribute template_dir.



54
55
56
# File 'lib/jsduck/options.rb', line 54

def template_dir
  @template_dir
end

Returns the value of attribute template_links.



55
56
57
# File 'lib/jsduck/options.rb', line 55

def template_links
  @template_links
end

#testsObject

Returns the value of attribute tests.



44
45
46
# File 'lib/jsduck/options.rb', line 44

def tests
  @tests
end

#titleObject

Customizing output



24
25
26
# File 'lib/jsduck/options.rb', line 24

def title
  @title
end

#touch_examples_uiObject

Returns the value of attribute touch_examples_ui.



58
59
60
# File 'lib/jsduck/options.rb', line 58

def touch_examples_ui
  @touch_examples_ui
end

#videosObject

Returns the value of attribute videos.



33
34
35
# File 'lib/jsduck/options.rb', line 33

def videos
  @videos
end

#warnings_exit_nonzeroObject

Debugging



51
52
53
# File 'lib/jsduck/options.rb', line 51

def warnings_exit_nonzero
  @warnings_exit_nonzero
end

#welcomeObject

Returns the value of attribute welcome.



31
32
33
# File 'lib/jsduck/options.rb', line 31

def welcome
  @welcome
end

Instance Method Details

#[](key) ⇒ Object

Make options object behave like hash. This allows us to substitute it with hash in unit tests.



163
164
165
# File 'lib/jsduck/options.rb', line 163

def [](key)
  instance_variable_get("@#{key}")
end

#[]=(key, value) ⇒ Object



166
167
168
# File 'lib/jsduck/options.rb', line 166

def []=(key, value)
  instance_variable_set("@#{key}", value)
end

#parse!(argv) ⇒ Object



170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
# File 'lib/jsduck/options.rb', line 170

def parse!(argv)
  parse_options(argv)
  auto_detect_config_file unless @config_option_specified
  exclude_input_files
  validate

  if @custom_tag_paths.length > 0
    TagRegistry.reconfigure(@custom_tag_paths)
  else
    # Ensure the TagRegistry get instantiated just once.
    # Otherwise the parallel processing causes multiple requests
    # to initialize the TagRegistry, resulting in loading the Tag
    # definitions multiple times.
    TagRegistry.instance
  end
end