Skip to content

Commit

Permalink
Extract manual building code
Browse files Browse the repository at this point in the history
Squashed commit of the following:

commit 24ee467
Author: Gregory Brown <gregory.t.brown@gmail.com>
Date:   Wed May 28 12:00:30 2014 -0400

    Remove Prawn::Example namespace shim

commit 1fbf5a1
Author: Gregory Brown <gregory.t.brown@gmail.com>
Date:   Wed May 28 11:45:41 2014 -0400

    Minor tweaks to manual

commit 488c129
Author: Gregory Brown <gregory.t.brown@gmail.com>
Date:   Tue May 27 12:13:42 2014 -0400

    Use extracted prawn-manual_builder code

    The functionality of the manual should stay the same,
    we now just depend on an external gem rather than bundling
    the manual building code directly with Prawn.

    In theory, this will allow for the manual building code
    to be used by other extensions. In practice, some
    extra effort may be needed before that's practical.
  • Loading branch information
practicingruby committed May 28, 2014
1 parent 1be9bd4 commit 8b4fbd8
Show file tree
Hide file tree
Showing 114 changed files with 126 additions and 796 deletions.
2 changes: 1 addition & 1 deletion Rakefile
Expand Up @@ -32,7 +32,7 @@ desc "Generate the 'Prawn by Example' manual"
task :manual do
puts "Building manual..."
require File.expand_path(File.join(File.dirname(__FILE__),
%w[manual manual manual]))
%w[manual contents]))
puts "The Prawn manual is available at manual.pdf. Happy Prawning!"
end

Expand Down
Binary file added manual/absolute_position.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion manual/basic_concepts/adding_pages.rb
Expand Up @@ -17,7 +17,7 @@
%w[.. example_helper]))

filename = File.basename(__FILE__).gsub('.rb', '.pdf')
Prawn::Example.generate(filename) do
Prawn::ManualBuilder::Example.generate(filename) do
text "We are still on the initial page for this example. Now I'll ask " +
"Prawn to gently start a new page. Please follow me to the next page."

Expand Down
6 changes: 3 additions & 3 deletions manual/basic_concepts/basic_concepts.rb
Expand Up @@ -2,10 +2,10 @@
#
# Examples for Prawn basic concepts.
#
require File.expand_path(File.join(File.dirname(__FILE__),
%w[.. example_helper]))

Prawn::Example.generate("basic_concepts.pdf", :page_size => "FOLIO") do
require_relative "../example_helper"

Prawn::ManualBuilder::Example.generate("basic_concepts.pdf", :page_size => "FOLIO") do

package "basic_concepts" do |p|

Expand Down
2 changes: 1 addition & 1 deletion manual/basic_concepts/cursor.rb
Expand Up @@ -16,7 +16,7 @@
%w[.. example_helper]))

filename = File.basename(__FILE__).gsub('.rb', '.pdf')
Prawn::Example.generate(filename) do
Prawn::ManualBuilder::Example.generate(filename) do
stroke_axis

text "the cursor is here: #{cursor}"
Expand Down
2 changes: 1 addition & 1 deletion manual/basic_concepts/measurement.rb
Expand Up @@ -15,7 +15,7 @@
%w[.. example_helper]))

filename = File.basename(__FILE__).gsub('.rb', '.pdf')
Prawn::Example.generate(filename) do
Prawn::ManualBuilder::Example.generate(filename) do
require "prawn/measurement_extensions"

[:mm, :cm, :dm, :m, :in, :yd, :ft].each do |measurement|
Expand Down
2 changes: 1 addition & 1 deletion manual/basic_concepts/origin.rb
Expand Up @@ -26,7 +26,7 @@
%w[.. example_helper]))

filename = File.basename(__FILE__).gsub('.rb', '.pdf')
Prawn::Example.generate(filename) do
Prawn::ManualBuilder::Example.generate(filename) do
stroke_axis

stroke_circle [0, 0], 10
Expand Down
2 changes: 1 addition & 1 deletion manual/basic_concepts/other_cursor_helpers.rb
Expand Up @@ -13,7 +13,7 @@
%w[.. example_helper]))

filename = File.basename(__FILE__).gsub('.rb', '.pdf')
Prawn::Example.generate(filename) do
Prawn::ManualBuilder::Example.generate(filename) do
stroke_horizontal_rule
pad(20) { text "Text padded both before and after." }

Expand Down
2 changes: 1 addition & 1 deletion manual/bounding_box/bounding_box.rb
Expand Up @@ -5,7 +5,7 @@
require File.expand_path(File.join(File.dirname(__FILE__),
%w[.. example_helper]))

Prawn::Example.generate("bounding_box.pdf", :page_size => "FOLIO") do
Prawn::ManualBuilder::Example.generate("bounding_box.pdf", :page_size => "FOLIO") do

package "bounding_box" do |p|

Expand Down
2 changes: 1 addition & 1 deletion manual/bounding_box/bounds.rb
Expand Up @@ -21,7 +21,7 @@
%w[.. example_helper]))

filename = File.basename(__FILE__).gsub('.rb', '.pdf')
Prawn::Example.generate(filename) do
Prawn::ManualBuilder::Example.generate(filename) do
def print_coordinates
text "top: #{bounds.top}"
text "bottom: #{bounds.bottom}"
Expand Down
2 changes: 1 addition & 1 deletion manual/bounding_box/canvas.rb
Expand Up @@ -14,7 +14,7 @@
%w[.. example_helper]))

filename = File.basename(__FILE__).gsub('.rb', '.pdf')
Prawn::Example.generate(filename) do
Prawn::ManualBuilder::Example.generate(filename) do
canvas do
fill_circle [bounds.left, bounds.top], 30
fill_circle [bounds.right, bounds.top], 30
Expand Down
2 changes: 1 addition & 1 deletion manual/bounding_box/creation.rb
Expand Up @@ -14,7 +14,7 @@
%w[.. example_helper]))

filename = File.basename(__FILE__).gsub('.rb', '.pdf')
Prawn::Example.generate(filename) do
Prawn::ManualBuilder::Example.generate(filename) do
bounding_box([200, cursor - 100], :width => 200, :height => 100) do
text "Just your regular bounding box"

Expand Down
2 changes: 1 addition & 1 deletion manual/bounding_box/indentation.rb
Expand Up @@ -11,7 +11,7 @@
%w[.. example_helper]))

filename = File.basename(__FILE__).gsub('.rb', '.pdf')
Prawn::Example.generate(filename) do
Prawn::ManualBuilder::Example.generate(filename) do
text "No indentation on the margin box."
indent(20) do
text "Some indentation inside an indent block."
Expand Down
2 changes: 1 addition & 1 deletion manual/bounding_box/nesting.rb
Expand Up @@ -13,7 +13,7 @@
%w[.. example_helper]))

filename = File.basename(__FILE__).gsub('.rb', '.pdf')
Prawn::Example.generate(filename) do
Prawn::ManualBuilder::Example.generate(filename) do
def box_content(string)
text string
transparent(0.5) { stroke_bounds }
Expand Down
2 changes: 1 addition & 1 deletion manual/bounding_box/russian_boxes.rb
Expand Up @@ -8,7 +8,7 @@
%w[.. example_helper]))

filename = File.basename(__FILE__).gsub('.rb', '.pdf')
Prawn::Example.generate(filename) do
Prawn::ManualBuilder::Example.generate(filename) do
def combine(a1, a2)
output = []
a1.each do |i1|
Expand Down
2 changes: 1 addition & 1 deletion manual/bounding_box/stretchy.rb
Expand Up @@ -8,7 +8,7 @@
%w[.. example_helper]))

filename = File.basename(__FILE__).gsub('.rb', '.pdf')
Prawn::Example.generate(filename) do
Prawn::ManualBuilder::Example.generate(filename) do
y_position = cursor
bounding_box([0, y_position], :width => 200, :height => 100) do
text "This bounding box has a height of 100. If this text gets too large " +
Expand Down
15 changes: 6 additions & 9 deletions manual/manual/manual.rb → manual/contents.rb
@@ -1,19 +1,16 @@
# encoding: utf-8
#
# Generates the Prawn by example manual.
#

Encoding.default_external = Encoding::UTF_8
require_relative "example_helper"

require File.expand_path(File.join(File.dirname(__FILE__),
%w[.. example_helper]))
Encoding.default_external = Encoding::UTF_8

Prawn::Example.generate("manual.pdf",
:skip_page_creation => true,
:page_size => "FOLIO") do
Prawn::ManualBuilder::Example.generate("manual.pdf",
:skip_page_creation => true, :page_size => "FOLIO") do

load_page "cover"
load_page "how_to_read_this_manual"
load_page "", "cover"
load_page "", "how_to_read_this_manual"

# Core chapters
load_package "basic_concepts"
Expand Down
6 changes: 3 additions & 3 deletions manual/manual/cover.rb → manual/cover.rb
Expand Up @@ -2,11 +2,11 @@
#
# Prawn manual how to read this manual page.
#
require File.expand_path(File.join(File.dirname(__FILE__),
%w[.. example_helper]))

require_relative "example_helper"

filename = File.basename(__FILE__).gsub('.rb', '.pdf')
Prawn::Example.generate(filename) do
Prawn::ManualBuilder::Example.generate(filename) do
move_down 200

image "#{Prawn::DATADIR}/images/prawn.png",
Expand Down
Expand Up @@ -5,7 +5,7 @@
require File.expand_path(File.join(File.dirname(__FILE__),
%w[.. example_helper]))

Prawn::Example.generate("document_and_page_options.pdf",
Prawn::ManualBuilder::Example.generate("document_and_page_options.pdf",
:page_size => "FOLIO") do

package "document_and_page_options" do |p|
Expand Down
111 changes: 0 additions & 111 deletions manual/example_file.rb

This file was deleted.

0 comments on commit 8b4fbd8

Please sign in to comment.