yard 0.9.38 → 0.9.42

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +44 -1
  3. data/README.md +18 -21
  4. data/docs/GettingStarted.md +41 -15
  5. data/docs/Parser.md +17 -42
  6. data/docs/Tags.md +5 -5
  7. data/docs/WhatsNew.md +59 -7
  8. data/docs/templates/default/yard_tags/html/setup.rb +1 -1
  9. data/lib/yard/autoload.rb +17 -0
  10. data/lib/yard/cli/diff.rb +7 -2
  11. data/lib/yard/code_objects/proxy.rb +1 -1
  12. data/lib/yard/handlers/processor.rb +1 -0
  13. data/lib/yard/handlers/rbs/attribute_handler.rb +43 -0
  14. data/lib/yard/handlers/rbs/base.rb +38 -0
  15. data/lib/yard/handlers/rbs/constant_handler.rb +18 -0
  16. data/lib/yard/handlers/rbs/method_handler.rb +327 -0
  17. data/lib/yard/handlers/rbs/mixin_handler.rb +20 -0
  18. data/lib/yard/handlers/rbs/namespace_handler.rb +26 -0
  19. data/lib/yard/handlers/ruby/attribute_handler.rb +7 -4
  20. data/lib/yard/handlers/ruby/constant_handler.rb +1 -0
  21. data/lib/yard/i18n/locale.rb +1 -1
  22. data/lib/yard/i18n/pot_generator.rb +1 -1
  23. data/lib/yard/parser/rbs/rbs_parser.rb +325 -0
  24. data/lib/yard/parser/rbs/statement.rb +75 -0
  25. data/lib/yard/parser/ruby/legacy/irb/slex.rb +19 -1
  26. data/lib/yard/parser/ruby/ruby_parser.rb +55 -3
  27. data/lib/yard/parser/source_parser.rb +3 -2
  28. data/lib/yard/registry_resolver.rb +7 -0
  29. data/lib/yard/rubygems/specification.rb +1 -1
  30. data/lib/yard/server/commands/base.rb +1 -1
  31. data/lib/yard/server/library_version.rb +1 -1
  32. data/lib/yard/server/templates/default/fulldoc/html/css/custom.css +168 -88
  33. data/lib/yard/server/templates/default/fulldoc/html/js/autocomplete.js +203 -12
  34. data/lib/yard/server/templates/default/layout/html/breadcrumb.erb +1 -17
  35. data/lib/yard/server/templates/default/method_details/html/permalink.erb +4 -2
  36. data/lib/yard/server/templates/doc_server/library_list/html/headers.erb +3 -3
  37. data/lib/yard/server/templates/doc_server/library_list/html/library_list.erb +2 -3
  38. data/lib/yard/server/templates/doc_server/processing/html/processing.erb +22 -16
  39. data/lib/yard/tags/directives.rb +7 -0
  40. data/lib/yard/tags/library.rb +3 -3
  41. data/lib/yard/tags/types_explainer.rb +2 -1
  42. data/lib/yard/templates/helpers/base_helper.rb +1 -1
  43. data/lib/yard/templates/helpers/html_helper.rb +16 -5
  44. data/lib/yard/templates/helpers/html_syntax_highlight_helper.rb +6 -1
  45. data/lib/yard/templates/helpers/markup/hybrid_markdown.rb +2147 -0
  46. data/lib/yard/templates/helpers/markup_helper.rb +4 -2
  47. data/lib/yard/version.rb +1 -1
  48. data/po/ja.po +82 -82
  49. data/templates/default/fulldoc/html/css/common.css +1 -1
  50. data/templates/default/fulldoc/html/css/full_list.css +201 -53
  51. data/templates/default/fulldoc/html/css/style.css +988 -389
  52. data/templates/default/fulldoc/html/full_list.erb +4 -4
  53. data/templates/default/fulldoc/html/js/app.js +801 -395
  54. data/templates/default/fulldoc/html/js/full_list.js +332 -242
  55. data/templates/default/layout/html/headers.erb +1 -1
  56. data/templates/default/layout/html/layout.erb +3 -1
  57. data/templates/default/method/html/header.erb +3 -3
  58. data/templates/default/module/html/defines.erb +3 -3
  59. data/templates/default/module/html/inherited_methods.erb +1 -0
  60. data/templates/default/module/html/method_summary.erb +8 -0
  61. data/templates/default/module/setup.rb +20 -0
  62. data/templates/default/onefile/html/layout.erb +3 -4
  63. data/templates/guide/fulldoc/html/css/style.css +347 -97
  64. data/templates/guide/fulldoc/html/js/app.js +61 -33
  65. data/templates/guide/layout/html/layout.erb +69 -72
  66. metadata +14 -4
@@ -507,7 +507,7 @@ module YARD
507
507
  #
508
508
  # @example
509
509
  # # Synchronizes system time using NTP.
510
- # # @see http://ntp.org/documentation.html NTP Documentation
510
+ # # @see https://ntp.org/documentation.html NTP Documentation
511
511
  # # @see NTPHelperMethods
512
512
  # class NTPUpdater; end
513
513
  define_tag "See Also", :see, :with_name
@@ -541,7 +541,7 @@ module YARD
541
541
  # @example
542
542
  # # @todo Add support for Jabberwocky service.
543
543
  # # There is an open source Jabberwocky library available
544
- # # at http://jbrwcky.org that can be easily integrated.
544
+ # # at https://jbrwcky.org that can be easily integrated.
545
545
  # class Wonderlander; end
546
546
  # @see tag:note
547
547
  define_tag "Todo Item", :todo
@@ -554,7 +554,7 @@ module YARD
554
554
  # of a specific object.
555
555
  #
556
556
  # @example
557
- # # The public REST API for http://jbrwcky.org
557
+ # # The public REST API for https://jbrwcky.org
558
558
  # # @version 2.0
559
559
  # class JabberwockyAPI; end
560
560
  define_tag "Version", :version
@@ -102,6 +102,7 @@ module YARD
102
102
  :fixed_collection_start => /\(/,
103
103
  :fixed_collection_end => /\)/,
104
104
  :type_name => /#{ISEP}#{METHODNAMEMATCH}|#{NAMESPACEMATCH}|\w+/,
105
+ :symbol => /:#{METHODNAMEMATCH}/,
105
106
  :type_next => /[,;]/,
106
107
  :whitespace => /\s+/,
107
108
  :hash_collection_start => /\{/,
@@ -130,7 +131,7 @@ module YARD
130
131
  next unless (match.nil? && @scanner.eos?) || (match && token = @scanner.scan(match))
131
132
  found = true
132
133
  case token_type
133
- when :type_name
134
+ when :type_name, :symbol
134
135
  raise SyntaxError, "expecting END, got name '#{token}'" if name
135
136
  name = token
136
137
  when :type_next
@@ -45,7 +45,7 @@ module YARD::Templates::Helpers
45
45
  # method depending on the arguments passed in.
46
46
  #
47
47
  # @example Linking a URL
48
- # linkify('http://example.com')
48
+ # linkify('https://example.com')
49
49
  # @example Including docstring contents of an object
50
50
  # linkify('include:YARD::Docstring')
51
51
  # @example Linking to an extra file
@@ -93,10 +93,16 @@ module YARD
93
93
  :tables,
94
94
  :with_toc_data,
95
95
  :no_intraemphasis).to_html
96
+ when 'Commonmarker'
97
+ provider.to_html(text, :options => { }, :plugins => { :syntax_highlighter => nil })
96
98
  when 'CommonMarker'
97
- CommonMarker.render_html(text, %i[DEFAULT GITHUB_PRE_LANG], %i[autolink table])
99
+ provider.render_html(text, %i[DEFAULT GITHUB_PRE_LANG], %i[autolink table])
98
100
  else
99
- provider.new(text).to_html
101
+ if provider.respond_to?(:to_html)
102
+ provider.to_html(text)
103
+ else
104
+ provider.new(text).to_html
105
+ end
100
106
  end
101
107
  end
102
108
 
@@ -156,7 +162,7 @@ module YARD
156
162
  # @return [String] the output HTML
157
163
  # @since 0.6.0
158
164
  def html_markup_text(text)
159
- h(text).gsub(/\r?\n/, '<br/>')
165
+ h(text).gsub(/\r?\n/, '<br>')
160
166
  end
161
167
 
162
168
  # @return [String] the same text with no markup
@@ -228,7 +234,7 @@ module YARD
228
234
  # @return [String] HTML with linkified references
229
235
  def resolve_links(text)
230
236
  code_tags = 0
231
- text.gsub(%r{<(/)?(pre|code|tt)|(\\|!)?\{(?!\})(\S+?)(?:\s([^\}]*?\S))?\}(?=[\W<]|.+</|$)}m) do |str|
237
+ text.gsub(%r{<(/)?(pre|code|tt)|(\\|!)?\{(?!\})(\S+?)(?:\s([^\}]*?\S))?\}(?=\W|.+</|$)}m) do |str|
232
238
  closed = $1
233
239
  tag = $2
234
240
  escape = $3
@@ -650,7 +656,12 @@ module YARD
650
656
  language ||= detect_lang_in_codeblock_attributes($1, $2)
651
657
  language ||= object.source_type
652
658
 
653
- if options.highlight
659
+ # Skip re-highlighting if the block is already highlighted (e.g. from a recursive
660
+ # htmlify call via {include:} or {yard:include_tags}). Passing pre-highlighted HTML
661
+ # through CGI.unescapeHTML would corrupt deliberately-escaped entities inside spans.
662
+ # Note: this heuristic suppresses highlighting for code blocks in :html markup that
663
+ # contain a literal <span> tag in the source being documented (an uncommon edge case).
664
+ if options.highlight && string !~ HtmlSyntaxHighlightHelper::ALREADY_HIGHLIGHTED_RE
654
665
  string = html_syntax_highlight(CGI.unescapeHTML(string), language)
655
666
  end
656
667
  classes = ['code', language].compact.join(' ')
@@ -6,6 +6,11 @@ module YARD
6
6
  module HtmlSyntaxHighlightHelper
7
7
  include ModuleHelper
8
8
 
9
+ # Matches source that has already been highlighted (i.e. contains a span tag).
10
+ # Used to avoid double-processing pre-highlighted HTML in the rescue clause of
11
+ # {#html_syntax_highlight_ruby_ripper} and in the {HtmlHelper#parse_codeblocks} guard.
12
+ ALREADY_HIGHLIGHTED_RE = /<span[\s>]/
13
+
9
14
  # Highlights Ruby source
10
15
  # @param [String] source the Ruby source code
11
16
  # @return [String] the highlighted Ruby source
@@ -39,7 +44,7 @@ module YARD
39
44
  end
40
45
  output
41
46
  rescue Parser::ParserSyntaxError
42
- source =~ /^<span\s+class=/ ? source : h(source)
47
+ source =~ ALREADY_HIGHLIGHTED_RE ? source : h(source)
43
48
  end
44
49
 
45
50
  def html_syntax_highlight_ruby_legacy(source)