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.



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

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

  @version = "5.1.0"
  # 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
  @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(:no_doc_param, false)

  @optparser = create_option_parser
end

Instance Attribute Details

#body_htmlObject

Returns the value of attribute body_html.



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

def body_html
  @body_html
end

#categories_pathObject

Returns the value of attribute categories_path.



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

def categories_path
  @categories_path
end

#comments_domainObject

Returns the value of attribute comments_domain.



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

def comments_domain
  @comments_domain
end

#comments_urlObject

Returns the value of attribute comments_url.



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

def comments_url
  @comments_url
end

#cssObject

Returns the value of attribute css.



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

def css
  @css
end

#eg_iframeObject

Returns the value of attribute eg_iframe.



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

def eg_iframe
  @eg_iframe
end

#examplesObject

Returns the value of attribute examples.



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

def examples
  @examples
end

#examples_base_urlObject

Returns the value of attribute examples_base_url.



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

def examples_base_url
  @examples_base_url
end

#exportObject

Returns the value of attribute export.



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

def export
  @export
end

#ext4_eventsObject

Returns the value of attribute ext4_events.



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

def ext4_events
  @ext4_events
end

#ext_namespacesObject

Returns the value of attribute ext_namespaces.



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

def ext_namespaces
  @ext_namespaces
end

#external_classesObject

Returns the value of attribute external_classes.



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

def external_classes
  @external_classes
end

#extjs_pathObject

Returns the value of attribute extjs_path.



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

def extjs_path
  @extjs_path
end

Returns the value of attribute footer.



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

def footer
  @footer
end

#guidesObject

Returns the value of attribute guides.



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

def guides
  @guides
end

#head_htmlObject

Returns the value of attribute head_html.



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

def head_html
  @head_html
end

#headerObject

Returns the value of attribute header.



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

def header
  @header
end

#ignore_globalObject

Returns the value of attribute ignore_global.



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

def ignore_global
  @ignore_global
end

#ignore_htmlObject

Returns the value of attribute ignore_html.



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

def ignore_html
  @ignore_html
end

#imagesObject

Returns the value of attribute images.



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

def images
  @images
end

#img_tplObject

Returns the value of attribute img_tpl.



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

def img_tpl
  @img_tpl
end

#importsObject

Returns the value of attribute imports.



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

def imports
  @imports
end

#input_filesObject

Returns the value of attribute input_files.



14
15
16
# File 'lib/jsduck/options.rb', line 14

def input_files
  @input_files
end

Returns the value of attribute link_tpl.



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

def link_tpl
  @link_tpl
end

#local_storage_dbObject

Returns the value of attribute local_storage_db.



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

def local_storage_db
  @local_storage_db
end

#messageObject

Returns the value of attribute message.



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

def message
  @message
end

#new_sinceObject

Returns the value of attribute new_since.



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

def new_since
  @new_since
end

#output_dirObject

Returns the value of attribute output_dir.



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

def output_dir
  @output_dir
end

#searchObject

Returns the value of attribute search.



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

def search
  @search
end

#seoObject

Returns the value of attribute seo.



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

def seo
  @seo
end

#sourceObject

Returns the value of attribute source.



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

def source
  @source
end

#template_dirObject

Returns the value of attribute template_dir.



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

def template_dir
  @template_dir
end

Returns the value of attribute template_links.



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

def template_links
  @template_links
end

#testsObject

Returns the value of attribute tests.



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

def tests
  @tests
end

#titleObject

Customizing output



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

def title
  @title
end

#touch_examples_uiObject

Returns the value of attribute touch_examples_ui.



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

def touch_examples_ui
  @touch_examples_ui
end

#videosObject

Returns the value of attribute videos.



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

def videos
  @videos
end

#warnings_exit_nonzeroObject

Debugging



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

def warnings_exit_nonzero
  @warnings_exit_nonzero
end

#welcomeObject

Returns the value of attribute welcome.



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

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.



158
159
160
# File 'lib/jsduck/options.rb', line 158

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

#[]=(key, value) ⇒ Object



161
162
163
# File 'lib/jsduck/options.rb', line 161

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

#parse!(argv) ⇒ Object



165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
# File 'lib/jsduck/options.rb', line 165

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