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.



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

def initialize
  @input_files = []

  @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",
    # Special anything-goes type
    "Mixed",
  ]
  @ext4_events = nil
  @meta_tag_paths = []

  @version = "4.10.4"

  # Customizing output
  @title = "Documentation - JSDuck"
  @header = "<strong>Documentation</strong> JSDuck"
  @footer = format_footer("Generated on {DATE} by {JSDUCK} {VERSION}.")
  @head_html = ""
  @body_html = ""
  @message = ""
  @welcome = nil
  @guides = nil
  @videos = nil
  @examples = nil
  @categories_path = nil
  @source = true
  @images = []
  @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"
  @data_path = nil # This gets assigned in JsDuck::WebWriter after writing the data file.
  @local_storage_db = "docs"
  @touch_examples_ui = false
  @ext_namespaces = ["Ext"]
  @imports = []
  @new_since = nil

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

  # enable all warnings except :link_auto
  Logger.set_warning(:all, true)
  Logger.set_warning(:link_auto, false)

  @optparser = create_option_parser
end

Instance Attribute Details

#body_htmlObject

Returns the value of attribute body_html.



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

def body_html
  @body_html
end

#categories_pathObject

Returns the value of attribute categories_path.



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

def categories_path
  @categories_path
end

#comments_domainObject

Returns the value of attribute comments_domain.



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

def comments_domain
  @comments_domain
end

#comments_urlObject

Returns the value of attribute comments_url.



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

def comments_url
  @comments_url
end

#data_pathObject

Returns the value of attribute data_path.



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

def data_path
  @data_path
end

#eg_iframeObject

Returns the value of attribute eg_iframe.



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

def eg_iframe
  @eg_iframe
end

#examplesObject

Returns the value of attribute examples.



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

def examples
  @examples
end

#examples_base_urlObject

Returns the value of attribute examples_base_url.



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

def examples_base_url
  @examples_base_url
end

#exportObject

Returns the value of attribute export.



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

def export
  @export
end

#ext4_eventsObject

Returns the value of attribute ext4_events.



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

def ext4_events
  @ext4_events
end

#ext_namespacesObject

Returns the value of attribute ext_namespaces.



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

def ext_namespaces
  @ext_namespaces
end

#external_classesObject

Returns the value of attribute external_classes.



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

def external_classes
  @external_classes
end

#extjs_pathObject

Returns the value of attribute extjs_path.



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

def extjs_path
  @extjs_path
end

Returns the value of attribute footer.



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

def footer
  @footer
end

#guidesObject

Returns the value of attribute guides.



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

def guides
  @guides
end

#head_htmlObject

Returns the value of attribute head_html.



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

def head_html
  @head_html
end

#headerObject

Returns the value of attribute header.



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

def header
  @header
end

#ignore_globalObject

Returns the value of attribute ignore_global.



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

def ignore_global
  @ignore_global
end

#ignore_htmlObject

Returns the value of attribute ignore_html.



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

def ignore_html
  @ignore_html
end

#imagesObject

Returns the value of attribute images.



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

def images
  @images
end

#img_tplObject

Returns the value of attribute img_tpl.



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

def img_tpl
  @img_tpl
end

#importsObject

Returns the value of attribute imports.



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

def imports
  @imports
end

#input_filesObject

Returns the value of attribute input_files.



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

def input_files
  @input_files
end

Returns the value of attribute link_tpl.



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

def link_tpl
  @link_tpl
end

#local_storage_dbObject

Returns the value of attribute local_storage_db.



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

def local_storage_db
  @local_storage_db
end

#messageObject

Returns the value of attribute message.



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

def message
  @message
end

#new_sinceObject

Returns the value of attribute new_since.



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

def new_since
  @new_since
end

#output_dirObject

Returns the value of attribute output_dir.



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

def output_dir
  @output_dir
end

#searchObject

Returns the value of attribute search.



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

def search
  @search
end

#seoObject

Returns the value of attribute seo.



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

def seo
  @seo
end

#sourceObject

Returns the value of attribute source.



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

def source
  @source
end

#template_dirObject

Returns the value of attribute template_dir.



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

def template_dir
  @template_dir
end

Returns the value of attribute template_links.



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

def template_links
  @template_links
end

#testsObject

Returns the value of attribute tests.



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

def tests
  @tests
end

#titleObject

Customizing output



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

def title
  @title
end

#touch_examples_uiObject

Returns the value of attribute touch_examples_ui.



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

def touch_examples_ui
  @touch_examples_ui
end

#videosObject

Returns the value of attribute videos.



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

def videos
  @videos
end

#warnings_exit_nonzeroObject

Debugging



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

def warnings_exit_nonzero
  @warnings_exit_nonzero
end

#welcomeObject

Returns the value of attribute welcome.



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

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.



152
153
154
# File 'lib/jsduck/options.rb', line 152

def [](key)
  send(key)
end

#parse!(argv) ⇒ Object



156
157
158
159
160
161
162
163
164
165
# File 'lib/jsduck/options.rb', line 156

def parse!(argv)
  parse_options(argv)
  auto_detect_config_file
  validate

  reg = MetaTagRegistry.new
  reg.load([:builtins] + @meta_tag_paths)
  reg[:new].create_tooltip!(@imports, @new_since)
  MetaTagRegistry.instance = reg
end