Merge pull request #182 from eputnam/note_and_todo

(PDOC-212, PDOC-213) add support for @note and @todo
This commit is contained in:
David Schmitt 2018-06-25 12:30:42 +01:00 committed by GitHub
commit 0b255edd4f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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"}
{ :return_val => 'return',
: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
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?

View File

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

View File

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

View File

@ -8,6 +8,14 @@
<%= "The #{name} type." %>
<% end -%>
<% if todo -%>
* **TODO** <%= todo %>
<% end -%>
<% if note -%>
* **Note** <%= note %>
<% end -%>
<% if 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.
# @return [void]
def init
sections :header, :box_info, :summary, :overview, T('tags'), :source
sections :header, :box_info, :summary, :overview, :note, :todo, T('tags'), :source
end
# 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.
# @return [void]
def init
sections :header, :box_info, :summary, :overview, T('tags'), :source
sections :header, :box_info, :summary, :overview, :note, :todo, T('tags'), :source
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.
# @return [void]
def init
sections :header, :box_info, :summary, :overview, [T('tags'), :source]
sections :header, :box_info, :summary, :overview, :note, :todo, [T('tags'), :source]
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.
# @return [void]
def init
sections :header, :box_info, :summary, :overview, T('tags'), :source
sections :header, :box_info, :summary, :overview, :note, :todo, T('tags'), :source
end
# 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.
# @return [void]
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
# 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",
"file": "(stdin)",
"line": 5,
"line": 7,
"inherits": "foo::bar",
"docstring": {
"text": "A simple class.",
"tags": [
{
"tag_name": "todo",
"text": "Do a thing"
},
{
"tag_name": "note",
"text": "Some note"
},
{
"tag_name": "param",
"text": "First param.",
@ -44,7 +52,7 @@
{
"name": "dt",
"file": "(stdin)",
"line": 12,
"line": 14,
"docstring": {
"text": "A simple defined type.",
"tags": [

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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