Class: PDoc::Generators::Pythonesque::Description

Inherits:
Object
  • Object
show all
Defined in:
lib/pdoc/generators/pythonesque.rb

Constant Summary collapse

JS_ESCAPE_MAP =
{
  '\\'    => '\\\\',
  '</'    => '<\/',
  "\r\n"  => '\n',
  "\n"    => '\n',
  "\r"    => '\n',
  '"'     => '\\"',
  "'"     => "\\'"
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(obj) ⇒ Description

Returns a new instance of Description.



49
50
51
# File 'lib/pdoc/generators/pythonesque.rb', line 49

def initialize(obj)
  @obj = obj
end

Instance Attribute Details

#objObject (readonly)

Returns the value of attribute obj.



48
49
50
# File 'lib/pdoc/generators/pythonesque.rb', line 48

def obj
  @obj
end

Instance Method Details

#to_escaped_strObject



67
68
69
# File 'lib/pdoc/generators/pythonesque.rb', line 67

def to_escaped_str
  escape(to_str)
end

#to_strObject



53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/pdoc/generators/pythonesque.rb', line 53

def to_str
  return "#{obj.full_name} has been deprecated." if obj.deprecated?
  results = []
  results << sig
  results << args if obj.respond_to?(:arguments) && obj.arguments?
  results << desc
  results << aliases if obj.aliases?
  if obj.respond_to?(:constructor) && obj.constructor
    results << "\nWhen called as a constructor:\n"
    results << Description.new(obj.constructor).to_str
  end
  results.join("\n")
end