Module: Inch::CodeObject::Provider::YARD::NodocHelper
- Included in:
- Object::Base
- Defined in:
- lib/inch/code_object/provider/yard/nodoc_helper.rb
Constant Summary collapse
- NO_DOC_REGEX =
/#\s*\:nodoc\:/
- NO_DOC_ALL_REGEX =
/#\s*\:nodoc\:\s*all/
- DOC_REGEX =
/#\s*\:doc\:/
Instance Method Summary collapse
-
#declarations ⇒ Array<String>
Returns all lines in all files declaring the object.
- #explicit_doc_comment? ⇒ Boolean
- #explicit_nodoc_all_comment? ⇒ Boolean
- #explicit_nodoc_comment? ⇒ Boolean
-
#get_line_no(filename, line_number) ⇒ String
Returns a
line_number
from a file. - #implicit_nodoc_all_comment? ⇒ Boolean
- #implicit_nodoc_comment? ⇒ Boolean
-
#nodoc? ⇒ Boolean
Returns true if the code object is somehow marked not to be documented.
- #nodoc_comment? ⇒ Boolean
Instance Method Details
#declarations ⇒ Array<String>
Returns all lines in all files declaring the object
70 71 72 73 74 |
# File 'lib/inch/code_object/provider/yard/nodoc_helper.rb', line 70 def declarations @declarations ||= files.map do |f| get_line_no(f.filename, f.line_no) end end |
#explicit_doc_comment? ⇒ Boolean
31 32 33 |
# File 'lib/inch/code_object/provider/yard/nodoc_helper.rb', line 31 def explicit_doc_comment? declarations.any? { |str| str =~ DOC_REGEX } end |
#explicit_nodoc_all_comment? ⇒ Boolean
27 28 29 |
# File 'lib/inch/code_object/provider/yard/nodoc_helper.rb', line 27 def explicit_nodoc_all_comment? declarations.any? { |str| str =~ NO_DOC_ALL_REGEX } end |
#explicit_nodoc_comment? ⇒ Boolean
23 24 25 |
# File 'lib/inch/code_object/provider/yard/nodoc_helper.rb', line 23 def explicit_nodoc_comment? declarations.any? { |str| str =~ NO_DOC_REGEX } end |
#get_line_no(filename, line_number) ⇒ String
Returns a line_number
from a file
81 82 83 84 85 86 87 88 |
# File 'lib/inch/code_object/provider/yard/nodoc_helper.rb', line 81 def get_line_no(filename, line_number) f = File.open(filename) line_number.times { f.gets } result = $_ # LAST_READ_LINE f.close result.encode("UTF-8", "binary", invalid: :replace, undef: :replace, replace: "") end |
#implicit_nodoc_all_comment? ⇒ Boolean
35 36 37 38 39 40 |
# File 'lib/inch/code_object/provider/yard/nodoc_helper.rb', line 35 def implicit_nodoc_all_comment? if parent parent.explicit_nodoc_all_comment? || parent.implicit_nodoc_all_comment? end end |
#implicit_nodoc_comment? ⇒ Boolean
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/inch/code_object/provider/yard/nodoc_helper.rb', line 42 def implicit_nodoc_comment? return false if explicit_doc_comment? if parent return false if parent.explicit_doc_comment? if namespace? if parent.explicit_nodoc_all_comment? return true else return parent.implicit_nodoc_all_comment? end else if parent.explicit_nodoc_comment? return true else return parent.implicit_nodoc_all_comment? end end end end |
#nodoc? ⇒ Boolean
Note:
Doesnot recognize “:startdoc:” and “:stopdoc:”
Returns true if the code object is somehow marked not to be documented.
11 12 13 |
# File 'lib/inch/code_object/provider/yard/nodoc_helper.rb', line 11 def nodoc? tagged_as_private? || nodoc_comment? end |
#nodoc_comment? ⇒ Boolean
19 20 21 |
# File 'lib/inch/code_object/provider/yard/nodoc_helper.rb', line 19 def nodoc_comment? explicit_nodoc_comment? || implicit_nodoc_comment? end |