diff options
author | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-11-27 10:45:24 +0000 |
---|---|---|
committer | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-11-27 10:45:24 +0000 |
commit | 55518710865bd7258422807524403c91347519a2 (patch) | |
tree | 4146c423ab0c55ed35d9d860e64d7e3a7e2a9efb /lib/rdoc/token_stream.rb | |
parent | 2d9f20e1cfdc7532a8acef4da9b8b7a788c4e99a (diff) |
Merge rdoc-6.0.0.beta4 from upstream.
It version applied `frozen_string_literal: true`
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60920 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rdoc/token_stream.rb')
-rw-r--r-- | lib/rdoc/token_stream.rb | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/lib/rdoc/token_stream.rb b/lib/rdoc/token_stream.rb index 2b69e943cd..05fb46e89a 100644 --- a/lib/rdoc/token_stream.rb +++ b/lib/rdoc/token_stream.rb @@ -1,4 +1,4 @@ -# frozen_string_literal: false +# frozen_string_literal: true ## # A TokenStream is a list of tokens, gathered during the parse of some entity # (say a method). Entities populate these streams by being registered with the @@ -14,6 +14,8 @@ module RDoc::TokenStream # with the given class names. Other token types are not wrapped in spans. def self.to_html token_stream + starting_title = false + token_stream.map do |t| next unless t @@ -23,12 +25,8 @@ module RDoc::TokenStream when :on_ivar then 'ruby-ivar' when :on_cvar then 'ruby-identifier' when :on_gvar then 'ruby-identifier' - when '=' != t[:text] && :on_op then - if RDoc::RipperStateLex::EXPR_ARG == t[:state] then - 'ruby-identifier' - else - 'ruby-operator' - end + when '=' != t[:text] && :on_op + then 'ruby-operator' when :on_tlambda then 'ruby-operator' when :on_ident then 'ruby-identifier' when :on_label then 'ruby-value' @@ -53,6 +51,16 @@ module RDoc::TokenStream else text = t[:text] end + + if :on_ident == t[:kind] && starting_title + starting_title = false + style = 'ruby-identifier ruby-title' + end + + if :on_kw == t[:kind] and 'def' == t[:text] + starting_title = true + end + text = CGI.escapeHTML text if style then |