Skip to content

Commit

Permalink
(PDOC-192) remove warning for title/name
Browse files Browse the repository at this point in the history
Currently, if a user attempts to document the title or name params, Strings will throw a warning saying that these parameters are missing from the class/type. Of course, they aren't, they just may not be explicit. This removes the warning if the param name is 'name' or 'title'.
  • Loading branch information
eputnam committed Mar 22, 2018
1 parent 67f249c commit c56ee78
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
2 changes: 1 addition & 1 deletion lib/puppet-strings/yard/handlers/puppet/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def set_parameter_types(object)
tags = object.tags(:param)
tags.each do |tag|
next if statement.parameters.find { |p| tag.name == p.name }
log.warn "The @param tag for parameter '#{tag.name}' has no matching parameter at #{statement.file}:#{statement.line}."
log.warn "The @param tag for parameter '#{tag.name}' has no matching parameter at #{statement.file}:#{statement.line}." unless tag.name == 'name' || tag.name == 'title'
end

# Assign the types for the parameter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
describe 'parsing a defined type with a docstring' do
let(:source) { <<-SOURCE
# A simple foo defined type.
# @param name The type name.
# @param param1 First param.
# @param param2 Second param.
# @param param3 Third param.
Expand All @@ -45,6 +46,9 @@
}
SOURCE
}
it 'does not output a warning for title/name' do
expect{ subject }.not_to output(/\[warn\].*(name|title).*/).to_stdout_from_any_process
end

it 'should register a defined type object' do
expect(subject.size).to eq(1)
Expand All @@ -55,18 +59,21 @@
expect(object.statement).not_to eq(nil)
expect(object.parameters).to eq([['param1', nil], ['param2', nil], ['param3', 'hi']])
expect(object.docstring).to eq('A simple foo defined type.')
expect(object.docstring.tags.size).to eq(4)
expect(object.docstring.tags.size).to eq(5)
tags = object.docstring.tags(:param)
expect(tags.size).to eq(3)
expect(tags[0].name).to eq('param1')
expect(tags[0].text).to eq('First param.')
expect(tags[0].types).to eq(['Integer'])
expect(tags[1].name).to eq('param2')
expect(tags[1].text).to eq('Second param.')
expect(tags[1].types).to eq(['Any'])
expect(tags[2].name).to eq('param3')
expect(tags[2].text).to eq('Third param.')
expect(tags[2].types).to eq(['String'])
expect(tags.size).to eq(4)
expect(tags[0].name).to eq('name')
expect(tags[0].text).to eq('The type name.')
expect(tags[0].types).to eq(nil)
expect(tags[1].name).to eq('param1')
expect(tags[1].text).to eq('First param.')
expect(tags[1].types).to eq(['Integer'])
expect(tags[2].name).to eq('param2')
expect(tags[2].text).to eq('Second param.')
expect(tags[2].types).to eq(['Any'])
expect(tags[3].name).to eq('param3')
expect(tags[3].text).to eq('Third param.')
expect(tags[3].types).to eq(['String'])
tags = object.docstring.tags(:api)
expect(tags.size).to eq(1)
expect(tags[0].text).to eq('public')
Expand Down

0 comments on commit c56ee78

Please sign in to comment.