Skip to content
Browse files

Further RST to Markdown fixes for types, values, tests

  • Loading branch information...
1 parent 1157e8d commit 252c9b84f79307e5caa50b50e093ad493993622d @jamtur01 jamtur01 committed Aug 12, 2010
View
28 lib/puppet/application/doc.rb
@@ -56,7 +56,7 @@ def handle_unknown( opt, arg )
end
def run_command
- return[:rdoc, :markdown].include?(options[:mode]) ? send(options[:mode]) : other
+ return[:rdoc].include?(options[:mode]) ? send(options[:mode]) : other
end
def rdoc
@@ -92,32 +92,6 @@ def rdoc
exit exit_code
end
- def markdown
- text = ""
- with_contents = false
- exit_code = 0
- require 'puppet/util/reference'
- options[:references].sort { |a,b| a.to_s <=> b.to_s }.each do |name|
- raise "Could not find reference #{name}" unless section = Puppet::Util::Reference.reference(name)
-
- begin
- # Add the per-section text, but with no ToC
- text += section.send(options[:format], with_contents)
- text += Puppet::Util::Reference.footer
- text.gsub!(/`\w+\s+([^`]+)`:trac:/) { |m| $1 }
- Puppet::Util::Reference.markdown(name, text)
- text = ""
- rescue => detail
- puts detail.backtrace
- $stderr.puts "Could not generate reference #{name}: #{detail}"
- exit_code = 1
- next
- end
- end
-
- exit exit_code
- end
-
def other
text = ""
with_contents = options[:references].length <= 1
View
2 lib/puppet/indirector/facts/memory.rb
@@ -3,7 +3,7 @@
class Puppet::Node::Facts::Memory < Puppet::Indirector::Memory
desc "Keep track of facts in memory but nowhere else. This is used for
- one-time compiles, such as what the stand-alone ``puppet`` does.
+ one-time compiles, such as what the stand-alone `puppet` does.
To use this terminus, you must load it with the data you want it
to contain."
end
View
2 lib/puppet/indirector/node/memory.rb
@@ -3,7 +3,7 @@
class Puppet::Node::Memory < Puppet::Indirector::Memory
desc "Keep track of nodes in memory but nowhere else. This is used for
- one-time compiles, such as what the stand-alone ``puppet`` does.
+ one-time compiles, such as what the stand-alone `puppet` does.
To use this terminus, you must load it with the data you want it
to contain; it is only useful for developers and should generally not
be chosen by a normal user."
View
6 lib/puppet/parameter/value_collection.rb
@@ -21,14 +21,14 @@ def doc
@doc += " Valid values are "
@doc += @strings.collect do |value|
if aliases = value.aliases and ! aliases.empty?
- "``#{value.name}`` (also called ``#{aliases.join(", ")}``)"
+ "`#{value.name}` (also called `#{aliases.join(", ")}`)"
else
- "``#{value.name}``"
+ "`#{value.name}`"
end
end.join(", ") + "."
end
- @doc += " Values can match ``" + regexes.join("``, ``") + "``." unless regexes.empty?
+ @doc += " Values can match `" + regexes.join("`, `") + "`." unless regexes.empty?
end
@doc
View
10 lib/puppet/property.rb
@@ -55,10 +55,10 @@ def self.value_option(name, option)
# * <tt>:required_features</tt>: A list of features this value requires.
# * <tt>:event</tt>: The event that should be returned when this value is set.
# * <tt>:call</tt>: When to call any associated block. The default value
- # is ``instead``, which means to call the value instead of calling the
- # provider. You can also specify ``before`` or ``after``, which will
+ # is `instead`, which means to call the value instead of calling the
+ # provider. You can also specify `before` or `after`, which will
# call both the block and the provider, according to the order you specify
- # (the ``first`` refers to when the block is called, not the provider).
+ # (the `first` refers to when the block is called, not the provider).
def self.newvalue(name, options = {}, &block)
value = value_collection.newvalue(name, options, &block)
@@ -181,10 +181,10 @@ def is_to_s(currentvalue)
def log(msg)
Puppet::Util::Log.create(
-
+
:level => resource[:loglevel],
:message => msg,
-
+
:source => self
)
end
View
6 lib/puppet/provider.rb
@@ -205,23 +205,23 @@ def self.supports_parameter?(param)
dochook(:defaults) do
if @defaults.length > 0
return " Default for " + @defaults.collect do |f, v|
- "``#{f}`` == ``#{v}``"
+ "`#{f}` == `#{v}`"
end.join(" and ") + "."
end
end
dochook(:commands) do
if @commands.length > 0
return " Required binaries: " + @commands.collect do |n, c|
- "``#{c}``"
+ "`#{c}`"
end.join(", ") + "."
end
end
dochook(:features) do
if features.length > 0
return " Supported features: " + features.collect do |f|
- "``#{f}``"
+ "`#{f}`"
end.join(", ") + "."
end
end
View
4 lib/puppet/reference/providers.rb
@@ -95,7 +95,7 @@
ret += h(type.name.to_s + "_", 2)
- ret += ".. _#{type.name}: #{"http://docs.puppetlabs.com/references/stable/type.html##{type.name}"}\n\n"
+ ret += "[#{type.name}](#{"http://docs.puppetlabs.com/references/stable/type.html##{type.name}"})\n\n"
ret += option("Default provider", default)
ret += doctable(headers, table_data)
@@ -111,7 +111,7 @@
ret
end
providers.header = "
-Puppet resource types are usually backed by multiple implementations called ``providers``,
+Puppet resource types are usually backed by multiple implementations called `providers`,
which handle variance between platforms and tools.
Different providers are suitable or unsuitable on different platforms based on things
View
170 lib/puppet/type.rb
@@ -933,16 +933,16 @@ def pathbuilder
newmetaparam(:schedule) do
desc "On what schedule the object should be managed. You must create a
schedule object, and then reference the name of that object to use
- that for your schedule::
+ that for your schedule:
- schedule { daily:
- period => daily,
- range => \"2-4\"
- }
+ schedule { daily:
+ period => daily,
+ range => \"2-4\"
+ }
- exec { \"/usr/bin/apt-get update\":
- schedule => daily
- }
+ exec { \"/usr/bin/apt-get update\":
+ schedule => daily
+ }
The creation of the schedule object does not need to appear in the
configuration before objects that use it."
@@ -1020,40 +1020,40 @@ def properties_to_audit(list)
newmetaparam(:alias) do
desc "Creates an alias for the object. Puppet uses this internally when you
- provide a symbolic name::
-
- file { sshdconfig:
- path => $operatingsystem ? {
- solaris => \"/usr/local/etc/ssh/sshd_config\",
- default => \"/etc/ssh/sshd_config\"
- },
- source => \"...\"
- }
+ provide a symbolic name:
+
+ file { sshdconfig:
+ path => $operatingsystem ? {
+ solaris => \"/usr/local/etc/ssh/sshd_config\",
+ default => \"/etc/ssh/sshd_config\"
+ },
+ source => \"...\"
+ }
- service { sshd:
- subscribe => file[sshdconfig]
- }
+ service { sshd:
+ subscribe => file[sshdconfig]
+ }
- When you use this feature, the parser sets ``sshdconfig`` as the name,
+ When you use this feature, the parser sets `sshdconfig` as the name,
and the library sets that as an alias for the file so the dependency
- lookup for ``sshd`` works. You can use this parameter yourself,
+ lookup for `sshd` works. You can use this parameter yourself,
but note that only the library can use these aliases; for instance,
- the following code will not work::
+ the following code will not work:
- file { \"/etc/ssh/sshd_config\":
- owner => root,
- group => root,
- alias => sshdconfig
- }
+ file { \"/etc/ssh/sshd_config\":
+ owner => root,
+ group => root,
+ alias => sshdconfig
+ }
- file { sshdconfig:
- mode => 644
- }
+ file { sshdconfig:
+ mode => 644
+ }
There's no way here for the Puppet parser to know that these two stanzas
should be affecting the same file.
- See the `LanguageTutorial language tutorial`:trac: for more information.
+ See the [Language Tutorial](http://docs.puppetlabs.com/guides/language_tutorial.html) for more information.
"
@@ -1083,9 +1083,9 @@ def properties_to_audit(list)
be useful to add your own tags to a given resource.
Tags are currently useful for things like applying a subset of a
- host's configuration::
+ host's configuration:
- puppet agent --test --tags mytag
+ puppet agent --test --tags mytag
This way, when you're testing a configuration you can run just the
portion you're testing."
@@ -1189,23 +1189,23 @@ def self.relationship_params
newmetaparam(:require, :parent => RelationshipMetaparam, :attributes => {:direction => :in, :events => :NONE}) do
desc "One or more objects that this object depends on.
This is used purely for guaranteeing that changes to required objects
- happen before the dependent object. For instance::
+ happen before the dependent object. For instance:
- # Create the destination directory before you copy things down
- file { \"/usr/local/scripts\":
- ensure => directory
- }
+ # Create the destination directory before you copy things down
+ file { \"/usr/local/scripts\":
+ ensure => directory
+ }
- file { \"/usr/local/scripts/myscript\":
- source => \"puppet://server/module/myscript\",
- mode => 755,
- require => File[\"/usr/local/scripts\"]
- }
+ file { \"/usr/local/scripts/myscript\":
+ source => \"puppet://server/module/myscript\",
+ mode => 755,
+ require => File[\"/usr/local/scripts\"]
+ }
Multiple dependencies can be specified by providing a comma-seperated list
- of resources, enclosed in square brackets::
+ of resources, enclosed in square brackets:
- require => [ File[\"/usr/local\"], File[\"/usr/local/scripts\"] ]
+ require => [ File[\"/usr/local\"], File[\"/usr/local/scripts\"] ]
Note that Puppet will autorequire everything that it can, and
there are hooks in place so that it's easy for resources to add new
@@ -1219,67 +1219,67 @@ def self.relationship_params
Currently, exec resources will autorequire their CWD (if it is
specified) plus any fully qualified paths that appear in the
- command. For instance, if you had an ``exec`` command that ran
- the ``myscript`` mentioned above, the above code that pulls the
+ command. For instance, if you had an `exec` command that ran
+ the `myscript` mentioned above, the above code that pulls the
file down would be automatically listed as a requirement to the
- ``exec`` code, so that you would always be running againts the
+ `exec` code, so that you would always be running againts the
most recent version.
"
end
newmetaparam(:subscribe, :parent => RelationshipMetaparam, :attributes => {:direction => :in, :events => :ALL_EVENTS, :callback => :refresh}) do
desc "One or more objects that this object depends on. Changes in the
subscribed to objects result in the dependent objects being
- refreshed (e.g., a service will get restarted). For instance::
-
- class nagios {
- file { \"/etc/nagios/nagios.conf\":
- source => \"puppet://server/module/nagios.conf\",
- alias => nagconf # just to make things easier for me
+ refreshed (e.g., a service will get restarted). For instance:
+
+ class nagios {
+ file { \"/etc/nagios/nagios.conf\":
+ source => \"puppet://server/module/nagios.conf\",
+ alias => nagconf # just to make things easier for me
+ }
+ service { nagios:
+ ensure => running,
+ subscribe => File[nagconf]
+ }
}
- service { nagios:
- ensure => running,
- subscribe => File[nagconf]
- }
- }
- Currently the ``exec``, ``mount`` and ``service`` type support
+ Currently the `exec`, `mount` and `service` type support
refreshing.
"
end
newmetaparam(:before, :parent => RelationshipMetaparam, :attributes => {:direction => :out, :events => :NONE}) do
desc %{This parameter is the opposite of **require** -- it guarantees
that the specified object is applied later than the specifying
- object::
+ object:
- file { "/var/nagios/configuration":
- source => "...",
- recurse => true,
- before => Exec["nagios-rebuid"]
- }
+ file { "/var/nagios/configuration":
+ source => "...",
+ recurse => true,
+ before => Exec["nagios-rebuid"]
+ }
- exec { "nagios-rebuild":
- command => "/usr/bin/make",
- cwd => "/var/nagios/configuration"
- }
+ exec { "nagios-rebuild":
+ command => "/usr/bin/make",
+ cwd => "/var/nagios/configuration"
+ }
This will make sure all of the files are up to date before the
make command is run.}
end
newmetaparam(:notify, :parent => RelationshipMetaparam, :attributes => {:direction => :out, :events => :ALL_EVENTS, :callback => :refresh}) do
desc %{This parameter is the opposite of **subscribe** -- it sends events
- to the specified object::
+ to the specified object:
- file { "/etc/sshd_config":
- source => "....",
- notify => Service[sshd]
- }
+ file { "/etc/sshd_config":
+ source => "....",
+ notify => Service[sshd]
+ }
- service { sshd:
- ensure => running
- }
+ service { sshd:
+ ensure => running
+ }
This will restart the sshd service if the sshd config file changes.}
end
@@ -1293,24 +1293,24 @@ class nagios {
By default, all classes get directly added to the
'main' stage. You can create new stages as resources:
- stage { [pre, post]: }
+ stage { [pre, post]: }
To order stages, use standard relationships:
- stage { pre: before => Stage[main] }
+ stage { pre: before => Stage[main] }
Or use the new relationship syntax:
- Stage[pre] -> Stage[main] -> Stage[post]
+ Stage[pre] -> Stage[main] -> Stage[post]
Then use the new class parameters to specify a stage:
- class { foo: stage => pre }
+ class { foo: stage => pre }
Stages can only be set on classes, not individual resources. This will
- fail::
+ fail:
- file { '/foo': stage => pre, ensure => file }
+ file { '/foo': stage => pre, ensure => file }
}
end
View
12 lib/puppet/type/zone.rb
@@ -320,14 +320,14 @@ def should
timezone=GMT
terminal=xterms
security_policy=NONE
- root_password=&lt;%= password %>
+ root_password=<%= password %>
timeserver=localhost
- name_service=DNS {domain_name=&lt;%= domain %> name_server=&lt;%= nameserver %>}
- network_interface=primary {hostname=&lt;%= realhostname %>
- ip_address=&lt;%= ip %>
- netmask=&lt;%= netmask %>
+ name_service=DNS {domain_name=<%= domain %> name_server=<%= nameserver %>}
+ network_interface=primary {hostname=<%= realhostname %>
+ ip_address=<%= ip %>
+ netmask=<%= netmask %>
protocol_ipv6=no
- default_route=&lt;%= defaultroute %>}
+ default_route=<%= defaultroute %>}
nfs4_domain=dynamic
And then call that:
View
8 lib/puppet/type/zpool.rb
@@ -45,9 +45,9 @@ def insync?(is)
newproperty(:mirror, :array_matching => :all, :parent => Puppet::Property::MultiVDev) do
desc "List of all the devices to mirror for this pool. Each mirror should be a space separated string:
-
+
mirror => [\"disk1 disk2\", \"disk3 disk4\"]
-
+
"
validate do |value|
@@ -57,8 +57,8 @@ def insync?(is)
newproperty(:raidz, :array_matching => :all, :parent => Puppet::Property::MultiVDev) do
desc "List of all the devices to raid for this pool. Should be an array of space separated strings:
-
- raidz => [\"disk1 disk2\", \"disk3 disk4\"]
+
+ raidz => [\"disk1 disk2\", \"disk3 disk4\"]
"
View
10 lib/puppet/util/command_line/puppetdoc
@@ -8,15 +8,15 @@
#
# = Usage
#
-# puppet doc [-a|--all] [-h|--help] [-o|--outputdir <rdoc outputdir>] [-m|--mode <text|pdf|markdown|trac|rdoc>]
+# puppet doc [-a|--all] [-h|--help] [-o|--outputdir <rdoc outputdir>] [-m|--mode <text|pdf|rdoc>]
# [-r|--reference <[type]|configuration|..>] [--charset CHARSET] [manifest-file]
#
# = Description
#
-# If mode is not 'rdoc', then this command generates a restructured-text document describing all installed
+# If mode is not 'rdoc', then this command generates a Markdown document describing all installed
# Puppet types or all allowable arguments to puppet executables. It is largely
# meant for internal use and is used to generate the reference document
-# available on the Reductive Labs web site.
+# available on the Puppet Labs web site.
#
# In 'rdoc' mode, this command generates an html RDoc hierarchy describing the manifests that
# are in 'manifestdir' and 'modulepath' configuration directives.
@@ -37,7 +37,7 @@
# Specifies the directory where to output the rdoc documentation in 'rdoc' mode.
#
# mode::
-# Determine the output mode. Valid modes are 'text', 'trac', 'pdf', 'markdown' and 'rdoc'. The 'pdf' and 'markdown' modes create PDF or Markdown formatted files in the /tmp directory. Note that 'trac' mode only works on Reductive Labs servers. The default mode is 'text'. In 'rdoc' mode you must provide 'manifests-path'
+# Determine the output mode. Valid modes are 'text', 'trac', 'pdf' and 'rdoc'. The 'pdf' mode creates PDF formatted files in the /tmp directory. The default mode is 'text'. In 'rdoc' mode you must provide 'manifests-path'
#
# reference::
# Build a particular reference. Get a list of references by running +puppet doc --list+.
@@ -53,7 +53,7 @@
# or
# $ puppet doc /etc/puppet/manifests/site.pp
# or
-# $ puppet doc -m markdown -r configuration
+# $ puppet doc -m pdf -r configuration
#
# = Author
#
View
26 lib/puppet/util/command_line/ralsh
@@ -59,23 +59,23 @@
# types:
# List all available types.
#
-# verbose::
+# verbose:
# Print extra information.
#
# = Example
#
-# This example uses ``puppet resource`` to return Puppet configuration for the user ``luke``::
-#
-# $ puppet resource user luke
-# user { 'luke':
-# home => '/home/luke',
-# uid => '100',
-# ensure => 'present',
-# comment => 'Luke Kanies,,,',
-# gid => '1000',
-# shell => '/bin/bash',
-# groups => ['sysadmin','audio','video','puppet']
-# }
+# This example uses `puppet resource` to return Puppet configuration for the user `luke`:
+#
+# $ puppet resource user luke
+# user { 'luke':
+# home => '/home/luke',
+# uid => '100',
+# ensure => 'present',
+# comment => 'Luke Kanies,,,',
+# gid => '1000',
+# shell => '/bin/bash',
+# groups => ['sysadmin','audio','video','puppet']
+# }
#
# = Author
#
View
1 lib/puppet/util/docs.rb
@@ -105,4 +105,3 @@ def scrub(text)
module_function :scrub
end
-
View
28 lib/puppet/util/reference.rb
@@ -15,7 +15,7 @@ def self.footer
end
def self.modes
- %w{pdf text markdown}
+ %w{pdf text}
end
def self.newreference(name, options = {}, &block)
@@ -67,32 +67,6 @@ def self.pdf(text)
end
- def self.markdown(name, text)
- puts "Creating markdown for #{name} reference."
- dir = "/tmp/#{Puppet::PUPPETVERSION}"
- FileUtils.mkdir(dir) unless File.directory?(dir)
- Puppet::Util.secure_open(dir + "/#{name}.rst", "w") do |f|
- f.puts text
- end
- pandoc = %x{which pandoc}
- if $CHILD_STATUS != 0 or pandoc =~ /no /
- pandoc = %x{which pandoc}
- end
- if $CHILD_STATUS != 0 or pandoc =~ /no /
- raise "Could not find pandoc"
- end
- pandoc.chomp!
- cmd = %{#{pandoc} -s -r rst -w markdown #{dir}/#{name}.rst -o #{dir}/#{name}.mdwn}
- output = %x{#{cmd}}
- unless $CHILD_STATUS == 0
- $stderr.puts "Pandoc failed to create #{name} reference."
- $stderr.puts output
- exit(1)
- end
-
- File.unlink(dir + "/#{name}.rst")
- end
-
def self.references
instance_loader(:reference).loadall
loaded_instances(:reference).sort { |a,b| a.to_s <=> b.to_s }
View
4 spec/unit/parameter/value_collection_spec.rb
@@ -68,12 +68,12 @@
it "should correctly generate documentation for values" do
@collection.newvalues :foo
- @collection.doc.should be_include("Valid values are ``foo``")
+ @collection.doc.should be_include("Valid values are `foo`")
end
it "should correctly generate documentation for regexes" do
@collection.newvalues %r{\w+}
- @collection.doc.should be_include("Values can match ``/\\w+/``")
+ @collection.doc.should be_include("Values can match `/\\w+/`")
end
it "should be able to find the first matching value" do

0 comments on commit 252c9b8

Please sign in to comment.
Something went wrong with that request. Please try again.