yard 0.7.4 → 0.7.5

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.

Files changed (47) hide show
  1. data/ChangeLog +162 -0
  2. data/README.md +20 -3
  3. data/docs/Glossary.md +2 -2
  4. data/docs/Overview.md +1 -1
  5. data/lib/yard.rb +1 -1
  6. data/lib/yard/cli/yardoc.rb +1 -0
  7. data/lib/yard/code_objects/base.rb +7 -0
  8. data/lib/yard/handlers/ruby/legacy/method_handler.rb +3 -1
  9. data/lib/yard/handlers/ruby/macro_handler_methods.rb +2 -1
  10. data/lib/yard/handlers/ruby/method_handler.rb +3 -1
  11. data/lib/yard/parser/c_parser.rb +48 -52
  12. data/lib/yard/parser/ruby/ruby_parser.rb +13 -1
  13. data/lib/yard/registry_store.rb +1 -1
  14. data/lib/yard/server/commands/library_command.rb +2 -1
  15. data/lib/yard/server/doc_server_helper.rb +3 -3
  16. data/lib/yard/server/doc_server_serializer.rb +9 -9
  17. data/lib/yard/server/rack_adapter.rb +1 -0
  18. data/lib/yard/server/router.rb +2 -0
  19. data/lib/yard/server/templates/doc_server/library_list/html/contents.erb +1 -1
  20. data/lib/yard/server/templates/doc_server/search/html/search.erb +1 -2
  21. data/lib/yard/server/webrick_adapter.rb +1 -0
  22. data/lib/yard/templates/helpers/html_helper.rb +48 -22
  23. data/spec/cli/yardoc_spec.rb +17 -0
  24. data/spec/code_objects/base_spec.rb +1 -1
  25. data/spec/handlers/examples/method_handler_001.rb.txt +4 -0
  26. data/spec/handlers/macro_handler_spec.rb +9 -0
  27. data/spec/handlers/method_handler_spec.rb +7 -0
  28. data/spec/parser/c_parser_spec.rb +134 -9
  29. data/spec/parser/ruby/ruby_parser_spec.rb +17 -1
  30. data/spec/registry_spec.rb +1 -0
  31. data/spec/registry_store_spec.rb +2 -2
  32. data/spec/server/doc_server_helper_spec.rb +51 -0
  33. data/spec/server/doc_server_serializer_spec.rb +10 -23
  34. data/spec/server/rack_adapter_spec.rb +2 -0
  35. data/spec/server/router_spec.rb +8 -1
  36. data/spec/templates/class_spec.rb +2 -1
  37. data/spec/templates/examples/module001.html +1 -1
  38. data/spec/templates/examples/module003.html +186 -0
  39. data/spec/templates/helpers/html_helper_spec.rb +57 -31
  40. data/spec/templates/module_spec.rb +22 -0
  41. data/spec/templates/tag_spec.rb +12 -0
  42. data/templates/default/fulldoc/html/js/full_list.js +6 -0
  43. data/templates/default/module/html/inherited_attributes.erb +6 -9
  44. data/templates/default/module/html/inherited_constants.erb +8 -8
  45. data/templates/default/module/setup.rb +22 -0
  46. data/templates/default/tags/setup.rb +4 -0
  47. metadata +4 -2
data/ChangeLog CHANGED
@@ -1,3 +1,165 @@
1
+ 2012-01-31 Loren Segal <lsegal@soen.ca>
2
+
3
+ * ChangeLog, README.md, lib/yard.rb: Bump to 0.7.5
4
+
5
+ * spec/templates/examples/module003.html, spec/templates/module_spec.rb,
6
+ .../default/module/html/inherited_constants.erb,
7
+ templates/default/module/setup.rb: Don't show inherited constants if
8
+ overridden Backports #474, referencing #467
9
+
10
+ * lib/yard/server/commands/library_command.rb: Verify markup options when
11
+ loading yard opts in server mode Backports #456, referencing #467
12
+
13
+ * lib/yard/parser/c_parser.rb, spec/parser/c_parser_spec.rb: Update tests for
14
+ rb_define_const(), capture definitions Backports #443, referencing #467
15
+
16
+ * lib/yard/templates/helpers/html_helper.rb: Refactor code block parsing out
17
+ of htmlify
18
+
19
+ 2012-01-30 Loren Segal <lsegal@soen.ca>
20
+
21
+ * lib/yard/templates/helpers/html_helper.rb,
22
+ spec/templates/helpers/html_helper_spec.rb: Update tests for
23
+ html_syntax_highlight and minor refactor Backports #478, #479, referencing
24
+ #467 Conflicts: lib/yard/templates/helpers/html_helper.rb
25
+
26
+ 2012-01-30 Dominik Honnef <dominikh@fork-bomb.org>
27
+
28
+ * lib/yard/templates/helpers/html_helper.rb: make parse_lang_for_codeblock
29
+ return the language as a symbol, not a string
30
+
31
+ * lib/yard/templates/helpers/html_helper.rb: rename parse_lang to
32
+ parse_lang_for_codeblock and mark private
33
+
34
+ * lib/yard/templates/helpers/html_helper.rb: fix @return tag of
35
+ HtmlHelper#parse_lang
36
+
37
+ * lib/yard/templates/helpers/html_helper.rb: move parsing of !!!LANG up one
38
+ level to add lang classes to <pre> tags
39
+
40
+ 2012-01-29 Loren Segal <lsegal@soen.ca>
41
+
42
+ * lib/yard/cli/yardoc.rb, spec/cli/yardoc_spec.rb: Do not copy asset inside
43
+ of to/ if to is directory Backports #477, referencing #467
44
+
45
+ 2012-01-26 Loren Segal <lsegal@soen.ca>
46
+
47
+ * lib/yard/handlers/ruby/legacy/method_handler.rb,
48
+ lib/yard/handlers/ruby/method_handler.rb: Fix issue #458 for legacy handlers
49
+ Backport to 0.7.x, referencing #467
50
+
51
+ 2012-01-25 Loren Segal <lsegal@soen.ca>
52
+
53
+ * spec/registry_spec.rb, spec/templates/class_spec.rb: Fix Debian test
54
+ failures in 1.9.3 Backports #397, referencing #467
55
+
56
+ 2012-01-21 Loren Segal <lsegal@soen.ca>
57
+
58
+ * lib/yard/parser/ruby/ruby_parser.rb, spec/parser/ruby/ruby_parser_spec.rb:
59
+ Fix %w() source in []/[]= parsed context. Backports #461, referencing #467
60
+
61
+ * lib/yard/handlers/ruby/method_handler.rb,
62
+ spec/handlers/examples/method_handler_001.rb.txt,
63
+ spec/handlers/method_handler_spec.rb: Don't add default @return if a
64
+ @overload has @return. Backports #458, referencing #467
65
+
66
+ * lib/yard/code_objects/base.rb, spec/code_objects/base_spec.rb: Don't
67
+ discard tags by (see ...). Backports #457 referencing #467
68
+
69
+ 2012-01-19 Loren Segal <lsegal@soen.ca>
70
+
71
+ * lib/yard/handlers/ruby/macro_handler_methods.rb: Allow processing of macros
72
+ attached to Object class (via inheritance) Backports and closes #465,
73
+ referencing #467
74
+
75
+ * lib/yard/handlers/ruby/macro_handler_methods.rb,
76
+ spec/handlers/macro_handler_spec.rb: Do not auto-detect DSL methods as method
77
+ objects if parameter name is not a valid method name Backports and closes
78
+ #464, referencing #467
79
+
80
+ * lib/yard/registry_store.rb, spec/registry_store_spec.rb: Remove heuristics
81
+ that disable single object db Closes #466 referencing #467
82
+
83
+ 2012-01-07 Ankur Patel <ankur.patel@ymail.com>
84
+
85
+ * templates/default/fulldoc/html/js/full_list.js: Ignoring non-printable
86
+ characters in search Closes #446 referencing #467
87
+
88
+ 2012-01-05 Sergey Avseyev <sergey.avseyev@gmail.com>
89
+
90
+ * lib/yard/templates/helpers/html_helper.rb,
91
+ spec/templates/helpers/html_helper_spec.rb: Do not escape snippets twice
92
+ Markup helpers aleardy done escaping. This is actually partial revert of
93
+ 414e53424c28129625d743e41b15556f150fe083 Closes #445 referencing #467
94
+
95
+ 2012-01-19 Loren Segal <lsegal@soen.ca>
96
+
97
+ * spec/templates/examples/module001.html,
98
+ spec/templates/examples/module003.html, spec/templates/module_spec.rb,
99
+ .../default/module/html/inherited_attributes.erb,
100
+ templates/default/module/setup.rb: Run verifier on inherited attributes list
101
+ Backports #432 referencing #467 Conflicts:
102
+ templates/default/module/html/inherited_attributes.erb
103
+
104
+ 2012-01-02 Loren Segal <lsegal@soen.ca>
105
+
106
+ * lib/yard/parser/c_parser.rb, spec/parser/c_parser_spec.rb: Add support for
107
+ rb_path2class() in CRuby
108
+
109
+ * lib/yard/parser/c_parser.rb, spec/parser/c_parser_spec.rb: Properly handle
110
+ parsing of nested namespace definitions Fixes #437
111
+
112
+ 2012-01-01 Loren Segal <lsegal@soen.ca>
113
+
114
+ * spec/templates/examples/module003.html, spec/templates/module_spec.rb,
115
+ .../default/module/html/inherited_attributes.erb: Ignore overwritten
116
+ attributes from inherited list Closes #442
117
+
118
+ * spec/server/rack_adapter_spec.rb: Properly shutdown adapter after rack
119
+ middleware specs
120
+
121
+ 2011-12-26 Sergey Avseyev <sergey.avseyev@gmail.com>
122
+
123
+ * lib/yard/parser/c_parser.rb, spec/parser/c_parser_spec.rb: Allow aliases
124
+ for attributes
125
+
126
+ * lib/yard/parser/c_parser.rb, spec/parser/c_parser_spec.rb: Fix attribute
127
+ parsing This is the real signature for rb_define_attr(). There is only four
128
+ arguments. void rb_define_attr(VALUE klass, const char *name, int read, int
129
+ write)
130
+
131
+ 2011-12-19 Loren Segal <lsegal@soen.ca>
132
+
133
+ * spec/templates/tag_spec.rb, templates/default/tags/setup.rb: Don't render
134
+ param tags on non-method objects Closes #429
135
+
136
+ 2011-12-11 Loren Segal <lsegal@soen.ca>
137
+
138
+ * lib/yard/server/commands/library_command.rb,
139
+ lib/yard/server/doc_server_helper.rb,
140
+ lib/yard/server/doc_server_serializer.rb, lib/yard/server/rack_adapter.rb,
141
+ lib/yard/server/router.rb, .../doc_server/library_list/html/contents.erb,
142
+ .../templates/doc_server/search/html/search.erb,
143
+ lib/yard/server/webrick_adapter.rb, spec/server/doc_server_helper_spec.rb,
144
+ spec/server/doc_server_serializer_spec.rb, spec/server/router_spec.rb: Only
145
+ add /version/ to URLs accessed with /version/ Adds request.version_supplied
146
+ to detect whether the version was parsed out of the URL. Rewrote some of the
147
+ URL helpers and serializers to respect this new behaviour. The biggest
148
+ change is that the DocServerSerializer will no longer add the /prefix to the
149
+ serialized_path, and it will now ignore the command passed in to the
150
+ constructor (which is now optional). Instead, DocServerHelper#url_for should
151
+ be used to generate a URL with a prefix. Closes #426
152
+
153
+ 2011-12-04 Loren Segal <lsegal@soen.ca>
154
+
155
+ * lib/yard/templates/helpers/html_helper.rb,
156
+ spec/templates/helpers/html_helper_spec.rb: Be more forgiving about generated
157
+ HTML for code blocks
158
+
159
+ 2011-12-05 yuta yamada <yamada@clear-code.com>
160
+
161
+ * docs/Glossary.md, docs/Overview.md: fix-typo
162
+
1
163
  2011-12-03 Loren Segal <lsegal@soen.ca>
2
164
 
3
165
  * ChangeLog, README.md, docs/WhatsNew.md, lib/yard.rb: Bump to version 0.7.4
data/README.md CHANGED
@@ -6,10 +6,10 @@ YARD: Yay! A Ruby Documentation Tool
6
6
  **Git**: [http://github.com/lsegal/yard](http://github.com/lsegal/yard)
7
7
  **Author**: Loren Segal
8
8
  **Contributors**: See Contributors section below
9
- **Copyright**: 2007-2011
9
+ **Copyright**: 2007-2012
10
10
  **License**: MIT License
11
- **Latest Version**: 0.7.4 (codename "Kennedy")
12
- **Release Date**: December 2nd 2011
11
+ **Latest Version**: 0.7.5 (codename "Jackson")
12
+ **Release Date**: January 31st 2012
13
13
 
14
14
  Synopsis
15
15
  --------
@@ -289,6 +289,23 @@ More options can be seen by typing `yard-graph --help`, but here is an example:
289
289
  Changelog
290
290
  ---------
291
291
 
292
+ - **January.31.12**: 0.7.5 release
293
+ - Mostly bugfix release (backports from 0.8.0 branch, full list in #467)
294
+ - Don't show inherited attributes if overridden (#432)
295
+ - Capture definitions in `/* definition: docstring */` format in C Ruby (#443)
296
+ - Do not escape highlighted code blocks twice (#445)
297
+ - Ignore non-printable characters in search autocomplete (#446)
298
+ - Verify markup options when loading .yardopts file in server mode (#456)
299
+ - Don't discard tags in (see ...) references (#457)
300
+ - Don't add @return to methods ending in '?' if has @overload (#458)
301
+ - Fix listing of source for %w() blocks with arrays (#461)
302
+ - Do not detect invalid method names as DSL methods (#464)
303
+ - Allow processing of macros attached to Object class (#465)
304
+ - Multi-object db is only enabled via switch (#466)
305
+ - Ignore inherited constants if overridden (#474)
306
+ - Do not copy asset inside dest directory if source is directory (#477)
307
+ - Set pre className when !!!lang is used to denote highlight language (#478, #479)
308
+
292
309
  - **December.2.11**: 0.7.4 release
293
310
  - Redcarpet is now the default Markdown formatting library. GFM now works out-of-box (#404)
294
311
  - Fix server side searching for elements that are marked private (#420)
@@ -5,8 +5,8 @@
5
5
  and class variables, though it can be extended to refer to custom functionality
6
6
  defined by a DSL (like a spec, for instance).
7
7
 
8
- * **Domain Specific Language (DSL)**: In the context of Ruby, a DSL is a languge
8
+ * **Domain Specific Language (DSL)**: In the context of Ruby, a DSL is a language
9
9
  optimized for a specific domain (problem) but represented using Ruby syntax.
10
10
 
11
11
  * **Docstring (Documentation String)**: Comments associated with a code object
12
- used for documentation purposes.
12
+ used for documentation purposes.
@@ -14,7 +14,7 @@ that tools like RDoc do not do. These components are:
14
14
  This separation is a major goal of the project, and means that YARD is not *just*
15
15
  a tool to generate HTML output. The expectation is that any subset of YARD's
16
16
  major components may be used, extended or modified independently. YARD may be
17
- used just as a data gathering tool (to parse and audit code), just as as a data
17
+ used just as a data gathering tool (to parse and audit code), just as a data
18
18
  source (a webserver containing raw unformatted data about code), or just as a
19
19
  conventional HTML documentation generation tool (like RDoc).
20
20
 
@@ -1,5 +1,5 @@
1
1
  module YARD
2
- VERSION = "0.7.4"
2
+ VERSION = "0.7.5"
3
3
 
4
4
  # The root path for YARD source libraries
5
5
  ROOT = File.expand_path(File.dirname(__FILE__))
@@ -340,6 +340,7 @@ module YARD
340
340
  assets.each do |from, to|
341
341
  to = File.join(outpath, to)
342
342
  log.debug "Copying asset '#{from}' to '#{to}'"
343
+ from += '/.' if File.directory?(from)
343
344
  FileUtils.cp_r(from, to)
344
345
  end
345
346
  end
@@ -217,6 +217,8 @@ module YARD
217
217
  @visibility = :public
218
218
  @tags = []
219
219
  @docstring = Docstring.new('', self)
220
+ @docstring_extra = nil
221
+ @docstring_extra_tags = nil
220
222
  @namespace = nil
221
223
  self.namespace = namespace
222
224
  yield(self) if block_given?
@@ -353,7 +355,9 @@ module YARD
353
355
  return @docstring_extra
354
356
  when Base
355
357
  @docstring = @docstring.docstring + @docstring_extra
358
+ @docstring.add_tag(*@docstring_extra_tags)
356
359
  @docstring_extra = nil
360
+ @docstring_extra_tags = nil
357
361
  end
358
362
  @docstring
359
363
  end
@@ -368,9 +372,12 @@ module YARD
368
372
  if comments =~ /\A\s*\(see (\S+)\s*\)(?:\s|$)/
369
373
  path, extra = $1, $'
370
374
  @docstring_extra = Docstring.new(extra, self)
375
+ @docstring_extra_tags = Docstring === comments ? comments.tags : []
376
+ @docstring_extra.add_tag(*@docstring_extra_tags)
371
377
  @docstring = Proxy.new(namespace, path)
372
378
  else
373
379
  @docstring_extra = nil
380
+ @docstring_extra_tags = nil
374
381
  @docstring = Docstring === comments ? comments : Docstring.new(comments, self)
375
382
  end
376
383
  end
@@ -50,7 +50,9 @@ class YARD::Handlers::Ruby::Legacy::MethodHandler < YARD::Handlers::Ruby::Legacy
50
50
  if obj.tag(:return) && (obj.tag(:return).types || []).empty?
51
51
  obj.tag(:return).types = ['Boolean']
52
52
  elsif obj.tag(:return).nil?
53
- obj.docstring.add_tag(YARD::Tags::Tag.new(:return, "", "Boolean"))
53
+ unless obj.tags(:overload).any? {|overload| overload.tag(:return) }
54
+ obj.docstring.add_tag(YARD::Tags::Tag.new(:return, "", "Boolean"))
55
+ end
54
56
  end
55
57
  end
56
58
 
@@ -11,7 +11,7 @@ module YARD
11
11
 
12
12
  # Look for implicit macros
13
13
  (globals.__attached_macros[caller_method] || []).each do |macro|
14
- namespace.inheritance_tree.each do |obj|
14
+ (namespace.inheritance_tree + [P('Object')]).each do |obj|
15
15
  break(@macro = macro) if obj == macro.method_object.namespace
16
16
  end
17
17
  end
@@ -82,6 +82,7 @@ module YARD
82
82
  name = nil if name =~ /\A\s*\Z/
83
83
  name ||= call_params.first
84
84
  return unless name
85
+ return unless name =~ /^#{METHODNAMEMATCH}(\s|\(|$)/
85
86
  if name =~ /\A\s*([^\(; \t]+)/
86
87
  name = $1
87
88
  end
@@ -47,7 +47,9 @@ class YARD::Handlers::Ruby::MethodHandler < YARD::Handlers::Ruby::Base
47
47
  if obj.tag(:return) && (obj.tag(:return).types || []).empty?
48
48
  obj.tag(:return).types = ['Boolean']
49
49
  elsif obj.tag(:return).nil?
50
- obj.docstring.add_tag(YARD::Tags::Tag.new(:return, "", "Boolean"))
50
+ unless obj.tags(:overload).any? {|overload| overload.tag(:return) }
51
+ obj.docstring.add_tag(YARD::Tags::Tag.new(:return, "", "Boolean"))
52
+ end
51
53
  end
52
54
  end
53
55
 
@@ -12,11 +12,10 @@ module YARD
12
12
  end
13
13
 
14
14
  def parse
15
- parse_modules
16
- parse_classes
15
+ parse_namespaces
17
16
  parse_methods
18
- parse_aliases
19
17
  parse_attributes
18
+ parse_aliases
20
19
  parse_constants
21
20
  parse_includes
22
21
  end
@@ -32,6 +31,11 @@ module YARD
32
31
  def remove_var_prefix(var)
33
32
  var.gsub(/^rb_[mc]|^[a-z_]+/, '')
34
33
  end
34
+
35
+ # @since 0.7.5
36
+ def lookup_var(var)
37
+ @namespaces[var] || P(remove_var_prefix(var))
38
+ end
35
39
 
36
40
  def ensure_loaded!(object, max_retries = 1)
37
41
  return if object.is_a?(CodeObjects::RootObject)
@@ -52,9 +56,18 @@ module YARD
52
56
  end
53
57
  object
54
58
  end
59
+
60
+ # @since 0.7.5
61
+ def handle_namespace(var_name, ns_type, ns_name, parent, in_module = nil)
62
+ case ns_type
63
+ when 'module'; handle_module(var_name, ns_name, in_module)
64
+ when 'path2class'; handle_class_lookup(var_name, ns_name)
65
+ else handle_class(var_name, ns_name, parent, in_module)
66
+ end
67
+ end
55
68
 
56
69
  def handle_module(var_name, mod_name, in_module = nil)
57
- namespace = @namespaces[in_module] || (in_module ? P(remove_var_prefix(in_module)) : :root)
70
+ namespace = in_module ? lookup_var(in_module) : :root
58
71
  ensure_loaded!(namespace)
59
72
  obj = CodeObjects::ModuleObject.new(namespace, mod_name)
60
73
  obj.add_file(@file)
@@ -64,14 +77,19 @@ module YARD
64
77
 
65
78
  def handle_class(var_name, class_name, parent, in_module = nil)
66
79
  parent = nil if parent == "0"
67
- namespace = @namespaces[in_module] || (in_module ? P(remove_var_prefix(in_module)) : :root)
80
+ namespace = in_module ? lookup_var(in_module) : :root
68
81
  ensure_loaded!(namespace)
69
82
  obj = CodeObjects::ClassObject.new(namespace, class_name)
70
- obj.superclass = @namespaces[parent] || remove_var_prefix(parent) if parent
83
+ obj.superclass = lookup_var(parent) if parent
71
84
  obj.add_file(@file)
72
85
  find_namespace_docstring(obj)
73
86
  @namespaces[var_name] = obj
74
87
  end
88
+
89
+ # @since 0.7.5
90
+ def handle_class_lookup(var_name, class_name)
91
+ @namespaces[var_name] = P(class_name)
92
+ end
75
93
 
76
94
  # @return [CodeObjects::Base]
77
95
  def handle_method(scope, var_name, name, func_name, source_file = nil)
@@ -80,7 +98,7 @@ module YARD
80
98
  else; scope = :instance
81
99
  end
82
100
 
83
- namespace = @namespaces[var_name] || P(remove_var_prefix(var_name))
101
+ namespace = lookup_var(var_name)
84
102
  ensure_loaded!(namespace)
85
103
  obj = CodeObjects::MethodObject.new(namespace, name, scope)
86
104
  obj.add_file(@file)
@@ -102,7 +120,7 @@ module YARD
102
120
  end
103
121
 
104
122
  def handle_alias(var_name, new_name, old_name)
105
- namespace = P(remove_var_prefix(var_name))
123
+ namespace = lookup_var(var_name)
106
124
  ensure_loaded!(namespace)
107
125
  new_meth, old_meth = new_name.to_sym, old_name.to_sym
108
126
  old_obj = namespace.child(:name => old_meth, :scope => :instance)
@@ -124,12 +142,12 @@ module YARD
124
142
 
125
143
  namespace.aliases[new_obj] = old_meth
126
144
  end
127
-
128
- def handle_attribute(var_name, name, func_name, read, write, source_file = nil)
145
+
146
+ def handle_attribute(var_name, name, read, write, source_file = nil)
129
147
  values = {:read => read.to_i, :write => write.to_i}
130
148
  {:read => name, :write => "#{name}="}.each do |type, meth_name|
131
149
  next unless values[type] > 0
132
- obj = handle_method(:instance, var_name, meth_name, func_name, source_file)
150
+ obj = handle_method(:instance, var_name, meth_name, nil, source_file)
133
151
  ensure_loaded!(obj.namespace)
134
152
  obj.namespace.attributes[:instance][name] ||= SymbolHash[:read => nil, :write => nil]
135
153
  obj.namespace.attributes[:instance][name][type] = obj
@@ -137,7 +155,8 @@ module YARD
137
155
  end
138
156
 
139
157
  def handle_constants(type, var_name, const_name, definition)
140
- namespace = @namespaces[var_name]
158
+ namespace = lookup_var(var_name)
159
+ ensure_loaded!(namespace)
141
160
  obj = CodeObjects::ConstantObject.new(namespace, const_name)
142
161
  obj.value = definition
143
162
  obj.add_file(@file)
@@ -148,16 +167,10 @@ module YARD
148
167
  # "/* definition: comment */" form. The literal ':' and '\' characters
149
168
  # can be escaped with a backslash.
150
169
  if type.downcase == 'const'
151
- elements = comment.split(':')
152
- new_definition = elements[0..-2].join(':')
153
- if new_definition.empty? then # Default to literal C definition
154
- new_definition = definition
155
- else
156
- new_definition.gsub!("\:", ":")
157
- new_definition.gsub!("\\", '\\')
170
+ comment.scan(/\A\s*(.*?[^\s\\]):\s*(.+)/) do |new_value, new_comment|
171
+ obj.value = new_value.gsub(/\\:/, ':')
172
+ comment = new_comment
158
173
  end
159
- new_definition.sub!(/\A(\s+)/, '')
160
- comment = $1.nil? ? elements.last : "#{$1}#{elements.last.lstrip}"
161
174
  end
162
175
 
163
176
  obj.docstring = comment
@@ -335,38 +348,23 @@ module YARD
335
348
  end
336
349
  end
337
350
 
338
- def parse_modules
339
- @content.scan(/(\w+)\s* = \s*rb_define_module\s*
340
- \(\s*"(\w+)"\s*\)/mx) do |var_name, class_name|
341
- handle_module(var_name, class_name)
342
- end
343
-
344
- @content.scan(/(\w+)\s* = \s*rb_define_module_under\s*
345
- \(
346
- \s*(\w+),
347
- \s*"(\w+)"
348
- \s*\)/mx) do |var_name, in_module, class_name|
349
- handle_module(var_name, class_name, in_module)
350
- end
351
- end
352
-
353
- def parse_classes
351
+ def parse_namespaces
354
352
  # The '.' lets us handle SWIG-generated files
355
- @content.scan(/([\w\.]+)\s* = \s*(?:rb_define_class|boot_defclass)\s*
353
+ @content.scan(/([\w\.]+)\s* = \s*(?:rb_define_(class|module)|boot_defclass|rb_(path2class))\s*
356
354
  \(
357
- \s*"(\w+)",
358
- \s*(\w+|0)\s*
359
- \)/mx) do |var_name, class_name, parent|
360
- handle_class(var_name, class_name, parent)
355
+ \s*"([\w:]+)"(?:,
356
+ \s*(\w+|0)\s*)?
357
+ \)/mx) do |var_name, ns_type, path2class, ns_name, parent|
358
+ handle_namespace(var_name, path2class || ns_type, ns_name, parent)
361
359
  end
362
360
 
363
- @content.scan(/([\w\.]+)\s* = \s*rb_define_class_under\s*
361
+ @content.scan(/([\w\.]+)\s* = \s*rb_define_(class|module)_under\s*
364
362
  \(
365
363
  \s*(\w+),
366
- \s*"(\w+)",
367
- \s*([\w\*\s\(\)\.\->]+)\s* # for SWIG
368
- \s*\)/mx) do |var_name, in_module, class_name, parent|
369
- handle_class(var_name, class_name, parent, in_module)
364
+ \s*"(\w+)"(?:,
365
+ \s*([\w\*\s\(\)\.\->]+)\s*)? # for SWIG
366
+ \s*\)/mx) do |var_name, ns_type, in_module, ns_name, parent|
367
+ handle_namespace(var_name, ns_type, ns_name, parent, in_module)
370
368
  end
371
369
  end
372
370
 
@@ -420,10 +418,9 @@ module YARD
420
418
  @content.scan(%r{rb_define_attr
421
419
  \s*\(\s*([\w\.]+),
422
420
  \s*"([^"]+)",
423
- \s*(?:RUBY_METHOD_FUNC\(|VALUEFUNC\()?(\w+)\)?,
424
421
  \s*(0|1)\s*,\s*(0|1)\s*\)
425
422
  (?:;\s*/[*/]\s+in\s+(.+?\.[cy]))?
426
- }xm) do |var_name, name, func_name, read, write, source_file|
423
+ }xm) do |var_name, name, read, write, source_file|
427
424
 
428
425
  # Ignore top-object and weird struct.c dynamic stuff
429
426
  next if var_name == "ruby_top_self"
@@ -431,15 +428,14 @@ module YARD
431
428
  next if var_name == "envtbl"
432
429
 
433
430
  var_name = "rb_cObject" if var_name == "rb_mKernel"
434
- handle_attribute(var_name, name, func_name, read, write, source_file)
431
+ handle_attribute(var_name, name, read, write, source_file)
435
432
  end
436
433
  end
437
434
 
438
435
  def parse_includes
439
436
  @content.scan(/rb_include_module\s*\(\s*(\w+?),\s*(\w+?)\s*\)/) do |klass, mod|
440
437
  if klass = @namespaces[klass]
441
- mod = @namespaces[mod] || P(remove_var_prefix(mod))
442
- klass.mixins(:instance) << mod
438
+ klass.mixins(:instance) << lookup_var(mod)
443
439
  end
444
440
  end
445
441
  end