[PATCH/puppet 1/1] Fix #2783, take2 - puppetdoc should use environment to get modulepath/manifestdir

1 view
Skip to first unread message

Brice Figureau

unread,
Nov 21, 2009, 2:47:40 PM11/21/09
to puppe...@googlegroups.com
I was told that setting manifestdir in environment is not supported.
Only the manifest setting seems to be supported in environments.
This patch changes how puppetdoc handles manifestdir, instead
of getting it through the manifestdir variable, we now get the
manifest settings and infer the directory from this, exactly as
the parser is doing.
This allows puppetdoc to handle what user are doing with environments.

Signed-off-by: Brice Figureau <brice-...@daysofwonder.com>
---
lib/puppet/application/puppetdoc.rb | 2 +-
spec/unit/application/puppetdoc.rb | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/puppet/application/puppetdoc.rb b/lib/puppet/application/puppetdoc.rb
index 0a4e0c3..024c784 100644
--- a/lib/puppet/application/puppetdoc.rb
+++ b/lib/puppet/application/puppetdoc.rb
@@ -68,7 +68,7 @@ Puppet::Application.new(:puppetdoc) do
unless @manifest
env = Puppet::Node::Environment.new
files += env.modulepath
- files += env.manifestdir
+ files << env[:manifest].sub(%r{[^/]+$},'').sub(/\/$/, '')
end
files += ARGV
Puppet.info "scanning: %s" % files.inspect
diff --git a/spec/unit/application/puppetdoc.rb b/spec/unit/application/puppetdoc.rb
index cb60581..413fa11 100755
--- a/spec/unit/application/puppetdoc.rb
+++ b/spec/unit/application/puppetdoc.rb
@@ -293,7 +293,7 @@ describe "puppetdoc" do
@env = stub 'env'
Puppet::Node::Environment.stubs(:new).returns(@env)
@env.stubs(:modulepath).returns(['modules'])
- @env.stubs(:manifestdir).returns(['manifests'])
+ @env.stubs(:[]).with(:manifest).returns('manifests/site.pp')
@puppetdoc.options.stubs(:[]).with(:all).returns(false)
@puppetdoc.options.stubs(:[]).with(:outputdir).returns('doc')
Puppet.settings.stubs(:[]=).with(:document_all, false)
@@ -334,9 +334,9 @@ describe "puppetdoc" do

it "should get modulepath and manifestdir values from the environment" do
@env.expects(:modulepath).returns(['envmodules1','envmodules2'])
- @env.expects(:manifestdir).returns(['envmanifests1','envmanifests2'])
+ @env.expects(:[]).with(:manifest).returns('envmanifests/site.pp')

- Puppet::Util::RDoc.expects(:rdoc).with('doc', ['envmodules1','envmodules2','envmanifests1','envmanifests2'])
+ Puppet::Util::RDoc.expects(:rdoc).with('doc', ['envmodules1','envmodules2','envmanifests'])

@puppetdoc.rdoc
end
--
1.6.5.2

Luke Kanies

unread,
Nov 22, 2009, 1:19:43 PM11/22/09
to puppe...@googlegroups.com
On Nov 21, 2009, at 11:47 AM, Brice Figureau wrote:

> I was told that setting manifestdir in environment is not supported.
> Only the manifest setting seems to be supported in environments.
> This patch changes how puppetdoc handles manifestdir, instead
> of getting it through the manifestdir variable, we now get the
> manifest settings and infer the directory from this, exactly as
> the parser is doing.
> This allows puppetdoc to handle what user are doing with environments.
>
> Signed-off-by: Brice Figureau <brice-...@daysofwonder.com>
> ---
> lib/puppet/application/puppetdoc.rb | 2 +-
> spec/unit/application/puppetdoc.rb | 6 +++---
> 2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/lib/puppet/application/puppetdoc.rb b/lib/puppet/
> application/puppetdoc.rb
> index 0a4e0c3..024c784 100644
> --- a/lib/puppet/application/puppetdoc.rb
> +++ b/lib/puppet/application/puppetdoc.rb
> @@ -68,7 +68,7 @@ Puppet::Application.new(:puppetdoc) do
> unless @manifest
> env = Puppet::Node::Environment.new
> files += env.modulepath
> - files += env.manifestdir
> + files << env[:manifest].sub(%r{[^/]+$},'').sub(/\/$/, '')

This can be done more easily with File.dirname(env[:manifest]).

Otherwise, +1
> --
>
> You received this message because you are subscribed to the Google
> Groups "Puppet Developers" group.
> To post to this group, send email to puppe...@googlegroups.com.
> To unsubscribe from this group, send email to puppet-dev+...@googlegroups.com
> .
> For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=
> .
>
>


--
It is odd, but on the infrequent occasions when I have been called upon
in a formal place to play the bongo drums, the introducer never seems
to find it necessary to mention that I also do theoretical physics.
-- Richard Feynman
---------------------------------------------------------------------
Luke Kanies | http://reductivelabs.com | http://madstop.com

Reply all
Reply to author
Forward
0 new messages