Skip to content
Browse files

a ruby script to replicate docco without the cruft

  • Loading branch information...
1 parent fc9a7a0 commit 144460aae3af98affcc5fc63954f380f0d0cdb86 Eric Redmond committed Jul 9, 2012
Showing with 1,292 additions and 1,097 deletions.
  1. +1,236 −1,097 docs/dynamo.html
  2. +56 −0 dr_rockzo.rb
View
2,333 docs/dynamo.html
1,236 additions, 1,097 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
56 dr_rockzo.rb
@@ -0,0 +1,56 @@
+# this file does cocaine
+
+comment_block, document = false, []
+File.open('dynamo.js').each do |line|
+ line.strip!
+ comment_line = line =~ /^\/\//
+ line = line.sub(/^\/\//, '').strip
+ document << {:comments => [], :doc => []} if comment_line && !comment_block
+ if comment_block = comment_line
+ document.last[:comments] << line
+ else
+ document.last[:doc] << ((line.length == 0 && document.last[:doc].length > 0) ? '</p><p>' : line)
+ end
+end
+
+File.open('docs/dynamo.html', 'w+') do |f|
+ f.write <<-HTML
+ <!DOCTYPE html>
+ <html>
+ <head>
+ <title>Dynamo</title>
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8">
+ <link rel="stylesheet" media="all" href="docco.css" />
+ </head>
+ <body>
+ <div id="container">
+ <div id="background"></div>
+ <table cellpadding="0" cellspacing="0">
+ <thead>
+ <tr>
+ <th class="docs">
+ <h1>dynamo.js</h1>
+ </th>
+ <th class="code"></th>
+ </tr>
+ </thead>
+ <tbody>
+ HTML
+ document.each_with_index do |rows, index|
+ f.write "<tr id=\"section-#{index}\">"
+ f.write "<td class=\"docs\">"
+ f.write "<div class=\"pilwrap\"><a class=\"pilcrow\" href=\"#section-#{index}\">&#182;</a></div>"
+ f.write "<p>#{rows[:comments].join("\n")}</p>"
+ f.write "</td>"
+ f.write "<td class=\"code\">"
+ f.write "<p>#{rows[:doc].join("\n")}</p>"
+ f.write "</td>"
+ end
+ f.write <<-HTML
+ </tbody>
+ </table>
+ </div>
+ </body>
+ </html>
+ HTML
+end

0 comments on commit 144460a

Please sign in to comment.
Something went wrong with that request. Please try again.