Skip to content

Commit 176d6d4

Browse files
committed
(PDOC-184) refactoring because naming is hard
1 parent 8a34dc7 commit 176d6d4

15 files changed

Lines changed: 43 additions & 43 deletions

File tree

lib/puppet-strings/markdown.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
# module for parsing Yard Registries and generating markdown
44
module PuppetStrings::Markdown
55
require_relative 'markdown/puppet_classes'
6-
require_relative 'markdown/puppet_functions'
7-
require_relative 'markdown/puppet_defined_types'
8-
require_relative 'markdown/puppet_resource_types'
6+
require_relative 'markdown/functions'
7+
require_relative 'markdown/defined_types'
8+
require_relative 'markdown/custom_types'
99
require_relative 'markdown/table_of_contents'
1010

1111
# generates markdown documentation
@@ -14,9 +14,9 @@ def self.generate
1414
final = "# Reference\n\n"
1515
final << PuppetStrings::Markdown::TableOfContents.render
1616
final << PuppetStrings::Markdown::PuppetClasses.render
17-
final << PuppetStrings::Markdown::PuppetDefinedTypes.render
18-
final << PuppetStrings::Markdown::PuppetResourceTypes.render
19-
final << PuppetStrings::Markdown::PuppetFunctions.render
17+
final << PuppetStrings::Markdown::DefinedTypes.render
18+
final << PuppetStrings::Markdown::CustomTypes.render
19+
final << PuppetStrings::Markdown::Functions.render
2020

2121
final
2222
end

lib/puppet-strings/markdown/base.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ def initialize(registry, component_type)
5757
# e.g. {:tag_name=>"author", :text=>"eputnam"}
5858
{ :return_val => 'return',
5959
:since => 'since',
60-
:summary => 'summary',
61-
:option => 'option' }.each do |method_name, tag_name|
60+
:summary => 'summary' }.each do |method_name, tag_name|
6261
define_method method_name do
6362
@tags.select { |tag| tag[:tag_name] == "#{tag_name}" }[0][:text] unless @tags.select { |tag| tag[:tag_name] == "#{tag_name}" }[0].nil?
6463
end
@@ -99,15 +98,19 @@ def examples
9998
@tags.select { |tag| tag[:tag_name] == 'example' } unless @tags.select { |tag| tag[:tag_name] == 'example' }[0].nil?
10099
end
101100

102-
# @return [Array] example tag hashes
101+
# @return [Array] raise tag hashes
103102
def raises
104103
@tags.select { |tag| tag[:tag_name] == 'raise' } unless @tags.select { |tag| tag[:tag_name] == 'raise' }[0].nil?
105104
end
106105

106+
# @return [Array] option tag hashes
107107
def options
108108
@tags.select { |tag| tag[:tag_name] == 'option' } unless @tags.select { |tag| tag[:tag_name] == 'option' }[0].nil?
109109
end
110110

111+
# @param parameter_name
112+
# parameter name to match to option tags
113+
# @return [Array] option tag hashes that have a parent parameter_name
111114
def options_for_param(parameter_name)
112115
opts_for_p = options.select { |o| o[:parent] == parameter_name } unless options.nil?
113116
opts_for_p unless opts_for_p.nil? || opts_for_p.length.zero?

lib/puppet-strings/markdown/puppet_resource_type.rb renamed to lib/puppet-strings/markdown/custom_type.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
require 'puppet-strings/markdown/base'
22

33
module PuppetStrings::Markdown
4-
class PuppetResourceType < Base
4+
class CustomType < Base
55
def initialize(registry)
6-
@template = 'puppet_resource_type.erb'
7-
super(registry, 'resource type')
6+
@template = 'custom_type.erb'
7+
super(registry, 'type')
88
end
99

1010
def render

lib/puppet-strings/markdown/puppet_resource_types.rb renamed to lib/puppet-strings/markdown/custom_types.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
require_relative 'puppet_resource_type'
1+
require_relative 'custom_type'
22

33
module PuppetStrings::Markdown
4-
module PuppetResourceTypes
4+
module CustomTypes
55

66
# @return [Array] list of resource types
77
def self.in_rtypes
@@ -11,7 +11,7 @@ def self.in_rtypes
1111
def self.render
1212
final = in_rtypes.length > 0 ? "## Resource types\n\n" : ""
1313
in_rtypes.each do |type|
14-
final << PuppetStrings::Markdown::PuppetResourceType.new(type).render
14+
final << PuppetStrings::Markdown::CustomType.new(type).render
1515
end
1616
final
1717
end
@@ -20,7 +20,7 @@ def self.toc_info
2020
final = []
2121

2222
in_rtypes.each do |type|
23-
final.push(PuppetStrings::Markdown::PuppetResourceType.new(type).toc_info)
23+
final.push(PuppetStrings::Markdown::CustomType.new(type).toc_info)
2424
end
2525

2626
final

lib/puppet-strings/markdown/puppet_defined_type.rb renamed to lib/puppet-strings/markdown/defined_type.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
require 'puppet-strings/markdown/base'
22

33
module PuppetStrings::Markdown
4-
class PuppetDefinedType < Base
4+
class DefinedType < Base
55
def initialize(registry)
6-
@template = 'puppet_resource.erb'
6+
@template = 'classes_and_defines.erb'
77
super(registry, 'defined type')
88
end
99

lib/puppet-strings/markdown/puppet_defined_types.rb renamed to lib/puppet-strings/markdown/defined_types.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
require_relative 'puppet_defined_type'
1+
require_relative 'defined_type'
22

33
module PuppetStrings::Markdown
4-
module PuppetDefinedTypes
4+
module DefinedTypes
55

66
# @return [Array] list of defined types
77
def self.in_dtypes
@@ -11,7 +11,7 @@ def self.in_dtypes
1111
def self.render
1212
final = in_dtypes.length > 0 ? "## Defined types\n\n" : ""
1313
in_dtypes.each do |type|
14-
final << PuppetStrings::Markdown::PuppetDefinedType.new(type).render
14+
final << PuppetStrings::Markdown::DefinedType.new(type).render
1515
end
1616
final
1717
end
@@ -20,7 +20,7 @@ def self.toc_info
2020
final = []
2121

2222
in_dtypes.each do |type|
23-
final.push(PuppetStrings::Markdown::PuppetDefinedType.new(type).toc_info)
23+
final.push(PuppetStrings::Markdown::DefinedType.new(type).toc_info)
2424
end
2525

2626
final

lib/puppet-strings/markdown/puppet_function.rb renamed to lib/puppet-strings/markdown/function.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
require 'puppet-strings/markdown/base'
22

33
module PuppetStrings::Markdown
4-
class PuppetFunction < Base
4+
class Function < Base
55
attr_reader :signatures
66

77
def initialize(registry)
8-
@template = 'puppet_function.erb'
8+
@template = 'function.erb'
99
super(registry, 'function')
1010
@signatures = []
1111
registry[:signatures].each do |sig|
@@ -39,7 +39,7 @@ def error_text(r)
3939
end
4040
end
4141

42-
class PuppetFunction::Signature < Base
42+
class Function::Signature < Base
4343
def initialize(registry)
4444
@registry = registry
4545
super(@registry, 'function signature')

lib/puppet-strings/markdown/puppet_functions.rb renamed to lib/puppet-strings/markdown/functions.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
require_relative 'puppet_function'
1+
require_relative 'function'
22

33
module PuppetStrings::Markdown
4-
module PuppetFunctions
4+
module Functions
55

66
# @return [Array] list of functions
77
def self.in_functions
@@ -11,7 +11,7 @@ def self.in_functions
1111
def self.render
1212
final = in_functions.length > 0 ? "## Functions\n\n" : ""
1313
in_functions.each do |func|
14-
final << PuppetStrings::Markdown::PuppetFunction.new(func).render
14+
final << PuppetStrings::Markdown::Function.new(func).render
1515
end
1616
final
1717
end
@@ -20,7 +20,7 @@ def self.toc_info
2020
final = []
2121

2222
in_functions.each do |func|
23-
final.push(PuppetStrings::Markdown::PuppetFunction.new(func).toc_info)
23+
final.push(PuppetStrings::Markdown::Function.new(func).toc_info)
2424
end
2525

2626
final

lib/puppet-strings/markdown/puppet_class.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
module PuppetStrings::Markdown
44
class PuppetClass < Base
55
def initialize(registry)
6-
@template = 'puppet_resource.erb'
6+
@template = 'classes_and_defines.erb'
77
super(registry, 'class')
88
end
99

lib/puppet-strings/markdown/table_of_contents.rb

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
require 'puppet-strings/markdown/puppet_classes'
2-
31
module PuppetStrings::Markdown
42
module TableOfContents
53
def self.render
64
puppet_classes = PuppetStrings::Markdown::PuppetClasses.toc_info
7-
puppet_defined_types = PuppetStrings::Markdown::PuppetDefinedTypes.toc_info
8-
puppet_resource_types = PuppetStrings::Markdown::PuppetResourceTypes.toc_info
9-
puppet_functions = PuppetStrings::Markdown::PuppetFunctions.toc_info
5+
puppet_defined_types = PuppetStrings::Markdown::DefinedTypes.toc_info
6+
puppet_resource_types = PuppetStrings::Markdown::CustomTypes.toc_info
7+
puppet_functions = PuppetStrings::Markdown::Functions.toc_info
108

119
template = File.join(File.dirname(__FILE__),"templates/table_of_contents.erb")
1210
ERB.new(File.read(template), nil, '-').result(binding)

0 commit comments

Comments
 (0)