Note: I pushed 2 branches, one for 0.25.x and one for master because it
touches code that diverged between 0.25.x and master, but the fix is the
same (except master has some tests).
On 04/11/09 20:28, Brice Figureau wrote:
> class klass {
> include a, b, c
> }
>
> wasn't producing any rdoc documentation.
> We were thinking code was always embedded in an array which is not
> the case for mono-instruction code.
>
> Signed-off-by: Brice Figureau<[email protected]>
> ---
> lib/puppet/util/rdoc/parser.rb | 3 +++
> spec/unit/util/rdoc/parser.rb | 18 ++++++++++++++++++
> 2 files changed, 21 insertions(+), 0 deletions(-)
>
> diff --git a/lib/puppet/util/rdoc/parser.rb b/lib/puppet/util/rdoc/parser.rb
> index aa34335..d7e1c30 100644
> --- a/lib/puppet/util/rdoc/parser.rb
> +++ b/lib/puppet/util/rdoc/parser.rb
> @@ -148,6 +148,7 @@ class Parser
> # create documentation for include statements we can find in +code+
> # and associate it with +container+
> def scan_for_include_or_require(container, code)
> + code = [code] unless code.is_a?(Array)
> code.each do |stmt|
> scan_for_include_or_require(container,stmt.children) if
> stmt.is_a?(Puppet::Parser::AST::ASTArray)
>
> @@ -163,6 +164,7 @@ class Parser
> # create documentation for global variables assignements we can find in
> +code+
> # and associate it with +container+
> def scan_for_vardef(container, code)
> + code = [code] unless code.is_a?(Array)
> code.each do |stmt|
> scan_for_vardef(container,stmt.children) if
> stmt.is_a?(Puppet::Parser::AST::ASTArray)
>
> @@ -176,6 +178,7 @@ class Parser
> # create documentation for resources we can find in +code+
> # and associate it with +container+
> def scan_for_resource(container, code)
> + code = [code] unless code.is_a?(Array)
> code.each do |stmt|
> scan_for_resource(container,stmt.children) if
> stmt.is_a?(Puppet::Parser::AST::ASTArray)
>
> diff --git a/spec/unit/util/rdoc/parser.rb b/spec/unit/util/rdoc/parser.rb
> index b05df6d..de11832 100755
> --- a/spec/unit/util/rdoc/parser.rb
> +++ b/spec/unit/util/rdoc/parser.rb
> @@ -321,6 +321,12 @@ describe RDoc::Parser do
>
> @code.stubs(:is_a?).with(Puppet::Parser::AST::ASTArray).returns(true)
> end
>
> + it "should also scan mono-instruction code" do
> + @class.expects(:add_include).with { |i| i.is_a?(RDoc::Include)
> and i.name == "myclass" and i.comment == "mydoc" }
> +
> +
> @parser.scan_for_include_or_require(@class,create_stmt("include"))
> + end
> +
> it "should register recursively includes to the current container"
> do
> @code.stubs(:children).returns([ create_stmt("include") ])
>
> @@ -354,6 +360,12 @@ describe RDoc::Parser do
> @class.expects(:add_constant).with { |i|
> i.is_a?(RDoc::Constant) and i.name == "myvar" and i.comment == "mydoc" }
> @parser.scan_for_vardef(@class, [ @code ])
> end
> +
> + it "should also scan mono-instruction code" do
> + @class.expects(:add_constant).with { |i| i.is_a?(RDoc::Constant)
> and i.name == "myvar" and i.comment == "mydoc" }
> +
> + @parser.scan_for_vardef(@class, @stmt)
> + end
> end
>
> describe "when scanning for resources" do
> @@ -375,6 +387,12 @@ describe RDoc::Parser do
> @class.expects(:add_resource).with { |i|
> i.is_a?(RDoc::PuppetResource) and i.title == "myfile" and i.comment ==
> "mydoc" }
> @parser.scan_for_resource(@class, [ @code ])
> end
> +
> + it "should also scan mono-instruction code" do
> + @class.expects(:add_resource).with { |i|
> i.is_a?(RDoc::PuppetResource) and i.title == "myfile" and i.comment ==
> "mydoc" }
> +
> + @parser.scan_for_resource(@class, @stmt)
> + end
> end
>
> describe "when parsing plugins" do
--
Brice Figureau
My Blog: http://www.masterzen.fr/
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---