Class: Yardstick::Document
- Inherits:
-
Object
- Object
- Yardstick::Document
- Defined in:
- lib/yardstick/document.rb
Overview
Wraps a yard docstring to make a nicer interface
Defined Under Namespace
Classes: NullTag
Class Attribute Summary collapse
-
.registered_rules ⇒ Array<Class>
readonly
private
Shows currently registered rules.
Instance Attribute Summary collapse
-
#docstring ⇒ YARD::Docstring
readonly
private
Return document yard docstring.
Class Method Summary collapse
-
.measure(document, config) ⇒ MeasurementSet
private
Measures docstring against enabled rules.
-
.register_rule(rule_class) ⇒ undefined
private
Register rule with document.
Instance Method Summary collapse
-
#api?(types) ⇒ Boolean
private
Check if the method API type matches.
-
#file ⇒ Pathname
private
The filename for the code.
-
#has_tag?(name) ⇒ Boolean
private
Tests if document has a tag.
-
#initialize(docstring) ⇒ undefined
constructor
private
Initializes Document object with docstring.
-
#line ⇒ Integer
private
The line number for the code.
-
#path ⇒ String
private
The class and method name for the code.
-
#summary_text ⇒ String
private
The raw text for the summary.
-
#tag_text(tag_name) ⇒ String?
private
The text for a specified tag.
-
#tag_types(tag_name) ⇒ Array<String>
private
The types for a specified tag.
-
#visibility ⇒ Symbol
private
The method visibility: public, protected or private.
Constructor Details
#initialize(docstring) ⇒ undefined
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initializes Document object with docstring
61 62 63 |
# File 'lib/yardstick/document.rb', line 61 def initialize(docstring) @docstring = docstring end |
Class Attribute Details
.registered_rules ⇒ Array<Class> (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Shows currently registered rules
14 15 16 |
# File 'lib/yardstick/document.rb', line 14 def registered_rules @registered_rules end |
Instance Attribute Details
#docstring ⇒ YARD::Docstring (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return document yard docstring
52 53 54 |
# File 'lib/yardstick/document.rb', line 52 def docstring @docstring end |
Class Method Details
.measure(document, config) ⇒ MeasurementSet
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Measures docstring against enabled rules
39 40 41 42 43 44 45 |
# File 'lib/yardstick/document.rb', line 39 def self.measure(document, config) MeasurementSet.new( registered_rules.map do |rule_class| Measurement.new(rule_class.coerce(document, config)) end ) end |
.register_rule(rule_class) ⇒ undefined
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Register rule with document
25 26 27 |
# File 'lib/yardstick/document.rb', line 25 def self.register_rule(rule_class) registered_rules << rule_class end |
Instance Method Details
#api?(types) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Check if the method API type matches
133 134 135 |
# File 'lib/yardstick/document.rb', line 133 def api?(types) types.include?(tag_text('api')) end |
#file ⇒ Pathname
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The filename for the code
143 144 145 |
# File 'lib/yardstick/document.rb', line 143 def file Pathname(object.file) end |
#has_tag?(name) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Tests if document has a tag
84 85 86 |
# File 'lib/yardstick/document.rb', line 84 def has_tag?(name) # rubocop:disable PredicateName @docstring.has_tag?(name) end |
#line ⇒ Integer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The line number for the code
153 154 155 |
# File 'lib/yardstick/document.rb', line 153 def line object.line end |
#path ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The class and method name for the code
163 164 165 |
# File 'lib/yardstick/document.rb', line 163 def path object.path end |
#summary_text ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The raw text for the summary
71 72 73 |
# File 'lib/yardstick/document.rb', line 71 def summary_text @docstring.split(/\r?\n\r?\n/).first.to_s end |
#tag_text(tag_name) ⇒ String?
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The text for a specified tag
97 98 99 |
# File 'lib/yardstick/document.rb', line 97 def tag_text(tag_name) tag(tag_name).text end |
#tag_types(tag_name) ⇒ Array<String>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The types for a specified tag
110 111 112 |
# File 'lib/yardstick/document.rb', line 110 def tag_types(tag_name) tag(tag_name).types end |
#visibility ⇒ Symbol
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The method visibility: public, protected or private
120 121 122 |
# File 'lib/yardstick/document.rb', line 120 def visibility object.visibility end |