Skip to content

Commit cee0da1

Browse files
authored
Merge pull request #234 from scotje/maint_spec_cleanups
(MAINT) Fix markdown lint errors and misc testing cleanups
2 parents ae9a323 + afb4095 commit cee0da1

27 files changed

+395
-359
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ Gemfile.lock
3939
/log/
4040
/*.gem
4141
/spec/acceptance/nodesets/
42-
/spec/fixtures/manifests/
4342
/spec/fixtures/modules/
43+
/spec/fixtures/manifests/
4444
/inventory.yaml
4545

4646
## local coverage results

.rubocop.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ AllCops:
77
- 'lib/puppet-strings/yard/templates/**/*'
88
# Ignore fixtures we do not control
99
- spec/fixtures/modules/**/*
10+
- spec/fixtures/ruby/**/*
1011

1112
# DISABLED - not useful
1213
Bundler/OrderedGems:

Rakefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ RSpec::Core::RakeTask.new(:spec) do |t|
4343
t.exclude_pattern = "spec/acceptance/**/*.rb"
4444
end
4545

46+
task :spec => :spec_clean
47+
4648
# Add our own tasks
4749
require 'puppet-strings/tasks'
4850

lib/puppet-strings.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ def self.generate(search_patterns = DEFAULT_SEARCH_PATTERNS, options = {})
2727

2828
# Format the arguments to YARD
2929
args = ['doc']
30+
args << '--no-progress'
3031
args << '--debug' if options[:debug]
31-
args << '--backtrace' if options[:backtrace]
32+
args << '--backtrace' if options[:debug]
3233
args << "-m#{options[:markup] || 'markdown'}"
3334

3435
file = nil
@@ -42,7 +43,6 @@ def self.generate(search_patterns = DEFAULT_SEARCH_PATTERNS, options = {})
4243
args << '-n'
4344
args << '-q' unless file
4445
args << '--no-stats' unless file
45-
args << '--no-progress' unless file
4646
end
4747

4848
yard_args = options[:yard_args]

lib/puppet-strings/markdown.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module PuppetStrings::Markdown
1414
# generates markdown documentation
1515
# @return [String] markdown doc
1616
def self.generate
17-
final = "# Reference\n"
17+
final = "# Reference\n\n"
1818
final << "<!-- DO NOT EDIT: This document was generated by Puppet Strings -->\n\n"
1919
final << PuppetStrings::Markdown::TableOfContents.render
2020
final << PuppetStrings::Markdown::PuppetClasses.render

lib/puppet-strings/markdown/base.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,12 @@ def private?
169169
@tags.any? { |tag| tag[:tag_name] == 'api' && tag[:text] == 'private' }
170170
end
171171

172+
def word_wrap(text, line_width: 120, break_sequence: "\n")
173+
text.split("\n").collect! do |line|
174+
line.length > line_width ? line.gsub(/(.{1,#{line_width}})(\s+|$)/, "\\1#{break_sequence}").strip : line
175+
end * break_sequence
176+
end
177+
172178
# @return [String] full markdown rendering of a component
173179
def render(template)
174180
file = File.join(File.dirname(__FILE__),"templates/#{template}")

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424
* **See also**
2525
<% see.each do |sa| -%>
2626
<% if sa[:name] -%>
27-
<%= sa[:name] %>
27+
<%= " * #{sa[:name]}" %>
2828
<% end -%>
2929
<% if sa[:text] -%>
30-
<%= sa[:text] %>
30+
<%= " * #{sa[:text]}" %>
3131
<% end -%>
3232
<% end -%>
3333

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424
* **See also**
2525
<% see.each do |sa| -%>
2626
<% if sa[:name] -%>
27-
<%= sa[:name] %>
27+
<%= " * #{sa[:name]}" %>
2828
<% end -%>
2929
<% if sa[:text] -%>
30-
<%= sa[:text] %>
30+
<%= " * #{sa[:text]}" %>
3131
<% end -%>
3232
<% end -%>
3333

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ Returns: `<%= sig.return_type %>`<% if sig.return_val %> <%= sig.return_val %><%
5555
<% end -%>
5656
<% if raises -%>
5757
Raises:
58+
5859
<% raises.each do |r| -%>
5960
* <%= error_type(r[:text]) %> <%= error_text(r[:text]) %>
6061
<% end -%>

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424
* **See also**
2525
<% see.each do |sa| -%>
2626
<% if sa[:name] -%>
27-
<%= sa[:name] %>
27+
<%= " * #{sa[:name]}" %>
2828
<% end -%>
2929
<% if sa[:text] -%>
30-
<%= sa[:text] %>
30+
<%= " * #{sa[:text]}" %>
3131
<% end -%>
3232
<% end -%>
3333

@@ -116,7 +116,7 @@ Aliases: <%= param[:aliases].to_s.delete('{').delete('}') %>
116116
Data type: `<%= param[:data_type] %>`<%= "\n_\*this data type contains a regex that may not be accurately reflected in generated documentation_" if regex_in_data_type?(param[:data_type]) %>
117117

118118
<% end -%>
119-
<%= param[:description] %>
119+
<%= word_wrap(param[:description]) %>
120120

121121
<% if options_for_param(param[:name]) -%>
122122
Options:

0 commit comments

Comments
 (0)