(PDOC-212, PDOC-213) add support for @note and @todo

This commit is contained in:
Eric Putnam 2018-04-21 21:38:53 +01:00
parent d122b1962b
commit adbf887246
No known key found for this signature in database
GPG Key ID: 3FB595AA224A7751
26 changed files with 143 additions and 11 deletions

View File

@ -57,7 +57,9 @@ module PuppetStrings::Markdown
# e.g. {:tag_name=>"author", :text=>"eputnam"} # e.g. {:tag_name=>"author", :text=>"eputnam"}
{ :return_val => 'return', { :return_val => 'return',
:since => 'since', :since => 'since',
:summary => 'summary' }.each do |method_name, tag_name| :summary => 'summary',
:note => 'note',
:todo => 'todo' }.each do |method_name, tag_name|
# @return [String] unless the tag is nil or the string.length == 0 # @return [String] unless the tag is nil or the string.length == 0
define_method method_name do define_method method_name do
@tags.select { |tag| tag[:tag_name] == "#{tag_name}" }[0][:text] unless @tags.select { |tag| tag[:tag_name] == "#{tag_name}" }[0].nil? || @tags.select { |tag| tag[:tag_name] == "#{tag_name}" }[0][:text].length.zero? @tags.select { |tag| tag[:tag_name] == "#{tag_name}" }[0][:text] unless @tags.select { |tag| tag[:tag_name] == "#{tag_name}" }[0].nil? || @tags.select { |tag| tag[:tag_name] == "#{tag_name}" }[0][:text].length.zero?

View File

@ -8,6 +8,14 @@
<%= "The #{name} class." %> <%= "The #{name} class." %>
<% end -%> <% end -%>
<% if todo -%>
* **TODO** <%= todo %>
<% end -%>
<% if note -%>
* **Note** <%= note %>
<% end -%>
<% if since -%> <% if since -%>
* **Since** <%= since %> * **Since** <%= since %>

View File

@ -7,7 +7,15 @@ Type: <%= type %>
<% elsif summary -%> <% elsif summary -%>
<%= summary %> <%= summary %>
<% else -%> <% else -%>
<%= "The #{name} class." %> <%= "The #{name} function." %>
<% end -%>
<% if todo -%>
* **TODO** <%= todo %>
<% end -%>
<% if note -%>
* **Note** <%= note %>
<% end -%> <% end -%>
<% signatures.each do |sig| -%> <% signatures.each do |sig| -%>
@ -16,6 +24,16 @@ Type: <%= type %>
<% if sig.text -%> <% if sig.text -%>
<%= sig.text %> <%= sig.text %>
<% elsif sig.summary -%>
<%= sig.summary %>
<% else -%>
<%= "The #{name} function." %>
<% end -%>
<% if sig.note -%>
* **Note** <%= sig.note %>
<% end -%> <% end -%>
<% if sig.return_type -%> <% if sig.return_type -%>
Returns: `<%= sig.return_type %>`<% if sig.return_val %> <%= sig.return_val %><% end %> Returns: `<%= sig.return_type %>`<% if sig.return_val %> <%= sig.return_val %><% end %>

View File

@ -8,6 +8,14 @@
<%= "The #{name} type." %> <%= "The #{name} type." %>
<% end -%> <% end -%>
<% if todo -%>
* **TODO** <%= todo %>
<% end -%>
<% if note -%>
* **Note** <%= note %>
<% end -%>
<% if since -%> <% if since -%>
* **Since** <%= since %> * **Since** <%= since %>

View File

@ -0,0 +1,6 @@
<% object.tags(:note).each do |tag| %>
<div class="note notetag">
<strong>Note:</strong>
<%= htmlify_line tag.text %>
</div>
<% end %>

View File

@ -1,7 +1,7 @@
# Initializes the template. # Initializes the template.
# @return [void] # @return [void]
def init def init
sections :header, :box_info, :summary, :overview, T('tags'), :source sections :header, :box_info, :summary, :overview, :note, :todo, T('tags'), :source
end end
# Renders the box_info section. # Renders the box_info section.

View File

@ -0,0 +1,6 @@
<% object.tags(:todo).each do |tag| %>
<div class="note todo">
<strong>TODO:</strong>
<%= htmlify_line tag.text %>
</div>
<% end %>

View File

@ -0,0 +1,6 @@
<% object.tags(:note).each do |tag| %>
<div class="note notetag">
<strong>Note:</strong>
<%= htmlify_line tag.text %>
</div>
<% end %>

View File

@ -1,5 +1,5 @@
# Initializes the template. # Initializes the template.
# @return [void] # @return [void]
def init def init
sections :header, :box_info, :summary, :overview, T('tags'), :source sections :header, :box_info, :summary, :overview, :note, :todo, T('tags'), :source
end end

View File

@ -0,0 +1,6 @@
<% object.tags(:todo).each do |tag| %>
<div class="note todo">
<strong>TODO:</strong>
<%= htmlify_line tag.text %>
</div>
<% end %>

View File

@ -0,0 +1,6 @@
<% object.tags(:note).each do |tag| %>
<div class="note notetag">
<strong>Note:</strong>
<%= htmlify_line tag.text %>
</div>
<% end %>

View File

@ -1,5 +1,5 @@
# Initializes the template. # Initializes the template.
# @return [void] # @return [void]
def init def init
sections :header, :box_info, :summary, :overview, [T('tags'), :source] sections :header, :box_info, :summary, :overview, :note, :todo, [T('tags'), :source]
end end

View File

@ -0,0 +1,6 @@
<% object.tags(:todo).each do |tag| %>
<div class="note todo">
<strong>TODO:</strong>
<%= htmlify_line tag.text %>
</div>
<% end %>

View File

@ -0,0 +1,6 @@
<% object.tags(:note).each do |tag| %>
<div class="note notetag">
<strong>Note:</strong>
<%= htmlify_line tag.text %>
</div>
<% end %>

View File

@ -1,7 +1,7 @@
# Initializes the template. # Initializes the template.
# @return [void] # @return [void]
def init def init
sections :header, :box_info, :summary, :overview, T('tags'), :source sections :header, :box_info, :summary, :overview, :note, :todo, T('tags'), :source
end end
# Renders the box_info section. # Renders the box_info section.

View File

@ -0,0 +1,6 @@
<% object.tags(:todo).each do |tag| %>
<div class="note todo">
<strong>TODO:</strong>
<%= htmlify_line tag.text %>
</div>
<% end %>

View File

@ -0,0 +1,6 @@
<% object.tags(:note).each do |tag| %>
<div class="note notetag">
<strong>Note:</strong>
<%= htmlify_line tag.text %>
</div>
<% end %>

View File

@ -1,7 +1,7 @@
# Initializes the template. # Initializes the template.
# @return [void] # @return [void]
def init def init
sections :header, :box_info, :summary, :overview, T('tags'), :properties, :parameters, :features sections :header, :box_info, :summary, :overview, :note, :todo, T('tags'), :properties, :parameters, :features
end end
# Renders the box_info section. # Renders the box_info section.

View File

@ -0,0 +1,6 @@
<% object.tags(:todo).each do |tag| %>
<div class="note todo">
<strong>TODO:</strong>
<%= htmlify_line tag.text %>
</div>
<% end %>

View File

@ -3,11 +3,19 @@
{ {
"name": "klass", "name": "klass",
"file": "(stdin)", "file": "(stdin)",
"line": 5, "line": 7,
"inherits": "foo::bar", "inherits": "foo::bar",
"docstring": { "docstring": {
"text": "A simple class.", "text": "A simple class.",
"tags": [ "tags": [
{
"tag_name": "todo",
"text": "Do a thing"
},
{
"tag_name": "note",
"text": "Some note"
},
{ {
"tag_name": "param", "tag_name": "param",
"text": "First param.", "text": "First param.",
@ -44,7 +52,7 @@
{ {
"name": "dt", "name": "dt",
"file": "(stdin)", "file": "(stdin)",
"line": 12, "line": 14,
"docstring": { "docstring": {
"text": "A simple defined type.", "text": "A simple defined type.",
"tags": [ "tags": [

View File

@ -3,11 +3,19 @@
{ {
"name": "klass", "name": "klass",
"file": "(stdin)", "file": "(stdin)",
"line": 5, "line": 7,
"inherits": "foo::bar", "inherits": "foo::bar",
"docstring": { "docstring": {
"text": "A simple class.", "text": "A simple class.",
"tags": [ "tags": [
{
"tag_name": "todo",
"text": "Do a thing"
},
{
"tag_name": "note",
"text": "Some note"
},
{ {
"tag_name": "param", "tag_name": "param",
"text": "First param.", "text": "First param.",
@ -44,7 +52,7 @@
{ {
"name": "dt", "name": "dt",
"file": "(stdin)", "file": "(stdin)",
"line": 12, "line": 14,
"docstring": { "docstring": {
"text": "A simple defined type.", "text": "A simple defined type.",
"tags": [ "tags": [

View File

@ -8,6 +8,14 @@
"docstring": { "docstring": {
"text": "A simple class.", "text": "A simple class.",
"tags": [ "tags": [
{
"tag_name": "todo",
"text": "Do a thing"
},
{
"tag_name": "note",
"text": "Some note"
},
{ {
"tag_name": "param", "tag_name": "param",
"text": "First param.", "text": "First param.",

View File

@ -39,6 +39,10 @@ _Private Classes_
An overview for a simple class. An overview for a simple class.
* **TODO** Do something.
* **Note** Some note.
* **Since** 1.0.0 * **Since** 1.0.0
* **See also** * **See also**

View File

@ -43,6 +43,10 @@ _Private Classes_
An overview for a simple class. An overview for a simple class.
* **TODO** Do a thing
* **Note** some note
* **Since** 1.0.0 * **Since** 1.0.0
* **See also** * **See also**

View File

@ -7,6 +7,8 @@ describe PuppetStrings::Json do
# Populate the YARD registry with both Puppet and Ruby source # Populate the YARD registry with both Puppet and Ruby source
YARD::Parser::SourceParser.parse_string(<<-SOURCE, :puppet) YARD::Parser::SourceParser.parse_string(<<-SOURCE, :puppet)
# A simple class. # A simple class.
# @todo Do a thing
# @note Some note
# @param param1 First param. # @param param1 First param.
# @param param2 Second param. # @param param2 Second param.
# @param param3 Third param. # @param param3 Third param.

View File

@ -9,6 +9,8 @@ describe PuppetStrings::Markdown do
YARD::Parser::SourceParser.parse_string(<<-SOURCE, :puppet) YARD::Parser::SourceParser.parse_string(<<-SOURCE, :puppet)
# An overview for a simple class. # An overview for a simple class.
# @summary A simple class. # @summary A simple class.
# @todo Do a thing
# @note some note
# @since 1.0.0 # @since 1.0.0
# @see www.puppet.com # @see www.puppet.com
# @example This is an example # @example This is an example