Class: Puppet::Util::Reference
Overview
Manage Reference Documentation.
Constant Summary
Constants included from Puppet::Util
ALNUM, ALPHA, AbsolutePathPosix, AbsolutePathWindows, DEFAULT_POSIX_MODE, DEFAULT_WINDOWS_MODE, ESCAPED, HEX, HttpProxy, PUPPET_STACK_INSERTION_FRAME, RESERVED, RFC_3986_URI_REGEX, UNRESERVED, UNSAFE
Constants included from POSIX
POSIX::LOCALE_ENV_VARS, POSIX::USER_ENV_VARS
Constants included from SymbolicFileMode
SymbolicFileMode::SetGIDBit, SymbolicFileMode::SetUIDBit, SymbolicFileMode::StickyBit, SymbolicFileMode::SymbolicMode, SymbolicFileMode::SymbolicSpecialToBit
Constants included from Docs
Instance Attribute Summary collapse
-
#depth ⇒ Object
Returns the value of attribute depth.
- #doc ⇒ Object
-
#dynamic ⇒ Object
Returns the value of attribute dynamic.
-
#header ⇒ Object
Returns the value of attribute header.
-
#page ⇒ Object
Returns the value of attribute page.
-
#title ⇒ Object
Returns the value of attribute title.
Attributes included from Docs
Class Method Summary collapse
- .modes ⇒ Object
- .newreference(name, options = {}, &block) ⇒ Object
- .page(*sections) ⇒ Object
- .references(environment) ⇒ Object
Instance Method Summary collapse
- #dynamic? ⇒ Boolean
-
#indent(text, tab) ⇒ Object
Indent every line in the chunk except those which begin with ‘..’.
-
#initialize(name, title: nil, depth: nil, dynamic: nil, doc: nil, &block) ⇒ Reference
constructor
A new instance of Reference.
- #option(name, value) ⇒ Object
- #text ⇒ Object
- #to_markdown(withcontents = true) ⇒ Object
Methods included from InstanceLoader
instance_hash, instance_load, instance_loader, instance_loading?, loaded_instance, loaded_instances
Methods included from Puppet::Util
absolute_path?, benchmark, chuser, clear_environment, create_erb, default_env, deterministic_rand, deterministic_rand_int, exit_on_fail, format_backtrace_array, format_puppetstack_frame, get_env, get_environment, logmethods, merge_environment, path_to_uri, pretty_backtrace, replace_file, resolve_stackframe, rfc2396_escape, safe_posix_fork, set_env, skip_external_facts, symbolizehash, thinmark, uri_encode, uri_query_encode, uri_to_path, uri_unescape, which, withenv, withumask
Methods included from POSIX
#get_posix_field, #gid, groups_of, #idfield, #methodbyid, #methodbyname, #search_posix_field, #uid
Methods included from SymbolicFileMode
#display_mode, #normalize_symbolic_mode, #symbolic_mode_to_int, #valid_symbolic_mode?
Methods included from Docs
#desc, #dochook, #doctable, #markdown_definitionlist, #markdown_header, #nodoc?, #pad, scrub
Constructor Details
#initialize(name, title: nil, depth: nil, dynamic: nil, doc: nil, &block) ⇒ Reference
Returns a new instance of Reference.
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/puppet/util/reference.rb', line 55 def initialize(name, title: nil, depth: nil, dynamic: nil, doc: nil, &block) @name = name @title = title @depth = depth @dynamic = dynamic @doc = doc (:generate, &block) # Now handle the defaults @title ||= _("%{name} Reference") % { name: @name.to_s.capitalize } @page ||= @title.gsub(/\s+/, '') @depth ||= 2 @header ||= "" end |
Instance Attribute Details
#depth ⇒ Object
Returns the value of attribute depth.
40 41 42 |
# File 'lib/puppet/util/reference.rb', line 40 def depth @depth end |
#doc ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/puppet/util/reference.rb', line 43 def doc if defined?(@doc) "#{@name} - #{@doc}" else @title end end |
#dynamic ⇒ Object
Returns the value of attribute dynamic.
40 41 42 |
# File 'lib/puppet/util/reference.rb', line 40 def dynamic @dynamic end |
#header ⇒ Object
Returns the value of attribute header.
40 41 42 |
# File 'lib/puppet/util/reference.rb', line 40 def header @header end |
#page ⇒ Object
Returns the value of attribute page.
40 41 42 |
# File 'lib/puppet/util/reference.rb', line 40 def page @page end |
#title ⇒ Object
Returns the value of attribute title.
40 41 42 |
# File 'lib/puppet/util/reference.rb', line 40 def title @title end |
Class Method Details
.modes ⇒ Object
15 16 17 |
# File 'lib/puppet/util/reference.rb', line 15 def self.modes %w[text] end |
.newreference(name, options = {}, &block) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/puppet/util/reference.rb', line 19 def self.newreference(name, = {}, &block) ref = new(name, **, &block) instance_hash(:reference)[name.intern] = ref ref end |
.page(*sections) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/puppet/util/reference.rb', line 26 def self.page(*sections) depth = 4 # Use the minimum depth sections.each do |name| section = reference(name) or raise _("Could not find section %{name}") % { name: name } depth = section.depth if section.depth < depth end end |
.references(environment) ⇒ Object
35 36 37 38 |
# File 'lib/puppet/util/reference.rb', line 35 def self.references(environment) instance_loader(:reference).loadall(environment) loaded_instances(:reference).sort_by(&:to_s) end |
Instance Method Details
#dynamic? ⇒ Boolean
51 52 53 |
# File 'lib/puppet/util/reference.rb', line 51 def dynamic? dynamic end |
#indent(text, tab) ⇒ Object
Indent every line in the chunk except those which begin with ‘..’.
72 73 74 |
# File 'lib/puppet/util/reference.rb', line 72 def indent(text, tab) text.gsub(/(^|\A)/, tab).gsub(/^ +\.\./, "..") end |
#option(name, value) ⇒ Object
76 77 78 |
# File 'lib/puppet/util/reference.rb', line 76 def option(name, value) ":#{name.to_s.capitalize}: #{value}\n" end |
#text ⇒ Object
80 81 82 |
# File 'lib/puppet/util/reference.rb', line 80 def text puts output end |
#to_markdown(withcontents = true) ⇒ Object
84 85 86 87 88 89 90 91 92 93 |
# File 'lib/puppet/util/reference.rb', line 84 def to_markdown(withcontents = true) # First the header text = markdown_header(@title, 1) text << @header text << generate text end |