prawn-manual_builder 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b92c79c06eb6b0de91b5b541d5f948d45594e142
4
- data.tar.gz: 728bbb45d003b2c8c6a98a5e0ebb0c0dc83ba928
3
+ metadata.gz: e049e1cd01093d886d6fdff3d0a20aec5f585574
4
+ data.tar.gz: 7c29632aca25f3ca567681a5ff847eb170a0bf2e
5
5
  SHA512:
6
- metadata.gz: 80bf1683a3c617881d099cccc8b7e551400a43c959b091171a18561815d6d766f15b70af7e73e7cbc12a07c129a8c154fb43b755b99346f58f662c6869773cfa
7
- data.tar.gz: 521f4848da775d933160a2b1d8b460e7c17a598310c99a91469366147a42ae29288009bb259991130fb5cbd20c0c1611fc4d35e99b1bb2d36f475aaf13a93da8
6
+ metadata.gz: 63ca7f9ed808b3b17a4f9f5c6f69c1b5f27b02773af4b32fed7cb387632e2e4077f1d2519afb39bb883f5eb6f870f5e1ef80aa629ad4be528884c66db4b8d705
7
+ data.tar.gz: 532ede4bdd2deb210c246e7ffdc3ed9456b88a65d53df4a4667689096fa52b452e145d8c91a84c0adad104a84ced0768c034af7018f4030e336579d4e9badc0f
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Prawn::ManualBuilder
2
2
 
3
+ ![Maintained: yes](https://img.shields.io/badge/maintained-yes-brightgreen.png)
4
+
3
5
  This library is used by Prawn to generate its self-documenting manual,
4
6
  and could be used by third-party Prawn extensions to create manuals
5
7
  for their functionality as well.
@@ -228,7 +228,13 @@ module Prawn
228
228
  puts "Error evaluating example: #{e.message}"
229
229
  puts
230
230
  puts "---- Source: ----"
231
- puts source
231
+ puts
232
+ source.lines.each_with_index do |l, i|
233
+ puts format('% 4d: %s', i + 1, l)
234
+ end
235
+ puts
236
+ puts "---- Backtrace: ----"
237
+ puts e.backtrace
232
238
  end
233
239
  end
234
240
 
@@ -65,18 +65,14 @@ module Prawn
65
65
  # Then removes the '#' signs, reflows the line breaks and return the result
66
66
  #
67
67
  def introduction_text
68
- intro = @data.lines.grep(/^#/)
69
-
70
- intro.shift if intro.first =~ /^#!/
71
- intro.shift if intro.first =~ /coding:/
72
-
73
- intro = intro.join
74
-
75
- intro.gsub!(/\n# (?=\S)/m, ' ')
76
- intro.gsub!(/^#/, '')
77
- intro.gsub!("\n", "\n\n")
78
- intro.rstrip!
79
- intro
68
+ intro_lines
69
+ .map do |line|
70
+ line
71
+ .gsub(/\A\s*# (?=\S)/m, ' ')
72
+ .gsub(/\A\s*#/, '')
73
+ .strip
74
+ end
75
+ .join("\n")
80
76
  end
81
77
 
82
78
  # Returns a human friendly version of the example file name
@@ -113,7 +109,18 @@ module Prawn
113
109
 
114
110
  data.encode(::Encoding::UTF_8)
115
111
  end
116
-
112
+
113
+ def intro_lines
114
+ @data
115
+ .lines
116
+ .grep(/^#/)
117
+ .reject do |line|
118
+ line.start_with?('#!') ||
119
+ /coding:/.match(line) ||
120
+ /\A\s*#\s*frozen_string_literal:/.match(line) ||
121
+ /\A\s*#\s*rubocop:/.match(line)
122
+ end
123
+ end
117
124
  end
118
125
  end
119
126
  end
@@ -1,20 +1,20 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Prawn
4
- module ManualBuilder
5
- # The Prawn::ManualBuilder::ExamplePackage class is a utility class to
6
- # handle the packaging of individual examples within a hierarchy
4
+ module ManualBuilder
5
+ # The Prawn::ManualBuilder::ExamplePackage class is a utility class to
6
+ # handle the packaging of individual examples within a hierarchy
7
7
  # when building the manual.
8
8
  class ExamplePackage
9
9
  attr_reader :intro_block, :folder_name
10
10
 
11
11
  attr_writer :name
12
-
12
+
13
13
  def initialize(folder_name)
14
14
  @folder_name = folder_name
15
15
  @hierarchy = []
16
16
  end
17
-
17
+
18
18
  # Stores a new ExampleSection in the hierarchy and yields it to a block
19
19
  #
20
20
  def section(name)
@@ -22,31 +22,31 @@ module Prawn
22
22
  yield s
23
23
  @hierarchy << s
24
24
  end
25
-
25
+
26
26
  # Stores a new ExampleFile in the hierarchy
27
27
  #
28
28
  def example(filename, options={})
29
29
  @hierarchy << ExampleFile.new(self, "#{filename}.rb", options)
30
30
  end
31
-
31
+
32
32
  # Stores a block with code to be evaluated when rendering the package cover
33
33
  #
34
34
  def intro(&block)
35
35
  @intro_block = block
36
36
  end
37
-
37
+
38
38
  # Returns a human friendly version of the package name
39
39
  #
40
40
  def name
41
41
  @name ||= @folder_name.gsub("_", " ").capitalize
42
42
  end
43
-
43
+
44
44
  # Renders a cover page for the package to a pdf and iterates the examples
45
45
  # hierarchy delegating the examples and sections to be rendered as well
46
46
  #
47
47
  def render(pdf)
48
48
  pdf.render_package_cover(self)
49
-
49
+
50
50
  @hierarchy.each do |node|
51
51
  node.render(pdf)
52
52
  end
@@ -0,0 +1,14 @@
1
+ module Prawn
2
+ module ManualBuilder
3
+ class Manual
4
+ # Creates a new ExamplePackage object and yields it to a block in order
5
+ # for it to be populated with examples, sections and some introduction
6
+ # text. Used on the package files.
7
+ def package(package, &block)
8
+ ep = ExamplePackage.new(package)
9
+ ep.instance_eval(&block)
10
+ ep.render(self)
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,5 @@
1
+ module Prawn
2
+ module ManualBuilder
3
+ VERSION = '0.3.0'
4
+ end
5
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prawn-manual_builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Felipe Doria
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-07-23 00:00:00.000000000 Z
12
+ date: 2018-04-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: coderay
@@ -46,9 +46,14 @@ files:
46
46
  - lib/prawn/manual_builder/example_file.rb
47
47
  - lib/prawn/manual_builder/example_package.rb
48
48
  - lib/prawn/manual_builder/example_section.rb
49
+ - lib/prawn/manual_builder/manual.rb
49
50
  - lib/prawn/manual_builder/syntax_highlight.rb
51
+ - lib/prawn/manual_builder/version.rb
50
52
  homepage:
51
- licenses: []
53
+ licenses:
54
+ - PRAWN
55
+ - GPL-2.0
56
+ - GPL-3.0
52
57
  metadata: {}
53
58
  post_install_message:
54
59
  rdoc_options: []
@@ -58,7 +63,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
58
63
  requirements:
59
64
  - - ">="
60
65
  - !ruby/object:Gem::Version
61
- version: 1.9.3
66
+ version: '2.3'
62
67
  required_rubygems_version: !ruby/object:Gem::Requirement
63
68
  requirements:
64
69
  - - ">="
@@ -66,9 +71,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
66
71
  version: '0'
67
72
  requirements: []
68
73
  rubyforge_project:
69
- rubygems_version: 2.2.2
74
+ rubygems_version: 2.6.14
70
75
  signing_key:
71
76
  specification_version: 4
72
77
  summary: A tool for writing manuals for Prawn and Prawn accessories
73
78
  test_files: []
74
- has_rdoc: