diff --git a/lib/puppet-strings/markdown/base.rb b/lib/puppet-strings/markdown/base.rb index c35202b..bb20f14 100644 --- a/lib/puppet-strings/markdown/base.rb +++ b/lib/puppet-strings/markdown/base.rb @@ -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? diff --git a/lib/puppet-strings/markdown/templates/classes_and_defines.erb b/lib/puppet-strings/markdown/templates/classes_and_defines.erb index cc8c76e..ceaaf93 100644 --- a/lib/puppet-strings/markdown/templates/classes_and_defines.erb +++ b/lib/puppet-strings/markdown/templates/classes_and_defines.erb @@ -8,6 +8,14 @@ <%= "The #{name} class." %> <% end -%> +<% if todo -%> +* **TODO** <%= todo %> + +<% end -%> +<% if note -%> +* **Note** <%= note %> + +<% end -%> <% if since -%> * **Since** <%= since %> diff --git a/lib/puppet-strings/markdown/templates/function.erb b/lib/puppet-strings/markdown/templates/function.erb index 2d96066..7cfce0b 100644 --- a/lib/puppet-strings/markdown/templates/function.erb +++ b/lib/puppet-strings/markdown/templates/function.erb @@ -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 %> diff --git a/lib/puppet-strings/markdown/templates/resource_type.erb b/lib/puppet-strings/markdown/templates/resource_type.erb index 9c9a045..9913fe3 100644 --- a/lib/puppet-strings/markdown/templates/resource_type.erb +++ b/lib/puppet-strings/markdown/templates/resource_type.erb @@ -8,6 +8,14 @@ <%= "The #{name} type." %> <% end -%> +<% if todo -%> +* **TODO** <%= todo %> + +<% end -%> +<% if note -%> +* **Note** <%= note %> + +<% end -%> <% if since -%> * **Since** <%= since %> diff --git a/lib/puppet-strings/yard/templates/default/puppet_class/html/note.erb b/lib/puppet-strings/yard/templates/default/puppet_class/html/note.erb new file mode 100755 index 0000000..88c9ffb --- /dev/null +++ b/lib/puppet-strings/yard/templates/default/puppet_class/html/note.erb @@ -0,0 +1,6 @@ +<% object.tags(:note).each do |tag| %> +
+ Note: + <%= htmlify_line tag.text %> +
+<% end %> diff --git a/lib/puppet-strings/yard/templates/default/puppet_class/html/setup.rb b/lib/puppet-strings/yard/templates/default/puppet_class/html/setup.rb index 36255d3..76e2af9 100644 --- a/lib/puppet-strings/yard/templates/default/puppet_class/html/setup.rb +++ b/lib/puppet-strings/yard/templates/default/puppet_class/html/setup.rb @@ -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. diff --git a/lib/puppet-strings/yard/templates/default/puppet_class/html/todo.erb b/lib/puppet-strings/yard/templates/default/puppet_class/html/todo.erb new file mode 100755 index 0000000..8f91636 --- /dev/null +++ b/lib/puppet-strings/yard/templates/default/puppet_class/html/todo.erb @@ -0,0 +1,6 @@ +<% object.tags(:todo).each do |tag| %> +
+ TODO: + <%= htmlify_line tag.text %> +
+<% end %> diff --git a/lib/puppet-strings/yard/templates/default/puppet_defined_type/html/note.erb b/lib/puppet-strings/yard/templates/default/puppet_defined_type/html/note.erb new file mode 100755 index 0000000..88c9ffb --- /dev/null +++ b/lib/puppet-strings/yard/templates/default/puppet_defined_type/html/note.erb @@ -0,0 +1,6 @@ +<% object.tags(:note).each do |tag| %> +
+ Note: + <%= htmlify_line tag.text %> +
+<% end %> diff --git a/lib/puppet-strings/yard/templates/default/puppet_defined_type/html/setup.rb b/lib/puppet-strings/yard/templates/default/puppet_defined_type/html/setup.rb index aa5fe0e..d3dbefb 100644 --- a/lib/puppet-strings/yard/templates/default/puppet_defined_type/html/setup.rb +++ b/lib/puppet-strings/yard/templates/default/puppet_defined_type/html/setup.rb @@ -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 diff --git a/lib/puppet-strings/yard/templates/default/puppet_defined_type/html/todo.erb b/lib/puppet-strings/yard/templates/default/puppet_defined_type/html/todo.erb new file mode 100755 index 0000000..8f91636 --- /dev/null +++ b/lib/puppet-strings/yard/templates/default/puppet_defined_type/html/todo.erb @@ -0,0 +1,6 @@ +<% object.tags(:todo).each do |tag| %> +
+ TODO: + <%= htmlify_line tag.text %> +
+<% end %> diff --git a/lib/puppet-strings/yard/templates/default/puppet_function/html/note.erb b/lib/puppet-strings/yard/templates/default/puppet_function/html/note.erb new file mode 100755 index 0000000..88c9ffb --- /dev/null +++ b/lib/puppet-strings/yard/templates/default/puppet_function/html/note.erb @@ -0,0 +1,6 @@ +<% object.tags(:note).each do |tag| %> +
+ Note: + <%= htmlify_line tag.text %> +
+<% end %> diff --git a/lib/puppet-strings/yard/templates/default/puppet_function/html/setup.rb b/lib/puppet-strings/yard/templates/default/puppet_function/html/setup.rb index c2c36b3..b75f87f 100644 --- a/lib/puppet-strings/yard/templates/default/puppet_function/html/setup.rb +++ b/lib/puppet-strings/yard/templates/default/puppet_function/html/setup.rb @@ -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 diff --git a/lib/puppet-strings/yard/templates/default/puppet_function/html/todo.erb b/lib/puppet-strings/yard/templates/default/puppet_function/html/todo.erb new file mode 100755 index 0000000..8f91636 --- /dev/null +++ b/lib/puppet-strings/yard/templates/default/puppet_function/html/todo.erb @@ -0,0 +1,6 @@ +<% object.tags(:todo).each do |tag| %> +
+ TODO: + <%= htmlify_line tag.text %> +
+<% end %> diff --git a/lib/puppet-strings/yard/templates/default/puppet_plan/html/note.erb b/lib/puppet-strings/yard/templates/default/puppet_plan/html/note.erb new file mode 100755 index 0000000..88c9ffb --- /dev/null +++ b/lib/puppet-strings/yard/templates/default/puppet_plan/html/note.erb @@ -0,0 +1,6 @@ +<% object.tags(:note).each do |tag| %> +
+ Note: + <%= htmlify_line tag.text %> +
+<% end %> diff --git a/lib/puppet-strings/yard/templates/default/puppet_plan/html/setup.rb b/lib/puppet-strings/yard/templates/default/puppet_plan/html/setup.rb index 0db700d..3396ee1 100644 --- a/lib/puppet-strings/yard/templates/default/puppet_plan/html/setup.rb +++ b/lib/puppet-strings/yard/templates/default/puppet_plan/html/setup.rb @@ -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. diff --git a/lib/puppet-strings/yard/templates/default/puppet_plan/html/todo.erb b/lib/puppet-strings/yard/templates/default/puppet_plan/html/todo.erb new file mode 100755 index 0000000..8f91636 --- /dev/null +++ b/lib/puppet-strings/yard/templates/default/puppet_plan/html/todo.erb @@ -0,0 +1,6 @@ +<% object.tags(:todo).each do |tag| %> +
+ TODO: + <%= htmlify_line tag.text %> +
+<% end %> diff --git a/lib/puppet-strings/yard/templates/default/puppet_type/html/note.erb b/lib/puppet-strings/yard/templates/default/puppet_type/html/note.erb new file mode 100755 index 0000000..88c9ffb --- /dev/null +++ b/lib/puppet-strings/yard/templates/default/puppet_type/html/note.erb @@ -0,0 +1,6 @@ +<% object.tags(:note).each do |tag| %> +
+ Note: + <%= htmlify_line tag.text %> +
+<% end %> diff --git a/lib/puppet-strings/yard/templates/default/puppet_type/html/setup.rb b/lib/puppet-strings/yard/templates/default/puppet_type/html/setup.rb index 6b2e8ac..a74e1b0 100644 --- a/lib/puppet-strings/yard/templates/default/puppet_type/html/setup.rb +++ b/lib/puppet-strings/yard/templates/default/puppet_type/html/setup.rb @@ -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. diff --git a/lib/puppet-strings/yard/templates/default/puppet_type/html/todo.erb b/lib/puppet-strings/yard/templates/default/puppet_type/html/todo.erb new file mode 100755 index 0000000..8f91636 --- /dev/null +++ b/lib/puppet-strings/yard/templates/default/puppet_type/html/todo.erb @@ -0,0 +1,6 @@ +<% object.tags(:todo).each do |tag| %> +
+ TODO: + <%= htmlify_line tag.text %> +
+<% end %> diff --git a/spec/fixtures/unit/json/output.json b/spec/fixtures/unit/json/output.json index e874489..dad3eef 100644 --- a/spec/fixtures/unit/json/output.json +++ b/spec/fixtures/unit/json/output.json @@ -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": [ diff --git a/spec/fixtures/unit/json/output_with_plan.json b/spec/fixtures/unit/json/output_with_plan.json index dbff7f1..7c88ac9 100644 --- a/spec/fixtures/unit/json/output_with_plan.json +++ b/spec/fixtures/unit/json/output_with_plan.json @@ -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": [ diff --git a/spec/fixtures/unit/json/output_without_puppet_function.json b/spec/fixtures/unit/json/output_without_puppet_function.json index b9e38a0..89715f2 100644 --- a/spec/fixtures/unit/json/output_without_puppet_function.json +++ b/spec/fixtures/unit/json/output_without_puppet_function.json @@ -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.", diff --git a/spec/fixtures/unit/markdown/output.md b/spec/fixtures/unit/markdown/output.md index b738f7f..d56447f 100644 --- a/spec/fixtures/unit/markdown/output.md +++ b/spec/fixtures/unit/markdown/output.md @@ -39,6 +39,10 @@ _Private Classes_ An overview for a simple class. +* **TODO** Do something. + +* **Note** Some note. + * **Since** 1.0.0 * **See also** diff --git a/spec/fixtures/unit/markdown/output_with_plan.md b/spec/fixtures/unit/markdown/output_with_plan.md index 33cc774..ef4c16b 100644 --- a/spec/fixtures/unit/markdown/output_with_plan.md +++ b/spec/fixtures/unit/markdown/output_with_plan.md @@ -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** diff --git a/spec/unit/puppet-strings/json_spec.rb b/spec/unit/puppet-strings/json_spec.rb index d9fe243..ae9b33e 100644 --- a/spec/unit/puppet-strings/json_spec.rb +++ b/spec/unit/puppet-strings/json_spec.rb @@ -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. diff --git a/spec/unit/puppet-strings/markdown_spec.rb b/spec/unit/puppet-strings/markdown_spec.rb index c03b202..794ab7a 100644 --- a/spec/unit/puppet-strings/markdown_spec.rb +++ b/spec/unit/puppet-strings/markdown_spec.rb @@ -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