Forum: Ruby on Rails Documentation for the plugins you use

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Jeff Hoffman (Guest)
on 2006-05-18 21:21
I wanted a concise way to see the rdocs for all the plugins I use in my
project.  I threw together a quick program to generate it for me, and I
thought you guys might be interested.  It creates a plugins.html in your
application's root directory, with links to rdoc that it generates in
each plugin's own directory.  I just added a frame to the rdoc-generated
index.html in my own project and pointed it to this plugins.html.

I put this script in my application's scripts directory and invoke it
with:

ruby script/document_plugins

Regards,

Jeff


document_plugins.rb:
--------------------

require 'rdoc/rdoc'

dir = Dir.new("vendor/plugins")
outfile = File.new("plugins.html", "w")
file_start=<<'FILESTART'
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitiona...
<!--
    Plugins
  -->
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Plugins</title>
  <meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />
  <link rel="stylesheet" href="doc/rdoc/rdoc-style.css" type="text/css"
/>
  <base target="docwin" />
</head>
<body>
  <div id="index">
    <h1 class="section-bar">Plugins</h1>
    <div id="index-entries">
FILESTART

outfile.write(file_start)

Dir.glob("vendor/plugins/*").each do |relPath|
  plugin = File.split(relPath).last
  puts relPath + ", " + plugin
  outfile.write("      <a href=\"#{relPath}/doc/rdoc/index.html\"
target=\"_plugins\">#{plugin}</a><br/>\n");

  origDir = Dir.pwd
  begin
    Dir.chdir(relPath)
    r = RDoc::RDoc.new
    r.document ["--op","doc/rdoc", "-S", "--main", "README"] +
Dir.glob("*")

    rescue RDoc::RDocError => e
      $stderr.puts e.message
    ensure
      Dir.chdir origDir
    end

  end

  file_end=<<'FILEEND'
    </div>
  </div>
</body>
</html>
FILEEND

outfile.write(file_end)

----------------------------
 end of document_plugins.rb
----------------------------



index.html (add to project's root directory)
--------------------------------------------

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
     PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dt...
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>RDoc Documentation</title>
  <meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />
</head>
<frameset cols="20%,*">
    <frameset rows="25%,25%,25%,25%">
        <frame src="doc/rdoc/fr_file_index.html"   title="Files"
name="Files" />
        <frame src="doc/rdoc/fr_class_index.html"  name="Classes" />
        <frame src="doc/rdoc/fr_method_index.html" name="Methods" />
        <frame src="plugins.html" name="Plugins" />
    </frameset>
      <frame  src="doc/rdoc/files/README.html" name="docwin">
    <noframes>
          <body bgcolor="white">
            Click <a href="html/index.html">here</a> for a non-frames
            version of this page.
          </body>
    </noframes>
</frameset>
</html>
This topic is locked and can not be replied to.