method
markup_code
v1_9_2_180 -
Show latest stable
- Class:
RDoc::AnyMethod
markup_code()public
Turns the method’s token stream into HTML
# File lib/rdoc/generator/markup.rb, line 91
def markup_code
return '' unless @token_stream
src = ""
@token_stream.each do |t|
next unless t
# style = STYLE_MAP[t.class]
style = case t
when RDoc::RubyToken::TkCONSTANT then "ruby-constant"
when RDoc::RubyToken::TkKW then "ruby-keyword kw"
when RDoc::RubyToken::TkIVAR then "ruby-ivar"
when RDoc::RubyToken::TkOp then "ruby-operator"
when RDoc::RubyToken::TkId then "ruby-identifier"
when RDoc::RubyToken::TkNode then "ruby-node"
when RDoc::RubyToken::TkCOMMENT then "ruby-comment cmt"
when RDoc::RubyToken::TkREGEXP then "ruby-regexp re"
when RDoc::RubyToken::TkSTRING then "ruby-value str"
when RDoc::RubyToken::TkVal then "ruby-value"
else
nil
end
text = CGI.escapeHTML t.text
if style
src << "<span class=\"#{style}\">#{text}</span>"
else
src << text
end
end
add_line_numbers src
src
end Related methods
- Instance methods
- <=>
- add_alias
- add_line_numbers
- aref
- arglists
- full_name
- html_name
- inspect
- markup_code
- marshal_dump
- marshal_load
- name
- param_seq
- parent_name
- path
- pretty_name
- pretty_print
- to_s
- type
- Class methods
- new