Skip to content

Add deprecated tag #342

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ group :development do
gem 'json_spec', '~> 1.1', '>= 1.1.5'

gem 'mdl', '~> 0.11.0'
gem 'mocha'

gem 'pry', require: false
gem 'pry-byebug', require: false
gem 'pry-stack_explorer', require: false
# Need the following otherwise we end up with puppetlabs_spec_helper 1.1.1
gem 'mocha', '~> 1.0'
gem 'puppetlabs_spec_helper'

gem 'rake'
Expand Down
4 changes: 3 additions & 1 deletion lib/puppet-strings/markdown/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ module PuppetStrings::Markdown
# [{:tag_name=>"summary", :text=>"A simple class."},
# {:tag_name=>"since", :text=>"1.0.0"},
# {:tag_name=>"see", :name=>"www.puppet.com"},
# {:tag_name=>"deprecated", :text=>"No longer supported and will be removed in a future release"},
# {:tag_name=>"example",
# :text=>
# "class { 'klass':\n" +
Expand Down Expand Up @@ -93,7 +94,8 @@ def initialize(registry, component_type)
since: 'since',
summary: 'summary',
note: 'note',
todo: 'todo' }.each do |method_name, tag_name|
todo: 'todo',
deprecated: 'deprecated' }.each do |method_name, tag_name|
# @return [String] unless the tag is nil or the string.empty?
define_method method_name do
@tags.find { |tag| tag[:tag_name] == tag_name && !tag[:text].empty? }[:text] if @tags.any? { |tag| tag[:tag_name] == tag_name && !tag[:text].empty? }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
<%= "The #{name} class." %>
<% end -%>

<% if deprecated -%>
* **DEPRECATED** <%= deprecated %>

<% end -%>
<% if todo -%>
* **TODO** <%= todo %>

Expand Down
4 changes: 4 additions & 0 deletions lib/puppet-strings/markdown/templates/data_type.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
<%= "The #{name} data type." %>
<% end -%>

<% if deprecated -%>
* **DEPRECATED** <%= deprecated %>

<% end -%>
<% if todo -%>
* **TODO** <%= todo %>

Expand Down
4 changes: 4 additions & 0 deletions lib/puppet-strings/markdown/templates/function.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ Type: <%= type %>
<% else -%>
<%= "The #{name} function." %>

<% end -%>
<% if deprecated -%>
* **DEPRECATED** <%= deprecated %>

<% end -%>
<% if todo -%>
* **TODO** <%= todo %>
Expand Down
4 changes: 4 additions & 0 deletions lib/puppet-strings/markdown/templates/resource_type.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
<%= "The #{name} type." %>
<% end -%>

<% if deprecated -%>
* **DEPRECATED** <%= deprecated %>

<% end -%>
<% if todo -%>
* **TODO** <%= todo %>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<% object.tags(:deprecated).each do |tag| %>
<div class="note deprecated">
<strong>DEPRECATED:</strong>
<%= htmlify_line deprecated.text %>
</div>
<% end %>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Initializes the template.
# @return [void]
def init
sections :header, :box_info, :summary, :overview, :note, :todo, T('tags'), :source
sections :header, :box_info, :summary, :overview, :note, :todo, :deprecated, T('tags'), :source
end

# Renders the box_info section.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<% object.tags(:deprecated).each do |tag| %>
<div class="note deprecated">
<strong>DEPRECATED:</strong>
<%= htmlify_line deprecated.text %>
</div>
<% end %>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Initializes the template.
# @return [void]
def init
sections :header, :box_info, :summary, :overview, :note, :todo, T('tags'), :method_details_list, [T('method_details')], :source
sections :header, :box_info, :summary, :overview, :note, :todo, :deprecated, T('tags'), :method_details_list, [T('method_details')], :source
end

def method_listing
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<% object.tags(:deprecated).each do |tag| %>
<div class="note deprecated">
<strong>DEPRECATED:</strong>
<%= htmlify_line deprecated.text %>
</div>
<% end %>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Initializes the template.
# @return [void]
def init
sections :header, :box_info, :summary, :overview, :alias_of, :note, :todo, T('tags'), :source
sections :header, :box_info, :summary, :overview, :alias_of, :note, :todo, :deprecated, T('tags'), :source
end

# Renders the alias_of section.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<% object.tags(:deprecated).each do |tag| %>
<div class="note deprecated">
<strong>DEPRECATED:</strong>
<%= htmlify_line deprecated.text %>
</div>
<% end %>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Initializes the template.
# @return [void]
def init
sections :header, :box_info, :summary, :overview, :note, :todo, T('tags'), :source
sections :header, :box_info, :summary, :overview, :note, :todo, :deprecated, T('tags'), :source
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<% object.tags(:deprecated).each do |tag| %>
<div class="note deprecated">
<strong>DEPRECATED:</strong>
<%= htmlify_line deprecated.text %>
</div>
<% end %>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Initializes the template.
# @return [void]
def init
sections :header, :box_info, :summary, :overview, [:note, :todo, T('tags'), :source]
sections :header, :box_info, :summary, :overview, [:note, :todo, :deprecated, T('tags'), :source]
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<% object.tags(:deprecated).each do |tag| %>
<div class="note deprecated">
<strong>DEPRECATED:</strong>
<%= htmlify_line deprecated.text %>
</div>
<% end %>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Initializes the template.
# @return [void]
def init
sections :header, :box_info, :summary, :overview, :note, :todo, T('tags'), :source
sections :header, :box_info, :summary, :overview, :note, :todo, :deprecated, T('tags'), :source
end

# Renders the box_info section.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<% object.tags(:deprecated).each do |tag| %>
<div class="note deprecated">
<strong>DEPRECATED:</strong>
<%= htmlify_line deprecated.text %>
</div>
<% end %>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Initializes the template.
# @return [void]
def init
sections :header, :box_info, :summary, :overview, :note, :todo, T('tags'), :properties, :parameters, :features
sections :header, :box_info, :summary, :overview, :note, :todo, :deprecated, T('tags'), :properties, :parameters, :features
end

# Renders the box_info section.
Expand Down
1 change: 1 addition & 0 deletions spec/fixtures/puppet/class.pp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# An overview for a simple class.
# @summary A simple class.
# @todo Do a thing
# @deprecated No longer supported and will be removed in a future release
# @note some note
# @since 1.0.0
# @see www.puppet.com
Expand Down
1 change: 1 addition & 0 deletions spec/unit/puppet-strings/json_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
expect(YARD::Parser::SourceParser.parse_string(<<~'SOURCE', :puppet).enumerator.length).to eq(2)
# A simple class.
# @todo Do a thing
# @deprecated No longer supported and will be removed in a future release
# @note Some note
# @param param1 First param.
# @param param2 Second param.
Expand Down
7 changes: 7 additions & 0 deletions spec/unit/puppet-strings/markdown/base_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# An overview
# @api private
# @summary A simple class.
# @deprecated No longer supported and will be removed in a future release
# @param param1 First param.
# @param param2 Second param.
# @param param3 Third param.
Expand Down Expand Up @@ -56,6 +57,12 @@ class klass(Integer $param1, $param2, String $param3 = hi) inherits foo::bar {
end
end

describe '#deprecated' do
it 'returns the expected deprecated warning' do
expect(component.deprecated).to eq 'No longer supported and will be removed in a future release'
end
end

describe '#toc_info' do
let(:toc) { component.toc_info }

Expand Down
6 changes: 6 additions & 0 deletions spec/unit/puppet-strings/markdown_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ def parse_data_type_content
end
end

describe 'deprecated message' do
it 'includes deprecated message' do
expect(output).to match(%r{\*\*DEPRECATED\*\* No longer supported and will be removed in a future release})
end
end

describe 'with Puppet Plans', if: TEST_PUPPET_PLANS do
before(:each) do
parse_plan_content
Expand Down