yard 0.5.3 → 0.5.4

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 (90) hide show
  1. data/ChangeLog +443 -0
  2. data/README.md +5 -2
  3. data/docs/WhatsNew.md +8 -0
  4. data/lib/yard.rb +4 -4
  5. data/lib/yard/autoload.rb +34 -30
  6. data/lib/yard/cli/base.rb +14 -0
  7. data/lib/yard/cli/yard_graph.rb +5 -11
  8. data/lib/yard/cli/yardoc.rb +9 -8
  9. data/lib/yard/cli/yri.rb +2 -9
  10. data/lib/yard/code_objects/base.rb +9 -6
  11. data/lib/yard/code_objects/class_object.rb +5 -5
  12. data/lib/yard/code_objects/module_object.rb +3 -2
  13. data/lib/yard/core_ext/file.rb +1 -1
  14. data/lib/yard/docstring.rb +9 -20
  15. data/lib/yard/handlers/base.rb +13 -0
  16. data/lib/yard/handlers/ruby/alias_handler.rb +1 -1
  17. data/lib/yard/handlers/ruby/attribute_handler.rb +1 -1
  18. data/lib/yard/handlers/ruby/class_condition_handler.rb +1 -1
  19. data/lib/yard/handlers/ruby/class_handler.rb +1 -1
  20. data/lib/yard/handlers/ruby/class_variable_handler.rb +1 -1
  21. data/lib/yard/handlers/ruby/constant_handler.rb +1 -1
  22. data/lib/yard/handlers/ruby/exception_handler.rb +1 -1
  23. data/lib/yard/handlers/ruby/legacy/alias_handler.rb +1 -1
  24. data/lib/yard/handlers/ruby/legacy/attribute_handler.rb +1 -1
  25. data/lib/yard/handlers/ruby/legacy/class_condition_handler.rb +8 -0
  26. data/lib/yard/handlers/ruby/legacy/class_handler.rb +1 -1
  27. data/lib/yard/handlers/ruby/legacy/class_variable_handler.rb +1 -1
  28. data/lib/yard/handlers/ruby/legacy/constant_handler.rb +1 -1
  29. data/lib/yard/handlers/ruby/legacy/exception_handler.rb +1 -1
  30. data/lib/yard/handlers/ruby/legacy/method_handler.rb +1 -1
  31. data/lib/yard/handlers/ruby/legacy/mixin_handler.rb +1 -1
  32. data/lib/yard/handlers/ruby/legacy/module_handler.rb +1 -1
  33. data/lib/yard/handlers/ruby/legacy/process_handler.rb +12 -0
  34. data/lib/yard/handlers/ruby/legacy/visibility_handler.rb +1 -1
  35. data/lib/yard/handlers/ruby/legacy/yield_handler.rb +1 -1
  36. data/lib/yard/handlers/ruby/method_condition_handler.rb +1 -1
  37. data/lib/yard/handlers/ruby/method_handler.rb +1 -1
  38. data/lib/yard/handlers/ruby/mixin_handler.rb +1 -1
  39. data/lib/yard/handlers/ruby/module_handler.rb +1 -1
  40. data/lib/yard/handlers/ruby/process_handler.rb +12 -0
  41. data/lib/yard/handlers/ruby/visibility_handler.rb +1 -1
  42. data/lib/yard/handlers/ruby/yield_handler.rb +1 -1
  43. data/lib/yard/parser/ruby/legacy/ruby_lex.rb +1 -1
  44. data/lib/yard/parser/ruby/legacy/statement.rb +6 -0
  45. data/lib/yard/parser/ruby/legacy/statement_list.rb +9 -3
  46. data/lib/yard/parser/ruby/ruby_parser.rb +16 -0
  47. data/lib/yard/tags/default_factory.rb +9 -13
  48. data/lib/yard/tags/library.rb +7 -7
  49. data/lib/yard/tags/overload_tag.rb +4 -4
  50. data/lib/yard/templates/erb_cache.rb +18 -0
  51. data/lib/yard/templates/helpers/html_helper.rb +24 -5
  52. data/lib/yard/templates/helpers/method_helper.rb +10 -2
  53. data/lib/yard/templates/template.rb +11 -7
  54. data/spec/code_objects/class_object_spec.rb +8 -1
  55. data/spec/code_objects/module_object_spec.rb +8 -1
  56. data/spec/core_ext/file_spec.rb +5 -1
  57. data/spec/docstring_spec.rb +80 -42
  58. data/spec/handlers/class_condition_handler_spec.rb +15 -13
  59. data/spec/handlers/examples/process_handler_001.rb.txt +11 -0
  60. data/spec/handlers/process_handler_spec.rb +17 -0
  61. data/spec/parser/source_parser_spec.rb +11 -0
  62. data/spec/tags/overload_tag_spec.rb +2 -2
  63. data/spec/templates/class_spec.rb +9 -0
  64. data/spec/templates/examples/class001.html +20 -17
  65. data/spec/templates/examples/class002.html +37 -0
  66. data/spec/templates/examples/method001.html +7 -7
  67. data/spec/templates/examples/method002.html +5 -5
  68. data/spec/templates/examples/method003.html +5 -5
  69. data/spec/templates/examples/method004.html +3 -3
  70. data/spec/templates/examples/method005.html +1 -1
  71. data/spec/templates/examples/module001.html +64 -36
  72. data/spec/templates/helpers/html_helper_spec.rb +28 -0
  73. data/spec/templates/helpers/method_helper_spec.rb +28 -0
  74. data/spec/templates/module_spec.rb +10 -1
  75. data/spec/templates/template_spec.rb +4 -0
  76. data/templates/default/class/setup.rb +1 -1
  77. data/templates/default/fulldoc/html/css/style.css +6 -1
  78. data/templates/default/fulldoc/html/frames.erb +1 -1
  79. data/templates/default/fulldoc/html/full_list.erb +1 -1
  80. data/templates/default/fulldoc/html/js/app.js +12 -0
  81. data/templates/default/fulldoc/html/js/full_list.js +11 -0
  82. data/templates/default/fulldoc/html/setup.rb +2 -1
  83. data/templates/default/layout/html/headers.erb +1 -1
  84. data/templates/default/layout/html/setup.rb +1 -1
  85. data/templates/default/module/html/box_info.erb +5 -0
  86. data/templates/default/module/html/constant_summary.erb +1 -1
  87. data/templates/default/module/html/inherited_methods.erb +10 -1
  88. data/templates/default/module/html/method_summary.erb +9 -7
  89. data/templates/default/module/setup.rb +17 -3
  90. metadata +9 -2
@@ -2,7 +2,7 @@ class YARD::Handlers::Ruby::ConstantHandler < YARD::Handlers::Ruby::Base
2
2
  namespace_only
3
3
  handles :assign
4
4
 
5
- def process
5
+ process do
6
6
  if statement[1].call? && statement[1][0][0] == s(:const, "Struct") &&
7
7
  statement[1][2] == s(:ident, "new")
8
8
  process_structclass(statement)
@@ -1,7 +1,7 @@
1
1
  class YARD::Handlers::Ruby::ExceptionHandler < YARD::Handlers::Ruby::Base
2
2
  handles method_call(:raise)
3
3
 
4
- def process
4
+ process do
5
5
  return unless owner.is_a?(MethodObject) # Only methods yield
6
6
  return if [:command_call, :call].include? statement.type
7
7
  return if owner.has_tag?(:raise)
@@ -1,7 +1,7 @@
1
1
  class YARD::Handlers::Ruby::Legacy::AliasHandler < YARD::Handlers::Ruby::Legacy::Base
2
2
  handles /\Aalias(_method)?(\s|\()/
3
3
 
4
- def process
4
+ process do
5
5
  if TkALIAS === statement.tokens.first
6
6
  tokens = statement.tokens[2..-1].to_s.split(/\s+/)
7
7
  names = [tokens[0], tokens[1]].map {|t| t.gsub(/^:/, '') }
@@ -1,7 +1,7 @@
1
1
  class YARD::Handlers::Ruby::Legacy::AttributeHandler < YARD::Handlers::Ruby::Legacy::Base
2
2
  handles /\Aattr(?:_(?:reader|writer|accessor))?(?:\s|\()/
3
3
 
4
- def process
4
+ process do
5
5
  begin
6
6
  attr_type = statement.tokens.first.text.to_sym
7
7
  symbols = tokval_list statement.tokens[2..-1], :attr, TkTRUE, TkFALSE
@@ -0,0 +1,8 @@
1
+ class YARD::Handlers::Ruby::Legacy::ClassConditionHandler < YARD::Handlers::Ruby::Legacy::Base
2
+ namespace_only
3
+ handles TkIF, TkELSIF, TkELSE, TkUNLESS
4
+
5
+ process do
6
+ parse_block
7
+ end
8
+ end
@@ -1,7 +1,7 @@
1
1
  class YARD::Handlers::Ruby::Legacy::ClassHandler < YARD::Handlers::Ruby::Legacy::Base
2
2
  handles TkCLASS
3
3
 
4
- def process
4
+ process do
5
5
  if statement.tokens.to_s =~ /^class\s+(#{NAMESPACEMATCH})\s*(?:<\s*(.+)|\Z)/m
6
6
  classname = $1
7
7
  superclass = parse_superclass($2)
@@ -2,7 +2,7 @@ class YARD::Handlers::Ruby::Legacy::ClassVariableHandler < YARD::Handlers::Ruby:
2
2
  HANDLER_MATCH = /\A@@\w+\s*=\s*/m
3
3
  handles HANDLER_MATCH
4
4
 
5
- def process
5
+ process do
6
6
  # Don't document @@cvars if they're set in second class objects (methods) because
7
7
  # they're not "static" when executed from a method
8
8
  return unless owner.is_a? NamespaceObject
@@ -2,7 +2,7 @@ class YARD::Handlers::Ruby::Legacy::ConstantHandler < YARD::Handlers::Ruby::Lega
2
2
  HANDLER_MATCH = /\A[A-Z]\w*\s*=[^=]\s*/m
3
3
  handles HANDLER_MATCH
4
4
 
5
- def process
5
+ process do
6
6
  # Don't document CONSTANTS if they're set in second class objects (methods) because
7
7
  # they're not "static" when executed from a method
8
8
  return unless owner.is_a? NamespaceObject
@@ -1,7 +1,7 @@
1
1
  class YARD::Handlers::Ruby::Legacy::ExceptionHandler < YARD::Handlers::Ruby::Legacy::Base
2
2
  handles /\Araise(\s|\()/
3
3
 
4
- def process
4
+ process do
5
5
  return unless owner.is_a?(MethodObject) # Only methods yield
6
6
  return if owner.has_tag?(:raise)
7
7
 
@@ -1,7 +1,7 @@
1
1
  class YARD::Handlers::Ruby::Legacy::MethodHandler < YARD::Handlers::Ruby::Legacy::Base
2
2
  handles TkDEF
3
3
 
4
- def process
4
+ process do
5
5
  nobj = namespace
6
6
  mscope = scope
7
7
 
@@ -1,7 +1,7 @@
1
1
  class YARD::Handlers::Ruby::Legacy::MixinHandler < YARD::Handlers::Ruby::Legacy::Base
2
2
  handles /\Ainclude(\s|\()/
3
3
 
4
- def process
4
+ process do
5
5
  statement.tokens[1..-1].to_s.split(/\s*,\s*/).each do |mixin|
6
6
  process_mixin(mixin.strip)
7
7
  end
@@ -1,7 +1,7 @@
1
1
  class YARD::Handlers::Ruby::Legacy::ModuleHandler < YARD::Handlers::Ruby::Legacy::Base
2
2
  handles TkMODULE
3
3
 
4
- def process
4
+ process do
5
5
  modname = statement.tokens.to_s[/^module\s+(#{NAMESPACEMATCH})/, 1]
6
6
  mod = register ModuleObject.new(namespace, modname)
7
7
  parse_block(:namespace => mod)
@@ -0,0 +1,12 @@
1
+ class YARD::Handlers::Ruby::Legacy::ProcessHandler < YARD::Handlers::Ruby::Legacy::Base
2
+ handles /\Aprocess(?:\(?|\s)/
3
+ namespace_only
4
+
5
+ process do
6
+ return unless namespace.is_a?(ClassObject) && namespace.superclass.to_s =~ /^YARD::Handlers/
7
+ register MethodObject.new(namespace, :process) do |o|
8
+ o.signature = "def process"
9
+ o.parameters = []
10
+ end
11
+ end
12
+ end
@@ -1,7 +1,7 @@
1
1
  class YARD::Handlers::Ruby::Legacy::VisibilityHandler < YARD::Handlers::Ruby::Legacy::Base
2
2
  handles /\A(protected|private|public)(\s|\(|$)/
3
3
 
4
- def process
4
+ process do
5
5
  vis = statement.tokens.first.text
6
6
  if statement.tokens.size == 1
7
7
  self.visibility = vis
@@ -1,7 +1,7 @@
1
1
  class YARD::Handlers::Ruby::Legacy::YieldHandler < YARD::Handlers::Ruby::Legacy::Base
2
2
  handles TkYIELD
3
3
 
4
- def process
4
+ process do
5
5
  return unless owner.is_a?(MethodObject) # Only methods yield
6
6
  return if owner.has_tag? :yield # Don't override yield tags
7
7
  return if owner.has_tag? :yieldparam # Same thing.
@@ -1,7 +1,7 @@
1
1
  class YARD::Handlers::Ruby::MethodConditionHandler < YARD::Handlers::Ruby::Base
2
2
  handles :if_mod, :unless_mod
3
3
 
4
- def process
4
+ process do
5
5
  parse_block(statement.then_block, owner: owner)
6
6
  end
7
7
  end
@@ -1,7 +1,7 @@
1
1
  class YARD::Handlers::Ruby::MethodHandler < YARD::Handlers::Ruby::Base
2
2
  handles :def, :defs
3
3
 
4
- def process
4
+ process do
5
5
  nobj = namespace
6
6
  mscope = scope
7
7
  if statement.type == :defs
@@ -2,7 +2,7 @@ class YARD::Handlers::Ruby::MixinHandler < YARD::Handlers::Ruby::Base
2
2
  namespace_only
3
3
  handles method_call(:include)
4
4
 
5
- def process
5
+ process do
6
6
  statement.parameters(false).each {|mixin| process_mixin(mixin) }
7
7
  end
8
8
 
@@ -1,7 +1,7 @@
1
1
  class YARD::Handlers::Ruby::ModuleHandler < YARD::Handlers::Ruby::Base
2
2
  handles :module
3
3
 
4
- def process
4
+ process do
5
5
  modname = statement[0].source
6
6
  mod = register ModuleObject.new(namespace, modname)
7
7
  parse_block(statement[1], :namespace => mod)
@@ -0,0 +1,12 @@
1
+ class YARD::Handlers::Ruby::ProcessHandler < YARD::Handlers::Ruby::Base
2
+ handles method_call(:process)
3
+ namespace_only
4
+
5
+ process do
6
+ return unless namespace.is_a?(ClassObject) && namespace.superclass.to_s =~ /^YARD::Handlers/
7
+ register MethodObject.new(namespace, :process) do |o|
8
+ o.signature = "def process"
9
+ o.parameters = []
10
+ end
11
+ end
12
+ end
@@ -3,7 +3,7 @@ class YARD::Handlers::Ruby::VisibilityHandler < YARD::Handlers::Ruby::Base
3
3
  handles method_call(:protected)
4
4
  handles method_call(:public)
5
5
 
6
- def process
6
+ process do
7
7
  return if (ident = statement.jump(:ident)) == statement
8
8
  case statement.type
9
9
  when :var_ref
@@ -1,7 +1,7 @@
1
1
  class YARD::Handlers::Ruby::YieldHandler < YARD::Handlers::Ruby::Base
2
2
  handles :yield, :yield0
3
3
 
4
- def process
4
+ process do
5
5
  return unless owner.is_a?(MethodObject) # Only methods yield
6
6
  return if owner.has_tag? :yield # Don't override yield tags
7
7
  return if owner.has_tag? :yieldparam # Same thing.
@@ -83,7 +83,7 @@ module YARD
83
83
  class TkUnknownChar < Token
84
84
  def initialize(line_no, char_no, id)
85
85
  super(line_no, char_no)
86
- @name = char_no.chr
86
+ @name = char_no > 255 ? '?' : char_no.chr
87
87
  end
88
88
  attr :name
89
89
  end
@@ -29,9 +29,15 @@ module YARD
29
29
  end
30
30
  alias show inspect
31
31
 
32
+ # @return [Fixnum] the first line of Ruby source
32
33
  def line
33
34
  tokens.first.line_no
34
35
  end
36
+
37
+ # @return [Range<Fixnum>] the first to last lines of Ruby source
38
+ def line_range
39
+ tokens.first.line_no..tokens.last.line_no
40
+ end
35
41
 
36
42
  private
37
43
 
@@ -111,7 +111,7 @@ module YARD
111
111
  #
112
112
  # @param [RubyToken::Token] tk the token to process
113
113
  def process_token(tk)
114
- # p tk.text, @state, @level, @current_block, "<br/>"
114
+ # p tk.class, tk.text, @state, @level, @current_block, "<br/>"
115
115
  case @state
116
116
  when :first_statement
117
117
  return if process_initial_comment(tk)
@@ -196,9 +196,15 @@ module YARD
196
196
  # Since, of course, the convention is to have "# text"
197
197
  # and not "#text", which I deem ugly (you heard it here first)
198
198
  @comments ||= []
199
- @comments << tk.text.gsub(/^#+\s{0,1}/, '')
199
+ if tk.text =~ /\A=begin/
200
+ lines = tk.text.count("\n")
201
+ @comments += tk.text.gsub(/\A=begin.*\r?\n|\r?\n=end.*\r?\n?\Z/, '').split(/\r?\n/)
202
+ @comments_last_line = tk.line_no + lines
203
+ else
204
+ @comments << tk.text.gsub(/^#+\s{0,1}/, '')
205
+ @comments_last_line = tk.line_no
206
+ end
200
207
  @comments.pop if @comments.size == 1 && @comments.first =~ /^\s*$/
201
- @comments_last_line = tk.line_no
202
208
  true
203
209
  end
204
210
 
@@ -317,6 +317,22 @@ module YARD
317
317
  @comments_last_column = column
318
318
  end
319
319
 
320
+ def on_embdoc_beg(text)
321
+ visit_ns_token(:embdoc_beg, text)
322
+ @embdoc = ""
323
+ end
324
+
325
+ def on_embdoc(text)
326
+ visit_ns_token(:embdoc, text)
327
+ @embdoc << text
328
+ end
329
+
330
+ def on_embdoc_end(text)
331
+ visit_ns_token(:embdoc_end, text)
332
+ @comments[lineno] = @embdoc
333
+ @embdoc = nil
334
+ end
335
+
320
336
  def on_parse_error(msg)
321
337
  raise ParserSyntaxError, "syntax error in `#{file}`:(#{lineno},#{column}): #{msg}"
322
338
  end
@@ -51,12 +51,8 @@ module YARD
51
51
  Tag.new(tag_name, text, types, name)
52
52
  end
53
53
 
54
- def parse_tag_with_raw_text(tag_name, text, raw_text)
55
- Tag.new(tag_name, raw_text)
56
- end
57
-
58
- def parse_tag_with_raw_title_and_text(tag_name, text, raw_text)
59
- title, desc = *extract_title_and_desc_from_raw_text(raw_text)
54
+ def parse_tag_with_title_and_text(tag_name, text)
55
+ title, desc = *extract_title_and_desc_from_text(text)
60
56
  Tag.new(tag_name, desc, nil, title)
61
57
  end
62
58
 
@@ -87,7 +83,7 @@ module YARD
87
83
  # @return [Array] an array holding the name as the first element and the
88
84
  # value as the second element
89
85
  def extract_name_from_text(text)
90
- text.strip.split(" ", 2)
86
+ text.strip.split(/\s+/, 2)
91
87
  end
92
88
 
93
89
  ##
@@ -102,14 +98,14 @@ module YARD
102
98
  [name, types, (range ? text[(range.end+1)..-1].strip : text)]
103
99
  end
104
100
 
105
- def extract_title_and_desc_from_raw_text(raw_text)
101
+ def extract_title_and_desc_from_text(text)
106
102
  title, desc = nil, nil
107
- if raw_text =~ /\A[ \t]\n/
108
- desc = raw_text
103
+ if text =~ /\A[ \t]\n/
104
+ desc = text
109
105
  else
110
- raw_text = raw_text.split(/\r?\n/)
111
- title = raw_text.shift.squeeze(' ').strip
112
- desc = raw_text.join("\n")
106
+ text = text.split(/\r?\n/)
107
+ title = text.shift.squeeze(' ').strip
108
+ desc = text.join("\n")
113
109
  end
114
110
  [title, desc]
115
111
  end
@@ -90,14 +90,14 @@ module YARD
90
90
  def define_tag(label, tag, meth = "")
91
91
  if meth.is_a?(Class) && Tag > meth
92
92
  class_eval <<-eof, __FILE__, __LINE__
93
- def #{tag}_tag(text, raw_text)
94
- #{meth}.new(#{tag.inspect}, text, raw_text)
93
+ def #{tag}_tag(text)
94
+ #{meth}.new(#{tag.inspect}, text)
95
95
  end
96
96
  eof
97
97
  else
98
98
  class_eval <<-eof, __FILE__, __LINE__
99
- def #{tag}_tag(text, raw_text)
100
- send_to_factory(#{tag.inspect}, #{meth.inspect}, text, raw_text)
99
+ def #{tag}_tag(text)
100
+ send_to_factory(#{tag.inspect}, #{meth.inspect}, text)
101
101
  end
102
102
  eof
103
103
  end
@@ -110,12 +110,12 @@ module YARD
110
110
 
111
111
  private
112
112
 
113
- def send_to_factory(tag_name, meth, text, raw_text)
113
+ def send_to_factory(tag_name, meth, text)
114
114
  meth = meth.to_s
115
115
  send_name = "parse_tag" + (meth.empty? ? "" : "_" + meth)
116
116
  if @factory.respond_to?(send_name)
117
117
  arity = @factory.method(send_name).arity
118
- @factory.send send_name, tag_name, text, *(arity == 3 ? [raw_text] : [])
118
+ @factory.send(send_name, tag_name, text)
119
119
  else
120
120
  raise NoMethodError, "Factory #{@factory.class_name} does not implement factory method :#{meth}."
121
121
  end
@@ -145,7 +145,7 @@ module YARD
145
145
  define_tag "API Visibility", :api
146
146
  define_tag "Note", :note
147
147
  define_tag "Todo Item", :todo
148
- define_tag "Example", :example, :with_raw_title_and_text
148
+ define_tag "Example", :example, :with_title_and_text
149
149
  define_tag "Options Hash", :option, :with_options
150
150
  define_tag "Overloads", :overload, OverloadTag
151
151
  define_tag "Private", :private
@@ -3,9 +3,9 @@ module YARD
3
3
  class OverloadTag < Tag
4
4
  attr_reader :signature, :parameters, :docstring
5
5
 
6
- def initialize(tag_name, text, raw_text)
6
+ def initialize(tag_name, text)
7
7
  super(tag_name, nil)
8
- parse_tag(raw_text)
8
+ parse_tag(text)
9
9
  parse_signature
10
10
  end
11
11
 
@@ -38,8 +38,8 @@ module YARD
38
38
 
39
39
  private
40
40
 
41
- def parse_tag(raw_text)
42
- @signature, text = *raw_text.split(/\r?\n/, 2)
41
+ def parse_tag(text)
42
+ @signature, text = *text.split(/\r?\n/, 2)
43
43
  @signature.strip!
44
44
  text ||= ""
45
45
  numspaces = text[/\A(\s*)/, 1].length
@@ -0,0 +1,18 @@
1
+ module YARD
2
+ module Templates
3
+ module ErbCache
4
+ def self.method_for(filename)
5
+ @methods ||= {}
6
+ return @methods[filename] if @methods[filename]
7
+ @methods[filename] = name = "_erb_cache_#{@methods.size}"
8
+ module_eval "def #{name}; #{yield.src.gsub(/\A#coding:.*$/, '')}; end", filename
9
+ name
10
+ end
11
+
12
+ def self.clear!
13
+ return unless @methods
14
+ @methods.clear
15
+ end
16
+ end
17
+ end
18
+ end
@@ -23,6 +23,25 @@ module YARD
23
23
  def urlencode(text)
24
24
  CGI.escape(text.to_s)
25
25
  end
26
+
27
+ # Returns the current character set. The default value can be overridden
28
+ # by setting the +LANG+ environment variable or by overriding this
29
+ # method. In Ruby 1.9 you can also modify this value by setting
30
+ # +Encoding.default_external+.
31
+ #
32
+ # @return [String] the current character set
33
+ def charset
34
+ return 'utf-8' unless RUBY19 || lang = ENV['LANG']
35
+ if RUBY19
36
+ lang = Encoding.default_external.name.downcase
37
+ else
38
+ lang = lang.downcase.split('.').last
39
+ end
40
+ case lang
41
+ when "ascii-8bit", "us-ascii", "ascii-7bit"; 'iso-8859-1'
42
+ else; lang
43
+ end
44
+ end
26
45
 
27
46
  # Turns text into HTML using +markup+ style formatting.
28
47
  #
@@ -65,7 +84,7 @@ module YARD
65
84
 
66
85
  # @return [String] HTMLified text as a single line (paragraphs removed)
67
86
  def htmlify_line(*args)
68
- htmlify(*args).gsub(/<\/?p>/, '')
87
+ "<div class='inline'>" + htmlify(*args) + "</div>"
69
88
  end
70
89
 
71
90
  # Fixes RDoc behaviour with ++ only supporting alphanumeric text.
@@ -76,7 +95,7 @@ module YARD
76
95
  type_text, pre_text, no_match = $1, $`, $&
77
96
  pre_match = pre_text.scan(%r(</?(?:pre|tt|code).*?>))
78
97
  if pre_match.last.nil? || pre_match.last.include?('/')
79
- '<tt>' + type_text + '</tt>'
98
+ '<tt>' + h(type_text) + '</tt>'
80
99
  else
81
100
  no_match
82
101
  end
@@ -287,7 +306,7 @@ module YARD
287
306
 
288
307
  type = signature_types(meth, link)
289
308
  scope = meth.scope == :class ? "+" : "-"
290
- name = full_attr_name ? meth.name : meth.name.to_s.gsub(/=$/, '')
309
+ name = full_attr_name ? meth.name : meth.name.to_s.gsub(/^(\w+)=$/, '\1')
291
310
  blk = format_block(meth)
292
311
  args = !full_attr_name && meth.writer? ? "" : format_args(meth)
293
312
  extras = []
@@ -316,10 +335,10 @@ module YARD
316
335
 
317
336
  def html_syntax_highlight(source, type = :ruby)
318
337
  return "" unless source
319
- return source if options[:no_highlight]
338
+ return h(source) if options[:no_highlight]
320
339
 
321
340
  # handle !!!LANG prefix to send to html_syntax_highlight_LANG
322
- if source =~ /\A[ \t]*!!!(\w+)[ \t]*\r?\n/
341
+ if source =~ /\A[ \t]*!!!([\w.+-]+)[ \t]*\r?\n/
323
342
  type, source = $1, $'
324
343
  source = $'
325
344
  end