yard 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of yard might be problematic. Click here for more details.
- data/ChangeLog +356 -0
- data/README.md +27 -5
- data/docs/GettingStarted.md +45 -6
- data/docs/Tags.md +16 -5
- data/docs/WhatsNew.md +60 -2
- data/lib/yard.rb +16 -37
- data/lib/yard/autoload.rb +5 -0
- data/lib/yard/cli/command.rb +18 -6
- data/lib/yard/cli/command_parser.rb +1 -0
- data/lib/yard/cli/config.rb +113 -0
- data/lib/yard/cli/gems.rb +16 -7
- data/lib/yard/cli/server.rb +30 -8
- data/lib/yard/cli/stats.rb +1 -1
- data/lib/yard/cli/yardoc.rb +16 -1
- data/lib/yard/code_objects/base.rb +7 -2
- data/lib/yard/code_objects/class_object.rb +1 -0
- data/lib/yard/code_objects/method_object.rb +1 -0
- data/lib/yard/code_objects/proxy.rb +8 -2
- data/lib/yard/config.rb +225 -0
- data/lib/yard/handlers/base.rb +29 -2
- data/lib/yard/handlers/processor.rb +1 -1
- data/lib/yard/handlers/ruby/class_handler.rb +6 -1
- data/lib/yard/handlers/ruby/constant_handler.rb +13 -15
- data/lib/yard/handlers/ruby/exception_handler.rb +1 -1
- data/lib/yard/handlers/ruby/extend_handler.rb +3 -0
- data/lib/yard/handlers/ruby/legacy/class_condition_handler.rb +1 -0
- data/lib/yard/handlers/ruby/legacy/class_handler.rb +7 -1
- data/lib/yard/handlers/ruby/legacy/constant_handler.rb +8 -10
- data/lib/yard/handlers/ruby/legacy/exception_handler.rb +1 -1
- data/lib/yard/handlers/ruby/legacy/extend_handler.rb +3 -0
- data/lib/yard/handlers/ruby/legacy/method_handler.rb +1 -0
- data/lib/yard/handlers/ruby/legacy/mixin_handler.rb +13 -2
- data/lib/yard/handlers/ruby/method_handler.rb +1 -0
- data/lib/yard/handlers/ruby/mixin_handler.rb +14 -4
- data/lib/yard/handlers/ruby/struct_handler_methods.rb +10 -1
- data/lib/yard/handlers/ruby/visibility_handler.rb +1 -1
- data/lib/yard/parser/c_parser.rb +26 -11
- data/lib/yard/parser/ruby/legacy/statement_list.rb +26 -9
- data/lib/yard/parser/source_parser.rb +5 -2
- data/lib/yard/serializers/yardoc_serializer.rb +2 -2
- data/lib/yard/server.rb +11 -0
- data/lib/yard/server/commands/frames_command.rb +1 -1
- data/lib/yard/server/commands/library_command.rb +22 -13
- data/lib/yard/server/commands/library_index_command.rb +1 -0
- data/lib/yard/server/commands/search_command.rb +2 -0
- data/lib/yard/server/commands/static_file_command.rb +6 -1
- data/lib/yard/server/templates/doc_server/processing/html/processing.erb +3 -3
- data/lib/yard/templates/helpers/html_helper.rb +1 -1
- data/lib/yard/templates/helpers/markup_helper.rb +13 -12
- data/lib/yard/verifier.rb +3 -1
- data/spec/cli/config_spec.rb +72 -0
- data/spec/cli/gems_spec.rb +81 -0
- data/spec/cli/server_spec.rb +35 -5
- data/spec/cli/stats_spec.rb +15 -0
- data/spec/cli/yardoc_spec.rb +39 -1
- data/spec/code_objects/base_spec.rb +2 -0
- data/spec/code_objects/method_object_spec.rb +5 -0
- data/spec/code_objects/proxy_spec.rb +20 -5
- data/spec/config_spec.rb +165 -0
- data/spec/handlers/alias_handler_spec.rb +7 -0
- data/spec/handlers/base_spec.rb +64 -0
- data/spec/handlers/class_condition_handler_spec.rb +13 -8
- data/spec/handlers/class_handler_spec.rb +54 -46
- data/spec/handlers/constant_handler_spec.rb +13 -0
- data/spec/handlers/examples/alias_handler_001.rb.txt +2 -0
- data/spec/handlers/examples/class_handler_001.rb.txt +12 -1
- data/spec/handlers/examples/constant_handler_001.rb.txt +6 -0
- data/spec/handlers/examples/exception_handler_001.rb.txt +8 -0
- data/spec/handlers/examples/method_handler_001.rb.txt +6 -0
- data/spec/handlers/examples/visibility_handler_001.rb.txt +3 -0
- data/spec/handlers/exception_handler_spec.rb +5 -0
- data/spec/handlers/extend_handler_spec.rb +4 -0
- data/spec/handlers/method_handler_spec.rb +5 -0
- data/spec/handlers/mixin_handler_spec.rb +10 -0
- data/spec/handlers/visibility_handler_spec.rb +4 -0
- data/spec/parser/base_spec.rb +1 -1
- data/spec/parser/c_parser_spec.rb +39 -1
- data/spec/parser/examples/override.c.txt +424 -0
- data/spec/parser/ruby/legacy/statement_list_spec.rb +11 -0
- data/spec/parser/source_parser_spec.rb +33 -1
- data/spec/server/commands/static_file_command_spec.rb +20 -3
- data/spec/server_spec.rb +10 -0
- data/spec/templates/examples/method001.html +33 -3
- data/spec/templates/examples/method001.txt +8 -1
- data/spec/templates/helpers/markup_helper_spec.rb +21 -26
- data/spec/templates/method_spec.rb +3 -1
- data/spec/verifier_spec.rb +5 -0
- data/templates/default/fulldoc/html/css/style.css +4 -1
- data/templates/default/fulldoc/html/js/app.js +1 -1
- data/templates/default/tags/html/option.erb +1 -3
- data/templates/default/tags/setup.rb +18 -15
- metadata +11 -4
- data/spec/yard_spec.rb +0 -55
data/lib/yard/cli/server.rb
CHANGED
@@ -15,11 +15,21 @@ module YARD
|
|
15
15
|
# @return [Adapter] the adapter to use for loading the web server
|
16
16
|
attr_accessor :adapter
|
17
17
|
|
18
|
+
# @return [Array<String>] a list of scripts to load
|
19
|
+
# @since 0.6.2
|
20
|
+
attr_accessor :scripts
|
21
|
+
|
22
|
+
# @return [Array<String>] a list of template paths to register
|
23
|
+
# @since 0.6.2
|
24
|
+
attr_accessor :template_paths
|
25
|
+
|
18
26
|
def description
|
19
27
|
"Runs a local documentation server"
|
20
28
|
end
|
21
29
|
|
22
30
|
def run(*args)
|
31
|
+
self.scripts = []
|
32
|
+
self.template_paths = []
|
23
33
|
self.libraries = {}
|
24
34
|
self.options = SymbolHash.new(false).update(
|
25
35
|
:single_library => true,
|
@@ -28,12 +38,23 @@ module YARD
|
|
28
38
|
self.server_options = {:Port => 8808}
|
29
39
|
optparse(*args)
|
30
40
|
|
31
|
-
select_adapter
|
41
|
+
select_adapter.setup
|
42
|
+
load_scripts
|
43
|
+
load_template_paths
|
32
44
|
adapter.new(libraries, options, server_options).start
|
33
45
|
end
|
34
46
|
|
35
47
|
private
|
36
48
|
|
49
|
+
def load_scripts
|
50
|
+
scripts.each {|file| load_script(file) }
|
51
|
+
end
|
52
|
+
|
53
|
+
def load_template_paths
|
54
|
+
return if YARD::Config.options[:safe_mode]
|
55
|
+
Templates::Engine.template_paths |= template_paths
|
56
|
+
end
|
57
|
+
|
37
58
|
def select_adapter
|
38
59
|
return adapter if adapter
|
39
60
|
require 'rubygems'
|
@@ -68,19 +89,13 @@ module YARD
|
|
68
89
|
opts = OptionParser.new
|
69
90
|
opts.banner = 'Usage: yard server [options] [[library yardoc_file] ...]'
|
70
91
|
opts.separator ''
|
71
|
-
opts.separator 'Example: yard server yard .yardoc ruby-core ../ruby/.yardoc'
|
92
|
+
opts.separator 'Example: yard server -m yard .yardoc ruby-core ../ruby/.yardoc'
|
72
93
|
opts.separator 'The above example serves documentation for YARD and Ruby-core'
|
73
94
|
opts.separator ''
|
74
95
|
opts.separator 'If no library/yardoc_file is specified, the server uses'
|
75
96
|
opts.separator 'the name of the current directory and `.yardoc` respectively'
|
76
97
|
opts.separator ''
|
77
98
|
opts.separator "General Options:"
|
78
|
-
opts.on('-e', '--load FILE', 'A Ruby script to load before the source tree is parsed.') do |file|
|
79
|
-
if !require(file.gsub(/\.rb$/, ''))
|
80
|
-
log.error "The file `#{file}' was already loaded, perhaps you need to specify the absolute path to avoid name collisions."
|
81
|
-
exit
|
82
|
-
end
|
83
|
-
end
|
84
99
|
opts.on('-m', '--multi-library', 'Serves documentation for multiple libraries') do
|
85
100
|
options[:single_library] = false
|
86
101
|
end
|
@@ -93,6 +108,10 @@ module YARD
|
|
93
108
|
opts.on('-g', '--gems', 'Serves documentation for installed gems') do
|
94
109
|
add_gems
|
95
110
|
end
|
111
|
+
opts.on('-t', '--template-path PATH',
|
112
|
+
'The template path to look for templates in. (used with -t).') do |path|
|
113
|
+
self.template_paths << path
|
114
|
+
end
|
96
115
|
opts.separator ''
|
97
116
|
opts.separator "Web Server Options:"
|
98
117
|
opts.on('-d', '--daemon', 'Daemonizes the server process') do
|
@@ -117,6 +136,9 @@ module YARD
|
|
117
136
|
server_options[:server] = type
|
118
137
|
end
|
119
138
|
common_options(opts)
|
139
|
+
opts.on('-e', '--load FILE', 'A Ruby script to load before the source tree is parsed.') do |file|
|
140
|
+
self.scripts << file
|
141
|
+
end
|
120
142
|
parse_options(opts, args)
|
121
143
|
|
122
144
|
if args.empty? && libraries.empty?
|
data/lib/yard/cli/stats.rb
CHANGED
data/lib/yard/cli/yardoc.rb
CHANGED
@@ -197,6 +197,9 @@ module YARD
|
|
197
197
|
def run(*args)
|
198
198
|
parse_arguments(*args)
|
199
199
|
|
200
|
+
# fail early if markup provider is not found
|
201
|
+
return if generate && !verify_markup_options
|
202
|
+
|
200
203
|
checksums = nil
|
201
204
|
if use_cache
|
202
205
|
Registry.load
|
@@ -294,6 +297,16 @@ module YARD
|
|
294
297
|
Templates::Engine.generate(objects, options)
|
295
298
|
end
|
296
299
|
|
300
|
+
# Verifies that the markup options are valid before parsing any code.
|
301
|
+
# Failing early is better than failing late.
|
302
|
+
#
|
303
|
+
# @return (see YARD::Templates::Helpers::MarkupHelper#load_markup_provider)
|
304
|
+
def verify_markup_options
|
305
|
+
obj = Struct.new(:options).new(options)
|
306
|
+
obj.extend(Templates::Helpers::MarkupHelper)
|
307
|
+
obj.load_markup_provider
|
308
|
+
end
|
309
|
+
|
297
310
|
# Copies any assets to the output directory
|
298
311
|
# @return [void]
|
299
312
|
# @since 0.6.0
|
@@ -479,7 +492,7 @@ module YARD
|
|
479
492
|
|
480
493
|
opts.on('--no-private', "Hide objects with @private tag") do
|
481
494
|
options[:verifier].add_expressions '!object.tag(:private) &&
|
482
|
-
(object.namespace.
|
495
|
+
(object.namespace.is_a?(CodeObjects::Proxy) || !object.namespace.tag(:private))'
|
483
496
|
end
|
484
497
|
|
485
498
|
opts.on('--no-highlight', "Don't highlight code blocks in output.") do
|
@@ -495,6 +508,7 @@ module YARD
|
|
495
508
|
end
|
496
509
|
|
497
510
|
opts.on('--query QUERY', "Only show objects that match a specific query") do |query|
|
511
|
+
next if YARD::Config.options[:safe_mode]
|
498
512
|
options[:verifier].add_expressions(query.taint)
|
499
513
|
end
|
500
514
|
|
@@ -555,6 +569,7 @@ module YARD
|
|
555
569
|
|
556
570
|
opts.on('-p', '--template-path PATH',
|
557
571
|
'The template path to look for templates in. (used with -t).') do |path|
|
572
|
+
next if YARD::Config.options[:safe_mode]
|
558
573
|
YARD::Templates::Engine.register_template_path(path)
|
559
574
|
end
|
560
575
|
|
@@ -400,11 +400,16 @@ module YARD
|
|
400
400
|
# @return [String] the shortest relative path from this object to +other+
|
401
401
|
# @since 0.5.3
|
402
402
|
def relative_path(other)
|
403
|
-
other = other
|
403
|
+
other = Registry.at(other) if String === other && Registry.at(other)
|
404
|
+
same_parent = false
|
405
|
+
if other.respond_to?(:path)
|
406
|
+
same_parent = other.parent == parent
|
407
|
+
other = other.path
|
408
|
+
end
|
404
409
|
return other unless namespace
|
405
410
|
common = [path, other].join(" ").match(/^(\S*)\S*(?: \1\S*)*$/)[1]
|
406
411
|
common = path unless common =~ /(\.|::|#)$/
|
407
|
-
common = common.sub(/(\.|::|#)[^:#\.]*?$/, '')
|
412
|
+
common = common.sub(/(\.|::|#)[^:#\.]*?$/, '') if same_parent
|
408
413
|
result = other.sub(/^#{Regexp.quote common}(::|\.|)?/, '')
|
409
414
|
result.empty? ? other : result
|
410
415
|
end
|
@@ -45,6 +45,7 @@ module YARD::CodeObjects
|
|
45
45
|
list += [superclass] unless superclass == P(:Object) || superclass == P(:BasicObject)
|
46
46
|
end
|
47
47
|
[self] + list.map do |m|
|
48
|
+
next m if m == self
|
48
49
|
next m unless m.respond_to?(:inheritance_tree)
|
49
50
|
m.inheritance_tree(include_mods)
|
50
51
|
end.flatten.uniq
|
@@ -104,6 +104,7 @@ module YARD::CodeObjects
|
|
104
104
|
# @return [nil] if it does not override a method
|
105
105
|
# @since 0.6.0
|
106
106
|
def overridden_method
|
107
|
+
return nil if namespace.is_a?(Proxy)
|
107
108
|
meths = namespace.meths(:all => true)
|
108
109
|
meths.find {|m| m.path != path && m.name == name && m.scope == scope }
|
109
110
|
end
|
@@ -230,8 +230,14 @@ module YARD
|
|
230
230
|
def to_obj
|
231
231
|
return @obj if @obj
|
232
232
|
if @obj = Registry.resolve(@namespace, (@imethod ? ISEP : '') + @name.to_s)
|
233
|
-
@
|
234
|
-
|
233
|
+
if @origname && @origname.include?("::") && !@obj.path.include?(@origname)
|
234
|
+
# the object's path should include the original proxy namespace,
|
235
|
+
# otherwise it's (probably) not the right object.
|
236
|
+
@obj = nil
|
237
|
+
else
|
238
|
+
@namespace = @obj.namespace
|
239
|
+
@name = @obj.name
|
240
|
+
end
|
235
241
|
end
|
236
242
|
@obj
|
237
243
|
end
|
data/lib/yard/config.rb
ADDED
@@ -0,0 +1,225 @@
|
|
1
|
+
module YARD
|
2
|
+
# This class maintains all system-wide configuration for YARD and handles
|
3
|
+
# the loading of plugins. To access options call {options}, and to load
|
4
|
+
# a plugin use {load_plugin}. All other public methods are used by YARD
|
5
|
+
# during load time.
|
6
|
+
#
|
7
|
+
# == User Configuration Files
|
8
|
+
#
|
9
|
+
# Persistent user configuration files can be stored in the file
|
10
|
+
# +~/.yard/config+, which is read when YARD first loads. The file should
|
11
|
+
# be formatted as YAML, and should contain a map of keys and values.
|
12
|
+
#
|
13
|
+
# Although you can specify any key-value mapping in the configuration file,
|
14
|
+
# YARD defines special keys specified in {DEFAULT_CONFIG_OPTIONS}.
|
15
|
+
#
|
16
|
+
# An example of a configuration file is listed below:
|
17
|
+
#
|
18
|
+
# !!!yaml
|
19
|
+
# load_plugins: true # Auto-load plugins when YARD starts
|
20
|
+
# ignored_plugins:
|
21
|
+
# - yard-broken
|
22
|
+
# - broken2 # yard- prefix not necessary
|
23
|
+
# autoload_plugins:
|
24
|
+
# - yard-rspec
|
25
|
+
#
|
26
|
+
# == Automatic Loading of Plugins
|
27
|
+
#
|
28
|
+
# YARD 0.6.2 will no longer automatically load all plugins by default. This
|
29
|
+
# option can be reset by setting 'load_plugins' to true in the configuration
|
30
|
+
# file. In addition, you can specify a set of specific plugins to load on
|
31
|
+
# load through the 'autoload_plugins' list setting. This setting is
|
32
|
+
# independent of the 'load_plugins' value and will always be processed.
|
33
|
+
#
|
34
|
+
# == Ignored Plugins File
|
35
|
+
#
|
36
|
+
# YARD 0.5 and below used a +~/.yard/ignored_plugins+ file to specify
|
37
|
+
# plugins to be ignored at load time. Ignored plugins in 0.6.2 and above
|
38
|
+
# should now be specified in the main configuration file, though YARD
|
39
|
+
# will support the +ignored_plugins+ file until 0.7.x.
|
40
|
+
#
|
41
|
+
# == Safe Mode
|
42
|
+
#
|
43
|
+
# YARD supports running in safe-mode. By doing this, it will avoid executing
|
44
|
+
# any user code such as require files or queries. Plugins will still be
|
45
|
+
# loaded with safe mode on, because plugins are properly namespaced with
|
46
|
+
# a 'yard-' prefix, must be installed as a gem, and therefore cannot be
|
47
|
+
# touched by the user. To specify safe mode, use the +safe_mode+ key.
|
48
|
+
#
|
49
|
+
# @since 0.6.2
|
50
|
+
# @see options
|
51
|
+
class Config
|
52
|
+
class << self
|
53
|
+
# The system-wide configuration options for YARD
|
54
|
+
# @return [SymbolHash] a map a key-value pair settings.
|
55
|
+
# @see DEFAULT_CONFIG_OPTIONS
|
56
|
+
attr_accessor :options
|
57
|
+
end
|
58
|
+
|
59
|
+
# The location where YARD stores user-specific settings
|
60
|
+
CONFIG_DIR = File.expand_path('~/.yard')
|
61
|
+
|
62
|
+
# The main configuration YAML file.
|
63
|
+
CONFIG_FILE = File.join(CONFIG_DIR, 'config')
|
64
|
+
|
65
|
+
# File listing all ignored plugins
|
66
|
+
# @deprecated Set `ignored_plugins` in the {CONFIG_FILE} instead.
|
67
|
+
IGNORED_PLUGINS = File.join(CONFIG_DIR, 'ignored_plugins')
|
68
|
+
|
69
|
+
# Default configuration options
|
70
|
+
DEFAULT_CONFIG_OPTIONS = {
|
71
|
+
:load_plugins => false, # Whether to load plugins automatically with YARD
|
72
|
+
:ignored_plugins => [], # A list of ignored plugins by name
|
73
|
+
:autoload_plugins => [], # A list of plugins to be automatically loaded
|
74
|
+
:safe_mode => false # Does not execute or eval any user-level code
|
75
|
+
}
|
76
|
+
|
77
|
+
# The prefix used for YARD plugins. Name your gem with this prefix
|
78
|
+
# to allow it to be used as a plugin.
|
79
|
+
YARD_PLUGIN_PREFIX = /^yard[-_]/
|
80
|
+
|
81
|
+
# Loads settings from {CONFIG_FILE}. This method is called by YARD at
|
82
|
+
# load time and should not be called by the user.
|
83
|
+
# @return [void]
|
84
|
+
def self.load
|
85
|
+
self.options = SymbolHash.new(false)
|
86
|
+
options.update(DEFAULT_CONFIG_OPTIONS)
|
87
|
+
options.update(read_config_file)
|
88
|
+
add_ignored_plugins_file
|
89
|
+
translate_plugin_names
|
90
|
+
load_plugins
|
91
|
+
rescue
|
92
|
+
log.error "Invalid configuration file, using default options."
|
93
|
+
options.update(DEFAULT_CONFIG_OPTIONS)
|
94
|
+
end
|
95
|
+
|
96
|
+
# Saves settings to {CONFIG_FILE}.
|
97
|
+
# @return [void]
|
98
|
+
def self.save
|
99
|
+
require 'yaml'
|
100
|
+
File.open(CONFIG_FILE, 'w') {|f| f.write(YAML.dump(options)) }
|
101
|
+
end
|
102
|
+
|
103
|
+
# Loads gems that match the name 'yard-*' (recommended) or 'yard_*' except
|
104
|
+
# those listed in +~/.yard/ignored_plugins+. This is called immediately
|
105
|
+
# after YARD is loaded to allow plugin support.
|
106
|
+
#
|
107
|
+
# @return [Boolean] true if all plugins loaded successfully, false otherwise.
|
108
|
+
def self.load_plugins
|
109
|
+
load_gem_plugins &&
|
110
|
+
load_autoload_plugins &&
|
111
|
+
load_commandline_plugins ? true : false
|
112
|
+
end
|
113
|
+
|
114
|
+
# Loads an individual plugin by name. It is not necessary to include the
|
115
|
+
# +yard-+ plugin prefix here.
|
116
|
+
#
|
117
|
+
# @param [String] name the name of the plugin (with or without +yard-+ prefix)
|
118
|
+
# @return [Boolean] whether the plugin was successfully loaded
|
119
|
+
def self.load_plugin(name)
|
120
|
+
name = translate_plugin_name(name)
|
121
|
+
return false if options[:ignored_plugins].include?(name)
|
122
|
+
return false if name =~ /^yard-doc-/
|
123
|
+
log.debug "Loading plugin '#{name}'..."
|
124
|
+
require name
|
125
|
+
true
|
126
|
+
rescue LoadError => e
|
127
|
+
load_plugin_failed(name, e)
|
128
|
+
end
|
129
|
+
|
130
|
+
private
|
131
|
+
|
132
|
+
# Load gem plugins if :load_plugins is true
|
133
|
+
def self.load_gem_plugins
|
134
|
+
return true unless options[:load_plugins]
|
135
|
+
require 'rubygems'
|
136
|
+
result = true
|
137
|
+
Gem.source_index.find_name('').each do |gem|
|
138
|
+
begin
|
139
|
+
next true unless gem.name =~ YARD_PLUGIN_PREFIX
|
140
|
+
load_plugin(gem.name)
|
141
|
+
rescue Gem::LoadError => e
|
142
|
+
tmp = load_plugin_failed(gem.name, e)
|
143
|
+
result = tmp if !tmp
|
144
|
+
end
|
145
|
+
end
|
146
|
+
result
|
147
|
+
rescue LoadError
|
148
|
+
log.debug "RubyGems is not present, skipping plugin loading"
|
149
|
+
false
|
150
|
+
end
|
151
|
+
|
152
|
+
# Load plugins set in :autoload_plugins
|
153
|
+
def self.load_autoload_plugins
|
154
|
+
options[:autoload_plugins].each {|name| load_plugin(name) }
|
155
|
+
end
|
156
|
+
|
157
|
+
# Load plugins from {#arguments}
|
158
|
+
def self.load_commandline_plugins
|
159
|
+
with_yardopts do
|
160
|
+
arguments.each_with_index do |arg, i|
|
161
|
+
next unless arg == '--plugin'
|
162
|
+
load_plugin(arguments[i+1])
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
# Print a warning if the plugin failed to load
|
168
|
+
# @return [false]
|
169
|
+
def self.load_plugin_failed(name, exception)
|
170
|
+
log.warn "Error loading plugin '#{name}'"
|
171
|
+
log.backtrace(exception) if $DEBUG
|
172
|
+
false
|
173
|
+
end
|
174
|
+
|
175
|
+
# Legacy support for {IGNORED_PLUGINS}
|
176
|
+
def self.add_ignored_plugins_file
|
177
|
+
if File.file?(IGNORED_PLUGINS)
|
178
|
+
options[:ignored_plugins] += File.read(IGNORED_PLUGINS).split(/\s+/)
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
# Translates plugin names to add yard- prefix.
|
183
|
+
def self.translate_plugin_names
|
184
|
+
options[:ignored_plugins].map! {|name| translate_plugin_name(name) }
|
185
|
+
options[:autoload_plugins].map! {|name| translate_plugin_name(name) }
|
186
|
+
end
|
187
|
+
|
188
|
+
# Loads the YAML configuration file into memory
|
189
|
+
# @return [Hash] the contents of the YAML file from disk
|
190
|
+
# @see CONFIG_FILE
|
191
|
+
def self.read_config_file
|
192
|
+
if File.file?(CONFIG_FILE)
|
193
|
+
require 'yaml'
|
194
|
+
YAML.load_file(CONFIG_FILE)
|
195
|
+
else
|
196
|
+
{}
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
# Sanitizes and normalizes a plugin name to include the 'yard-' prefix.
|
201
|
+
# @param [String] name the plugin name
|
202
|
+
# @return [String] the sanitized and normalized plugin name.
|
203
|
+
def self.translate_plugin_name(name)
|
204
|
+
name = name.gsub('/', '') # Security sanitization
|
205
|
+
name = "yard-" + name unless name =~ YARD_PLUGIN_PREFIX
|
206
|
+
name
|
207
|
+
end
|
208
|
+
|
209
|
+
# Temporarily loads .yardopts file into @yardopts
|
210
|
+
def self.with_yardopts(&block)
|
211
|
+
yfile = CLI::Yardoc::DEFAULT_YARDOPTS_FILE
|
212
|
+
@yardopts = File.file?(yfile) ? File.read_binary(yfile).shell_split : []
|
213
|
+
result = yield
|
214
|
+
@yardopts = nil
|
215
|
+
result
|
216
|
+
end
|
217
|
+
|
218
|
+
# @return [Array<String>] arguments from commandline and yardopts file
|
219
|
+
def self.arguments
|
220
|
+
ARGV + @yardopts
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
Config.options = Config::DEFAULT_CONFIG_OPTIONS
|
225
|
+
end
|
data/lib/yard/handlers/base.rb
CHANGED
@@ -219,6 +219,33 @@ module YARD
|
|
219
219
|
(@namespace_only ||= false) ? true : false
|
220
220
|
end
|
221
221
|
|
222
|
+
# Declares that a handler should only be called when inside a filename
|
223
|
+
# by its basename or a regex match for the full path.
|
224
|
+
#
|
225
|
+
# @param [String, Regexp] filename a matching filename or regex
|
226
|
+
# @return [void]
|
227
|
+
# @since 0.6.2
|
228
|
+
def in_file(filename)
|
229
|
+
(@in_files ||= []) << filename
|
230
|
+
end
|
231
|
+
|
232
|
+
# @return [Boolean] whether the filename matches the declared file
|
233
|
+
# match for a handler. If no file match is specified, returns true.
|
234
|
+
# @since 0.6.2
|
235
|
+
def matches_file?(filename)
|
236
|
+
return true unless @in_files
|
237
|
+
@in_files.any? do |in_file|
|
238
|
+
case in_file
|
239
|
+
when String
|
240
|
+
File.basename(filename) == in_file
|
241
|
+
when Regexp
|
242
|
+
filename =~ in_file
|
243
|
+
else
|
244
|
+
true
|
245
|
+
end
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
222
249
|
# Generates a +process+ method, equivalent to +def process; ... end+.
|
223
250
|
# Blocks defined with this syntax will be wrapped inside an anonymous
|
224
251
|
# module so that the handler class can be extended with mixins that
|
@@ -427,10 +454,10 @@ module YARD
|
|
427
454
|
end
|
428
455
|
end
|
429
456
|
|
430
|
-
|
457
|
+
unless CONTINUATIONS_SUPPORTED
|
431
458
|
unless $NO_CONTINUATION_WARNING
|
432
459
|
$NO_CONTINUATION_WARNING = true
|
433
|
-
log.warn "JRuby/Rubinius do not implement Kernel#callcc and cannot " +
|
460
|
+
log.warn "JRuby/MacRuby/Rubinius do not implement Kernel#callcc and cannot " +
|
434
461
|
"load files in order. You must specify the correct order manually."
|
435
462
|
end
|
436
463
|
raise NamespaceMissingError, object
|