Greetings!
Please review the pull request #117: Ticket/2.7.x/7601 type reference definition lists opened by (nfagerlund)
Some more information about the pull request:
- Opened: Thu Sep 15 01:00:43 UTC 2011
- Based on: puppetlabs:2.7.x (25b4cb689432a658f3ccf8985197c5986605d764)
- Requested merge: nfagerlund:ticket/2.7.x/7601-type_reference_definition_lists (ac7c146cd82dd6de41ab57b9e0cbd4179dfcdc45)
Description:
As part of an issue filed to discuss formatting in the type reference, Thomas
Bellman pointed out that it makes much more semantic sense for a type's
parameters to be expressed as a definition list, as opposed to a series of
elements with paragraphs underneath them. It turns out to be a lot
prettier, too.
This commit:
- Changes the paramwrap function in puppet/util/reference.rb to create definition lists instead of prepending a header
- Changes the puppet/reference/metaparameter.rb to append a header instead of using the paramwrap function, since paramwrap uses code specific to parameters of resource types (namevar checking, etc.)
Thanks!
The Pull Request Bot
Diff follows:
diff --git a/lib/puppet/reference/metaparameter.rb b/lib/puppet/reference/metaparameter.rb
index 3c4c087..dc89004 100644
--- a/lib/puppet/reference/metaparameter.rb
+++ b/lib/puppet/reference/metaparameter.rb
@@ -29,7 +29,9 @@ in your manifest, including defined components.
params.sort { |a,b|
a.to_s <=> b.to_s
}.each { |param|
- str += paramwrap(param.to_s, scrub(Puppet::Type.metaparamdoc(param)), :level => 3)
+ str << h(param.to_s, 3)
+ str << scrub(Puppet::Type.metaparamdoc(param))
+ str << "\n\n"
}
rescue => detail
puts detail.backtrace
diff --git a/lib/puppet/util/reference.rb b/lib/puppet/util/reference.rb
index a4921ed..061bfc5 100644
--- a/lib/puppet/util/reference.rb
+++ b/lib/puppet/util/reference.rb
@@ -85,6 +85,18 @@ class Puppet::Util::Reference
"#{HEADER_LEVELS[level]} #{name}\n\n"
end
+ def dl(term, definition)
+ lines = definition.split("\n")
+ str = "#{term}\n: #{lines.shift}\n"
+ if lines.length > 0
+ lines.each do |line|
+ str += " " if line =~ /\S/
+ str += "#{line}\n"
+ end
+ end
+ str += "\n"
+ end
+
def initialize(name, options = {}, &block)
@name = name
options.each do |option, value|
@@ -110,14 +122,8 @@ class Puppet::Util::Reference
end
def paramwrap(name, text, options = {})
- options[:level] ||= 5
- #str = "#{name} : "
- str = h(name, options[:level])
- str += "- **namevar**\n\n" if options[:namevar]
- str += text
- #str += text.gsub(/\n/, "\n ")
-
- str += "\n\n"
+ text = "(**Namevar:** If omitted, this parameter's value defaults to the resource's title.)\n\n" + text if options[:namevar]
+ dl(name, text)
end
def text
-- You received this message because you are subscribed to the Google Groups "Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected].
For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
