Class: Autodoc::Document
- Inherits:
-
Object
- Object
- Autodoc::Document
- Defined in:
- lib/autodoc/document.rb
Defined Under Namespace
Classes: Parameter
Constant Summary collapse
- DEFAULT_DOCUMENT_PATH_FROM_EXAMPLE =
->(example) do example.file_path.gsub(%r<\./spec/[^/]+/(.+)_spec\.rb>, '\1.md') end
Class Method Summary collapse
Instance Method Summary collapse
- #identifier ⇒ Object
-
#initialize(context, example) ⇒ Document
constructor
A new instance of Document.
- #line_number ⇒ Object
- #pathname ⇒ Object
- #render ⇒ Object
- #title ⇒ Object
Constructor Details
#initialize(context, example) ⇒ Document
Returns a new instance of Document.
20 21 22 23 |
# File 'lib/autodoc/document.rb', line 20 def initialize(context, example) @context = context @example = example end |
Class Method Details
.render(*args) ⇒ Object
16 17 18 |
# File 'lib/autodoc/document.rb', line 16 def self.render(*args) new(*args).render end |
Instance Method Details
#identifier ⇒ Object
43 44 45 |
# File 'lib/autodoc/document.rb', line 43 def identifier title.gsub(" ", "-").gsub(/[:\/]/, "").downcase end |
#line_number ⇒ Object
25 26 27 |
# File 'lib/autodoc/document.rb', line 25 def line_number @context.inspect[/:([\d]+)\)>$/, 1].to_i end |
#pathname ⇒ Object
29 30 31 32 33 |
# File 'lib/autodoc/document.rb', line 29 def pathname @pathname ||= begin Autodoc.configuration.pathname + document_path_from_example.call(example) end end |
#render ⇒ Object
35 36 37 |
# File 'lib/autodoc/document.rb', line 35 def render ERB.new(Autodoc.configuration.template, trim_mode: "-").result(binding) end |
#title ⇒ Object
39 40 41 |
# File 'lib/autodoc/document.rb', line 39 def title "#{method} #{path}" end |