Class: Autodoc::Document

Inherits:
Object
  • Object
show all
Defined in:
lib/autodoc/document.rb

Defined Under Namespace

Classes: Parameter

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context, example) ⇒ Document

Returns a new instance of Document.



14
15
16
17
# File 'lib/autodoc/document.rb', line 14

def initialize(context, example)
  @context = context
  @example = example
end

Class Method Details

.render(*args) ⇒ Object



10
11
12
# File 'lib/autodoc/document.rb', line 10

def self.render(*args)
  new(*args).render
end

Instance Method Details

#identifierObject



34
35
36
# File 'lib/autodoc/document.rb', line 34

def identifier
  title.gsub(" ", "-").gsub(/[:\/]/, "").downcase
end

#pathnameObject



19
20
21
22
23
24
# File 'lib/autodoc/document.rb', line 19

def pathname
  @path ||= begin
    payload = example.file_path.gsub(%r<\./spec/requests/(.+)_spec\.rb>, '\1.md')
    Autodoc.configuration.pathname + payload
  end
end

#renderObject



26
27
28
# File 'lib/autodoc/document.rb', line 26

def render
  ERB.new(Autodoc.configuration.template, nil, "-").result(binding)
end

#titleObject



30
31
32
# File 'lib/autodoc/document.rb', line 30

def title
  "#{method} #{path}"
end