Feature #11990

PuppetDoc should use also README.rdoc files

Added by Alessandro Franceschi 4 months ago. Updated 7 days ago.

Status:Duplicate Start date:01/17/2012
Priority:Normal Due date:
Assignee:Brice Figureau % Done:

0%

Category:documentation
Target version:3.0.0
Affected Puppet version:2.7.9 Branch:
Keywords:puppetdoc rdoc
Votes: 2

Description

This is a feature request for which there’s already a solution. Hope you will review and eventually accept it.

PuppetDoc uses the file README in a module to generate the main page of a module’s documentation. If this file is in rdoc format it renders it nicely. At the same time many modules are published on GitHub, where README files are rendered as rdoc if they are named README.rdoc

The request is to make puppetdoc renders files called README.rdoc ad module documentation if they are found on the module, otherwise it falls back to the standard README.

I already asked Brice an help about this and he replied, in very few minutes with this:

Here is a patch that should quite do what you need:

diff --git a/lib/puppet/util/rdoc/parser.rb b/lib/puppet/util/rdoc/parser.rb
index a8996ee..5fa3246 100644
--- a/lib/puppet/util/rdoc/parser.rb
+++ b/lib/puppet/util/rdoc/parser.rb
@@ -129,8 +129,10 @@ class Parser
  def scan_top_level(container)
    # use the module README as documentation for the module
    comment = ""
-    readme = File.join(File.dirname(File.dirname(@input_file_name)), "README")
-    comment = File.open(readme,"r") { |f| f.read } if FileTest.readable?(readme)
+    %w{README README.rdoc}.each do |rfile|
+      readme = File.join(File.dirname(File.dirname(@input_file_name)), rfile)
+      comment = File.open(readme,"r") { |f| f.read } if FileTest.readable?(readme)
+    end
    look_for_directives_in(container, comment) unless comment.empty?

    # infer module name from directory

It is fully untested :) It should prefer a README.rdoc over a README if both are present.


I’ve tested this patch on Puppet 2.7.9 and it seems to work as expected: – modules with a README are rendered well – modules with a README.rdoc are rendered well – modules with both render README.rdoc

puppetdoc.patch (811 Bytes) Alessandro Franceschi, 01/17/2012 02:08 pm


Related issues

duplicates Puppet - Feature #11801: puppet doc should be able to use README.rdoc in toplevel ... Merged - Pending Release 01/06/2012

History

Updated by Alessandro Franceschi 4 months ago

I attach the patch in a more readable format… sorry for the mess

Updated by Brice Figureau 4 months ago

Alessandro Franceschi wrote:

I attach the patch in a more readable format… sorry for the mess

I will produce a better patch (ie with spec coverage) soon.

Updated by Daniel Pittman 4 months ago

  • Description updated (diff)

Brice Figureau wrote:

Alessandro Franceschi wrote:

I attach the patch in a more readable format… sorry for the mess

I will produce a better patch (ie with spec coverage) soon.

Awesome. We are also going to need a CLA signed by Alessandro, and ideally the code as a pull request. Alessandro, can you sign the CLA?

Updated by Alessandro Franceschi 4 months ago

No problem in signing a CLA, but the attached patch was done by Brice, so suppose is not necessary.

Updated by Daniel Pittman 4 months ago

Alessandro Franceschi wrote:

No problem in signing a CLA, but the attached patch was done by Brice, so suppose is not necessary.

Oh. I thought you wrote it. Indeed, Bryce has signed the CLA, so we don’t need one from you. Thanks. :)

Updated by Dominic Cleal 4 months ago

  • Category set to documentation
  • Status changed from Unreviewed to Accepted
  • Assignee set to Brice Figureau
  • Target version set to 3.X
  • Affected Puppet version set to 2.7.9
  • Keywords changed from puppetdoc to puppetdoc rdoc

Updated by Dominic Cleal 4 months ago

  • Status changed from Accepted to Duplicate

Looks like we also have #11801 which has an associated pull request, closing this one.

Updated by Brice Figureau 4 months ago

Dominic Cleal wrote:

Looks like we also have #11801 which has an associated pull request, closing this one.

Too bad I just pushed mine without first looking this bug status :( Feel free to remove it then.

Updated by Daniel Pittman 7 days ago

  • Target version changed from 3.X to 3.0.0

Also available in: Atom PDF