<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -8,29 +8,101 @@ module Prawn
     #   data = [[&quot;Gregory&quot;,&quot;Brown&quot;],[&quot;James&quot;,&quot;Healy&quot;],[&quot;Jia&quot;,&quot;Wu&quot;]]
     #
     #   Prawn::Document.generate(&quot;table.pdf&quot;) do
+    #     
+    #     # Default table, without headers
+    #     table(data)
+    #
+    #     # Default table with headers
     #     table data, :headers =&gt; [&quot;First Name&quot;, &quot;Last Name&quot;]
+    #
+    #     # Very close to PDF::Writer's default SimpleTable output
+    #     table data, :headers            =&gt; [&quot;First Name&quot;, &quot;Last Name&quot;],
+    #                 :font_size          =&gt; 10,
+    #                 :vertical_padding   =&gt; 2,
+    #                 :horizontal_padding =&gt; 5,
+    #                 :position           =&gt; :center,
+    #                 :row_colors         =&gt; :pdf_writer,
+    #
+    #     # Grid border style with explicit column widths.
+    #     table data, :border_style =&gt; :grid,
+    #                 :widths       =&gt; { 0 =&gt; 100, 1 =&gt; 150 }
+    #
     #   end
     #
     def table(data,options={})
       Prawn::Document::Table.new(data,self,options).draw
     end
 
+    # This class implements simple PDF table generation.
+    # 
+    # Prawn tables have the following features:
+    #
+    #   * Can be generated with or without headers
+    #   * Can tweak horizontal and vertical padding of text
+    #   * Minimal styling support (borders / row background colors)
+    #   * Can be positioned by bounding boxes (left/center aligned) or an
+    #     absolute x position
+    #   * Automated page-breaking as needed
+    #   * Column widths can be calculated automatically or defined explictly on a 
+    #     column by column basis
+    #
+    # The current implementation is a bit barebones, but covers most of the
+    # basic needs for PDF table generation.  If you have feature requests,
+    # please share them at: http://groups.google.com/group/prawn-ruby
+    #
+    # Tables will be revisited before the end of the Ruby Mendicant project and
+    # the most commonly needed functionality will likely be added.
+    # 
     class Table
 
       attr_reader :col_widths # :nodoc:
 
+      # Creates a new Document::Table object. This is generally called 
+      # indirectly through Document#table but can also be used explictly.
+      #
+      # The &lt;tt&gt;data&lt;/tt&gt; argument is a two dimensional array of strings,
+      # organized by row, e.g. [[&quot;r1-col1&quot;,&quot;r1-col2&quot;],[&quot;r2-col2&quot;,&quot;r2-col2&quot;]].
+      # As with all Prawn text drawing operations, strings must be UTF-8 encoded.
+      #
+      # The following options are available for customizing your tables, with
+      # defaults shown in [] at the end of each description.
+      #
+      # &lt;tt&gt;:font_size&lt;/tt&gt;:: The font size for the text cells . [12]
+      # &lt;tt&gt;:horizontal_padding&lt;/tt&gt;:: The horizontal cell padding in PDF points [5]
+      # &lt;tt&gt;:vertical_padding&lt;/tt&gt;:: The vertical cell padding in PDF points [5]
+      # &lt;tt&gt;:padding&lt;/tt&gt;:: Horizontal and vertical cell padding (overrides both)
+      # &lt;tt&gt;:border&lt;/tt&gt;:: With of border lines in PDF points [1]
+      # &lt;tt&gt;:border_style&lt;/tt&gt;:: If set to :grid, fills in all borders.  Otherwise, borders are drawn on columns only, not rows
+      # &lt;tt&gt;:position&lt;/tt&gt;:: One of &lt;tt&gt;:left&lt;/tt&gt;, &lt;tt&gt;:center&lt;/tt&gt; or &lt;tt&gt;n&lt;/tt&gt;, where &lt;tt&gt;n&lt;/tt&gt; is an x-offset from the left edge of the current bounding box
+      # &lt;tt&gt;:widths:&lt;/tt&gt; A hash of indices and widths in PDF points.  E.g. &lt;tt&gt;{ 0 =&gt; 50, 1 =&gt; 100 }&lt;/tt&gt;
+      # &lt;tt&gt;:row_colors&lt;/tt&gt;:: An array of row background colors which are used cyclicly.  
+      #
+      # Row colors are specified as html encoded values, e.g.
+      # [&quot;ffffff&quot;,&quot;aaaaaa&quot;,&quot;ccaaff&quot;].  You can also specify 
+      # &lt;tt&gt;:row_colors =&gt; :pdf_writer&lt;/tt&gt; if you wish to use the default color
+      # scheme from the PDF::Writer library.
+      #
+      # See Document#table for typical usage, as directly using this class is
+      # not recommended unless you know why you want to do it.
+      #
       def initialize(data, document,options={})
         @data                = data
         @document            = document
         @font_size           = options[:font_size] || 12
-        @horizontal_padding  = options[:horizontal_padding] || 5
-        @vertical_padding    = options[:vertical_padding]   || 5
-        @border              = options[:border]    || 1
         @border_style        = options[:border_style]
+        @border              = options[:border]    || 1
         @position            = options[:position]  || :left
         @headers             = options[:headers]
         @row_colors          = options[:row_colors]
 
+        @horizontal_padding  = options[:horizontal_padding] || 5
+        @vertical_padding    = options[:vertical_padding]   || 5
+
+        if options[:padding]
+          @horizontal_padding = @vertical_padding = options[:padding]
+        end
+
+        
         @row_colors = [&quot;ffffff&quot;,&quot;cccccc&quot;] if @row_colors == :pdf_writer
 
         @original_row_colors = @row_colors.dup if @row_colors
@@ -40,22 +112,14 @@ module Prawn
         end
       end
       
-      def calculate_column_widths
-        @col_widths = [0] * @data[0].length
-        renderable_data.each do |row|
-          row.each_with_index do |cell,i|
-            length = cell.lines.map { |e| 
-              @document.font_metrics.string_width(e,@font_size) }.max +
-                2*@horizontal_padding
-            @col_widths[i] = length if length &gt; @col_widths[i]
-          end
-        end
-      end
-
+      # Width of the table in PDF points
+      #
       def width
          @col_widths.inject(0) { |s,r| s + r }
       end
-
+      
+      # Draws the table onto the PDF document
+      #
       def draw
         case(@position) 
         when :center
@@ -77,6 +141,18 @@ module Prawn
 
       private
 
+      def calculate_column_widths
+        @col_widths = [0] * @data[0].length
+        renderable_data.each do |row|
+          row.each_with_index do |cell,i|
+            length = cell.lines.map { |e| 
+              @document.font_metrics.string_width(e,@font_size) }.max +
+                2*@horizontal_padding
+            @col_widths[i] = length if length &gt; @col_widths[i]
+          end
+        end
+      end
+
       def renderable_data
         if @headers
           [@headers] + @data</diff>
      <filename>lib/prawn/document/table.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>c3b1bb4da23d28bebd646d2b4d63ff8d2f287247</id>
    </parent>
  </parents>
  <author>
    <name>Gregory Brown</name>
    <email>gregory.t.brown@gmail.com</email>
  </author>
  <url>http://github.com/sandal/prawn/commit/1ff7cd9e6260894c9e2d131bd7c5b1b44f694816</url>
  <id>1ff7cd9e6260894c9e2d131bd7c5b1b44f694816</id>
  <committed-date>2008-06-26T15:46:47-07:00</committed-date>
  <authored-date>2008-06-26T15:46:47-07:00</authored-date>
  <message>Table API documentation [#26]</message>
  <tree>7e1a52bf15d19ad5e606599e77ad6bbb8b35775d</tree>
  <committer>
    <name>Gregory Brown</name>
    <email>gregory.t.brown@gmail.com</email>
  </committer>
</commit>
