Class: ReadmeYard::CommentTag
- Inherits:
-
Object
- Object
- ReadmeYard::CommentTag
- Defined in:
- lib/readme_yard/comment_tag.rb
Overview
@readme comment
- Embeds the comment.
Class Method Summary collapse
- .format_docstring_as_comment(yard_object) ⇒ Object
-
.format_tag_markdown(yard_object, _tag) ⇒ Object
This comment is in the README because
@readme comment
is below, in the source code. - .named_readme_tag_regex ⇒ Object
Class Method Details
.format_docstring_as_comment(yard_object) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/readme_yard/comment_tag.rb', line 22 def format_docstring_as_comment(yard_object) comment = +"" docstring = yard_object.docstring.all docstring.gsub!(named_readme_tag_regex, "") docstring.lines.each do |line| comment << "#" comment << " " unless line[0] == "\n" comment << line end last_line = yard_object.docstring.all.lines.last comment << "#" if last_line.match?(/\n$/) comment end |
.format_tag_markdown(yard_object, _tag) ⇒ Object
This comment is in the README because @readme comment
is below, in the source code.
comment
14 15 16 17 |
# File 'lib/readme_yard/comment_tag.rb', line 14 def format_tag_markdown(yard_object, _tag) comment = format_docstring_as_comment(yard_object) ExampleTag.format_ruby(comment) end |
.named_readme_tag_regex ⇒ Object
36 37 38 |
# File 'lib/readme_yard/comment_tag.rb', line 36 def named_readme_tag_regex @named_readme_tag_regex ||= /(\n|^)@readme\s(#{YARDReadme::DocstringParser.readme_tag_names.join("|")})\n/ end |