Skip to content

Commit eadda6b

Browse files
committed
Add deprecated tag
I had a stab at adding the deprecated flag Fixes #339
1 parent 2b8f2c6 commit eadda6b

File tree

24 files changed

+89
-9
lines changed

24 files changed

+89
-9
lines changed

Gemfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ group :development do
2020
gem 'json_spec', '~> 1.1', '>= 1.1.5'
2121

2222
gem 'mdl', '~> 0.11.0'
23-
gem 'mocha'
2423

2524
gem 'pry', require: false
2625
gem 'pry-byebug', require: false
2726
gem 'pry-stack_explorer', require: false
27+
# Need the following otherwise we end up with puppetlabs_spec_helper 1.1.1
28+
gem 'mocha', '~> 1.0'
2829
gem 'puppetlabs_spec_helper'
2930

3031
gem 'rake'

lib/puppet-strings/markdown/base.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ module PuppetStrings::Markdown
2020
# [{:tag_name=>"summary", :text=>"A simple class."},
2121
# {:tag_name=>"since", :text=>"1.0.0"},
2222
# {:tag_name=>"see", :name=>"www.puppet.com"},
23+
# {:tag_name=>"deprecated", :text=>"Use a something else"},
2324
# {:tag_name=>"example",
2425
# :text=>
2526
# "class { 'klass':\n" +
@@ -93,7 +94,8 @@ def initialize(registry, component_type)
9394
since: 'since',
9495
summary: 'summary',
9596
note: 'note',
96-
todo: 'todo' }.each do |method_name, tag_name|
97+
todo: 'todo',
98+
deprecated: 'deprecated' }.each do |method_name, tag_name|
9799
# @return [String] unless the tag is nil or the string.empty?
98100
define_method method_name do
99101
@tags.find { |tag| tag[:tag_name] == tag_name && !tag[:text].empty? }[:text] if @tags.any? { |tag| tag[:tag_name] == tag_name && !tag[:text].empty? }

lib/puppet-strings/markdown/templates/classes_and_defines.erb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
<%= "The #{name} class." %>
99
<% end -%>
1010

11+
<% if deprecated -%>
12+
* **DEPRECATED** <%= deprecated %>
13+
14+
<% end -%>
1115
<% if todo -%>
1216
* **TODO** <%= todo %>
1317

lib/puppet-strings/markdown/templates/data_type.erb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
<%= "The #{name} data type." %>
99
<% end -%>
1010

11+
<% if deprecated -%>
12+
* **DEPRECATED** <%= deprecated %>
13+
14+
<% end -%>
1115
<% if todo -%>
1216
* **TODO** <%= todo %>
1317

lib/puppet-strings/markdown/templates/function.erb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ Type: <%= type %>
1111
<% else -%>
1212
<%= "The #{name} function." %>
1313

14+
<% end -%>
15+
<% if deprecated -%>
16+
* **DEPRECATED** <%= deprecated %>
17+
1418
<% end -%>
1519
<% if todo -%>
1620
* **TODO** <%= todo %>

lib/puppet-strings/markdown/templates/resource_type.erb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
<%= "The #{name} type." %>
99
<% end -%>
1010

11+
<% if deprecated -%>
12+
* **DEPRECATED** <%= deprecated %>
13+
14+
<% end -%>
1115
<% if todo -%>
1216
* **TODO** <%= todo %>
1317

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<% object.tags(:deprecated).each do |tag| %>
2+
<div class="note deprecated">
3+
<strong>DEPRECATED:</strong>
4+
<%= htmlify_line deprecated.text %>
5+
</div>
6+
<% end %>

lib/puppet-strings/yard/templates/default/puppet_class/html/setup.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Initializes the template.
22
# @return [void]
33
def init
4-
sections :header, :box_info, :summary, :overview, :note, :todo, T('tags'), :source
4+
sections :header, :box_info, :summary, :overview, :note, :todo, :deprecated, T('tags'), :source
55
end
66

77
# Renders the box_info section.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<% object.tags(:deprecated).each do |tag| %>
2+
<div class="note deprecated">
3+
<strong>DEPRECATED:</strong>
4+
<%= htmlify_line deprecated.text %>
5+
</div>
6+
<% end %>

lib/puppet-strings/yard/templates/default/puppet_data_type/html/setup.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Initializes the template.
22
# @return [void]
33
def init
4-
sections :header, :box_info, :summary, :overview, :note, :todo, T('tags'), :method_details_list, [T('method_details')], :source
4+
sections :header, :box_info, :summary, :overview, :note, :todo, :deprecated, T('tags'), :method_details_list, [T('method_details')], :source
55
end
66

77
def method_listing
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<% object.tags(:deprecated).each do |tag| %>
2+
<div class="note deprecated">
3+
<strong>DEPRECATED:</strong>
4+
<%= htmlify_line deprecated.text %>
5+
</div>
6+
<% end %>

lib/puppet-strings/yard/templates/default/puppet_data_type_alias/html/setup.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Initializes the template.
22
# @return [void]
33
def init
4-
sections :header, :box_info, :summary, :overview, :alias_of, :note, :todo, T('tags'), :source
4+
sections :header, :box_info, :summary, :overview, :alias_of, :note, :todo, :deprecated, T('tags'), :source
55
end
66

77
# Renders the alias_of section.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<% object.tags(:deprecated).each do |tag| %>
2+
<div class="note deprecated">
3+
<strong>DEPRECATED:</strong>
4+
<%= htmlify_line deprecated.text %>
5+
</div>
6+
<% end %>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Initializes the template.
22
# @return [void]
33
def init
4-
sections :header, :box_info, :summary, :overview, :note, :todo, T('tags'), :source
4+
sections :header, :box_info, :summary, :overview, :note, :todo, :deprecated, T('tags'), :source
55
end
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<% object.tags(:deprecated).each do |tag| %>
2+
<div class="note deprecated">
3+
<strong>DEPRECATED:</strong>
4+
<%= htmlify_line deprecated.text %>
5+
</div>
6+
<% end %>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Initializes the template.
22
# @return [void]
33
def init
4-
sections :header, :box_info, :summary, :overview, [:note, :todo, T('tags'), :source]
4+
sections :header, :box_info, :summary, :overview, [:note, :todo, :deprecated, T('tags'), :source]
55
end
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<% object.tags(:deprecated).each do |tag| %>
2+
<div class="note deprecated">
3+
<strong>DEPRECATED:</strong>
4+
<%= htmlify_line deprecated.text %>
5+
</div>
6+
<% end %>

lib/puppet-strings/yard/templates/default/puppet_plan/html/setup.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Initializes the template.
22
# @return [void]
33
def init
4-
sections :header, :box_info, :summary, :overview, :note, :todo, T('tags'), :source
4+
sections :header, :box_info, :summary, :overview, :note, :todo, :deprecated, T('tags'), :source
55
end
66

77
# Renders the box_info section.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<% object.tags(:deprecated).each do |tag| %>
2+
<div class="note deprecated">
3+
<strong>DEPRECATED:</strong>
4+
<%= htmlify_line deprecated.text %>
5+
</div>
6+
<% end %>

lib/puppet-strings/yard/templates/default/puppet_type/html/setup.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Initializes the template.
22
# @return [void]
33
def init
4-
sections :header, :box_info, :summary, :overview, :note, :todo, T('tags'), :properties, :parameters, :features
4+
sections :header, :box_info, :summary, :overview, :note, :todo, :deprecated, T('tags'), :properties, :parameters, :features
55
end
66

77
# Renders the box_info section.

spec/fixtures/puppet/class.pp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# An overview for a simple class.
22
# @summary A simple class.
33
# @todo Do a thing
4+
# @deprecated Use a something else
45
# @note some note
56
# @since 1.0.0
67
# @see www.puppet.com

spec/unit/puppet-strings/json_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
expect(YARD::Parser::SourceParser.parse_string(<<~'SOURCE', :puppet).enumerator.length).to eq(2)
1111
# A simple class.
1212
# @todo Do a thing
13+
# @deprecated Use a something else
1314
# @note Some note
1415
# @param param1 First param.
1516
# @param param2 Second param.

spec/unit/puppet-strings/markdown/base_spec.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
# An overview
1010
# @api private
1111
# @summary A simple class.
12+
# @deprecated Use a something else
1213
# @param param1 First param.
1314
# @param param2 Second param.
1415
# @param param3 Third param.
@@ -56,6 +57,12 @@ class klass(Integer $param1, $param2, String $param3 = hi) inherits foo::bar {
5657
end
5758
end
5859

60+
describe '#deprecated' do
61+
it 'returns the expected deprecated warning' do
62+
expect(component.deprecated).to eq 'Use a something else'
63+
end
64+
end
65+
5966
describe '#toc_info' do
6067
let(:toc) { component.toc_info }
6168

spec/unit/puppet-strings/markdown_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,12 @@ def parse_data_type_content
9191
end
9292
end
9393

94+
describe 'deprecated message' do
95+
it 'includes deprecated message' do
96+
expect(output).to match(%r{\*\*DEPRECATED\*\* Use a something else})
97+
end
98+
end
99+
94100
describe 'with Puppet Plans', if: TEST_PUPPET_PLANS do
95101
before(:each) do
96102
parse_plan_content
@@ -154,6 +160,10 @@ def parse_data_type_content
154160
it 'includes return value' do
155161
expect(output).to match(%r{returns: `optional\[string\]`}i)
156162
end
163+
164+
it 'includes return value' do
165+
expect(output).to match(%r{returns: `optional\[string\]`}i)
166+
end
157167
end
158168
end
159169
end

0 commit comments

Comments
 (0)