summaryrefslogtreecommitdiffstats
path: root/lib/puppet/util/rdoc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/puppet/util/rdoc')
-rw-r--r--lib/puppet/util/rdoc/code_objects.rb39
-rw-r--r--lib/puppet/util/rdoc/generators/puppet_generator.rb18
-rw-r--r--lib/puppet/util/rdoc/parser.rb6
3 files changed, 60 insertions, 3 deletions
diff --git a/lib/puppet/util/rdoc/code_objects.rb b/lib/puppet/util/rdoc/code_objects.rb
index 3854fbc01..3c789a0c5 100644
--- a/lib/puppet/util/rdoc/code_objects.rb
+++ b/lib/puppet/util/rdoc/code_objects.rb
@@ -124,6 +124,45 @@ module RDoc
def add_child(child)
@childs << child
end
+
+ # Look up the given symbol. RDoc only looks for class1::class2.method
+ # or class1::class2#method. Since our definitions are mapped to RDoc methods
+ # but are written class1::class2::define we need to perform the lookup by
+ # ourselves.
+ def find_symbol(symbol, method=nil)
+ result = super
+ if not result and symbol =~ /::/
+ modules = symbol.split(/::/)
+ unless modules.empty?
+ module_name = modules.shift
+ result = find_module_named(module_name)
+ if result
+ last_name = ""
+ previous = nil
+ modules.each do |module_name|
+ previous = result
+ last_name = module_name
+ result = result.find_module_named(module_name)
+ break unless result
+ end
+ unless result
+ result = previous
+ method = last_name
+ end
+ end
+ end
+ if result && method
+ if !result.respond_to?(:find_local_symbol)
+ p result.name
+ p method
+ fail
+ end
+ result = result.find_local_symbol(method)
+ end
+ end
+ result
+ end
+
end
# PuppetNode holds a puppet node
diff --git a/lib/puppet/util/rdoc/generators/puppet_generator.rb b/lib/puppet/util/rdoc/generators/puppet_generator.rb
index e6bbb2e1e..249c9a8ba 100644
--- a/lib/puppet/util/rdoc/generators/puppet_generator.rb
+++ b/lib/puppet/util/rdoc/generators/puppet_generator.rb
@@ -31,6 +31,24 @@ module Generators
NODE_DIR = "nodes"
PLUGIN_DIR = "plugins"
+ # We're monkey patching RDoc markup to allow
+ # lowercase class1::class2::class3 crossref hyperlinking
+ module MarkUp
+ alias :old_markup :markup
+
+ def new_markup(str, remove_para=false)
+ first = @markup.nil?
+ res = old_markup(str, remove_para)
+ if first and not @markup.nil?
+ @markup.add_special(/\b([a-z]\w+(::\w+)*)/,:CROSSREF)
+ # we need to call it again, since we added a rule
+ res = old_markup(str, remove_para)
+ end
+ res
+ end
+ alias :markup :new_markup
+ end
+
# This is a specialized HTMLGenerator tailored to Puppet manifests
class PuppetGenerator < HTMLGenerator
diff --git a/lib/puppet/util/rdoc/parser.rb b/lib/puppet/util/rdoc/parser.rb
index ce34442ab..2b89baace 100644
--- a/lib/puppet/util/rdoc/parser.rb
+++ b/lib/puppet/util/rdoc/parser.rb
@@ -43,9 +43,9 @@ class Parser
@parser.parse.instantiate('').each do |type|
@known_resource_types.add type
end
- scan_top_level(@top_level)
end
end
+ scan_top_level(@top_level)
@top_level
end
@@ -160,8 +160,8 @@ class Parser
if stmt.is_a?(Puppet::Parser::AST::Function) and ['include','require'].include?(stmt.name)
stmt.arguments.each do |included|
- Puppet.debug "found #{stmt.name}: #{included.value}"
- container.send("add_#{stmt.name}",Include.new(included.value, stmt.doc))
+ Puppet.debug "found #{stmt.name}: #{included}"
+ container.send("add_#{stmt.name}",Include.new(included.to_s, stmt.doc))
end
end
end