erbook 4.0.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.
Files changed (56) hide show
  1. data/LICENSE +13 -0
  2. data/README +14 -0
  3. data/Rakefile +77 -0
  4. data/bin/erbook +309 -0
  5. data/doc/HelloWorld.input +37 -0
  6. data/doc/HelloWorld.spec +62 -0
  7. data/doc/README +6 -0
  8. data/doc/api/classes/ERBook.html +164 -0
  9. data/doc/api/classes/RDoc.html +112 -0
  10. data/doc/api/classes/RDoc/AnyMethod.html +195 -0
  11. data/doc/api/classes/RDoc/AnyMethod.src/M000005.html +18 -0
  12. data/doc/api/classes/RDoc/AnyMethod.src/M000006.html +23 -0
  13. data/doc/api/classes/RDoc/AnyMethod.src/M000007.html +18 -0
  14. data/doc/api/classes/RDoc/AnyMethod.src/M000008.html +22 -0
  15. data/doc/api/classes/RDoc/TopLevel.html +250 -0
  16. data/doc/api/classes/RDoc/TopLevel.src/M000009.html +18 -0
  17. data/doc/api/classes/RDoc/TopLevel.src/M000010.html +18 -0
  18. data/doc/api/classes/RDoc/TopLevel.src/M000011.html +18 -0
  19. data/doc/api/classes/RDoc/TopLevel.src/M000012.html +29 -0
  20. data/doc/api/classes/RDoc/TopLevel.src/M000013.html +25 -0
  21. data/doc/api/classes/RDoc/TopLevel.src/M000014.html +18 -0
  22. data/doc/api/classes/String.html +261 -0
  23. data/doc/api/classes/String.src/M000001.html +18 -0
  24. data/doc/api/classes/String.src/M000002.html +34 -0
  25. data/doc/api/classes/String.src/M000003.html +20 -0
  26. data/doc/api/classes/String.src/M000004.html +26 -0
  27. data/doc/api/created.rid +1 -0
  28. data/doc/api/files/lib/erbook/html_rb.html +125 -0
  29. data/doc/api/files/lib/erbook/rdoc_rb.html +116 -0
  30. data/doc/api/files/lib/erbook_rb.html +107 -0
  31. data/doc/api/fr_class_index.html +31 -0
  32. data/doc/api/fr_file_index.html +29 -0
  33. data/doc/api/fr_method_index.html +40 -0
  34. data/doc/api/index.html +24 -0
  35. data/doc/api/rdoc-style.css +208 -0
  36. data/doc/erbook.png +0 -0
  37. data/doc/erbook.svg +349 -0
  38. data/doc/feed-icon-28x28.png +0 -0
  39. data/doc/index.html +2663 -0
  40. data/doc/manual.erb +769 -0
  41. data/fmt/html.icons/LICENSE +67 -0
  42. data/fmt/html.icons/README +31 -0
  43. data/fmt/html.icons/caution.png +0 -0
  44. data/fmt/html.icons/important.png +0 -0
  45. data/fmt/html.icons/note.png +0 -0
  46. data/fmt/html.icons/quote.png +0 -0
  47. data/fmt/html.icons/tip.png +0 -0
  48. data/fmt/html.icons/warning.png +0 -0
  49. data/fmt/html.yaml +1185 -0
  50. data/fmt/latex.yaml +2 -0
  51. data/fmt/man.yaml +2 -0
  52. data/fmt/text.yaml +2 -0
  53. data/lib/erbook.rb +13 -0
  54. data/lib/erbook/html.rb +145 -0
  55. data/lib/erbook/rdoc.rb +126 -0
  56. metadata +141 -0
@@ -0,0 +1,2 @@
1
+ desc: high-quality typesetting
2
+ code: raise NotImplementedError, 'this format is not yet implemented'
@@ -0,0 +1,2 @@
1
+ desc: manual page for UNIX
2
+ code: raise NotImplementedError, 'this format is not yet implemented'
@@ -0,0 +1,2 @@
1
+ desc: plain text, nothing fancy
2
+ code: raise NotImplementedError, 'this format is not yet implemented'
@@ -0,0 +1,13 @@
1
+ # Project and release information.
2
+ module ERBook
3
+ PROJECT = 'erbook'
4
+ VERSION = '4.0.0'
5
+ RELEASE = '2008-11-15'
6
+ WEBSITE = 'http://snk.tuxfamily.org/lib/erbook'
7
+ SUMMARY = 'Extensible document processor based on eRuby.'
8
+ DISPLAY = PROJECT + ' ' + VERSION
9
+
10
+ INSTALL_DIR = File.expand_path File.join(File.dirname(__FILE__), '..')
11
+ FORMATS_DIR = File.join INSTALL_DIR, 'fmt'
12
+ FORMAT_FILES = Dir[File.join(FORMATS_DIR, '*.yaml')]
13
+ end
@@ -0,0 +1,145 @@
1
+ # This file defines the String#to_html and String#to_inline_html
2
+ # methods, which are invoked to transform plain text into HTML.
3
+ #
4
+ # This particular implementation features the Markdown
5
+ # formatting system via Maruku, syntax coloring via CodeRay,
6
+ # and smart source code sizing (block versus inline display).
7
+
8
+ require 'cgi'
9
+
10
+ begin
11
+ require 'rubygems'
12
+ gem 'maruku', '~> 0.5'
13
+ gem 'coderay', '>= 0.7'
14
+ rescue LoadError
15
+ end
16
+
17
+ require 'coderay'
18
+ require 'maruku'
19
+
20
+ class String
21
+ # The content of these HTML tags will be preserved while
22
+ # they are being processed by Textile. By doing this, we
23
+ # avoid unwanted Textile transformations, such as quotation
24
+ # marks becoming curly ( ), in source code.
25
+ PROTECTED_TAGS = %w[tt code pre]
26
+
27
+ # The content of these HTML tags will be preserved
28
+ # *verbatim* throughout the text-to-HTML conversion process.
29
+ VERBATIM_TAGS = %w[noformat]
30
+
31
+ # Transforms this string into an *inline* HTML string (one that
32
+ # does not contain any block-level HTML elements at the root).
33
+ def to_inline_html
34
+ to_html true
35
+ end
36
+
37
+ # XXX: Maruku also defines String#to_html so we have to hack around it :-(
38
+ alias to_html_maruku to_html
39
+
40
+ # Transforms this string into HTML while ensuring that the
41
+ # result contains one or more block-level elements at the root.
42
+ #
43
+ # If aInline is true, then the resulting HTML will be an *inline* string.
44
+ #
45
+ def to_html aInline = false
46
+ # XXX: Maruku also defines String#to_html so we have to hack around it :-(
47
+ return to_html_maruku if caller.detect {|c| c =~ %r'/lib/maruku/output/' }
48
+
49
+ protect(self, VERBATIM_TAGS, true) do |text|
50
+ html = protect(text, PROTECTED_TAGS, false) {|s| s.thru_maruku aInline }
51
+
52
+ # Markdown's "code spans" should really be "pre spans"
53
+ while html.gsub! %r{(<pre>)<code>(.*?)</code>(</pre>)}m, '\1\2\3'
54
+ end
55
+
56
+ # ensure tables have a border: this *greatly* improves
57
+ # readability in text-based web browsers like w3m and lynx
58
+ html.gsub! %r/<table\b/, '\& border="1"'
59
+
60
+ # add syntax coloring
61
+ html.thru_coderay
62
+ end
63
+ end
64
+
65
+ # Returns the result of running this string through Maruku.
66
+ #
67
+ # If aInline is true, then the resulting HTML will
68
+ # *not* be wrapped in a HTML paragraph element.
69
+ #
70
+ def thru_maruku aInline = false
71
+ html = Maruku.new(self).to_html
72
+ html.sub! %r{\A<p>(.*)</p>\Z}, '\1' if aInline
73
+ html
74
+ end
75
+
76
+ # Adds syntax coloring to <code> elements in the given text. If the
77
+ # <code> tag has an attribute lang="...", then that is considered the
78
+ # programming language for which appropriate syntax coloring should be
79
+ # applied. Otherwise, the programming language is assumed to be ruby.
80
+ def thru_coderay
81
+ gsub %r{<(code)(.*?)>(.*?)</\1>}m do
82
+ atts, code = $2, CGI.unescapeHTML($3)
83
+ lang = atts[/\blang=('|")(.*?)\1/i, 2] || :ruby
84
+
85
+ html = CodeRay.scan(code, lang).html(:css => :style)
86
+ tag = if code =~ /\n/ then :pre else :code end
87
+
88
+ %{<#{tag} class="code"#{atts}>#{html}</#{tag}>}
89
+ end
90
+ end
91
+
92
+ private
93
+
94
+ # Protects the given tags in the given input, passes
95
+ # that protected input to the given block, restores the
96
+ # given tags in the result of the block and returns it.
97
+ #
98
+ # If aVerbatim is true, the content of the elments having the given tags will
99
+ # not be temporarily altered so that process nested elements can be processed.
100
+ #
101
+ def protect aInput, aTags, aVerbatim #:yields: aInput
102
+ raise ArgumentError unless block_given?
103
+
104
+ input = aInput.dup
105
+ escapes = {}
106
+
107
+ # protect the given tags by escaping them
108
+ aTags.each do |tag|
109
+ input.gsub! %r{(<#{tag}.*?>)(.*?)(</#{tag}>)}m do
110
+ head, body, tail = $1, $2, $3
111
+
112
+ # XXX: when we restore protected tags later on, String.gsub! is
113
+ # removing all single backslashes for some reason... so we
114
+ # protect against this by doubling all single backslashes first
115
+ body.gsub! %r/\\/, '\&\&'
116
+
117
+ original =
118
+ if aVerbatim
119
+ body
120
+ else
121
+ head << CGI.escapeHTML(CGI.unescapeHTML(body)) << tail
122
+ end
123
+
124
+ escaped = original.digest_id
125
+ escapes[escaped] = original
126
+
127
+ escaped
128
+ end
129
+ end
130
+
131
+ # invoke the given block with the protected input
132
+ output = yield(input)
133
+
134
+ # restore the protected tags by unescaping them
135
+ until escapes.empty?
136
+ escapes.each_pair do |esc, orig|
137
+ if output.gsub! esc, orig
138
+ escapes.delete esc
139
+ end
140
+ end
141
+ end
142
+
143
+ output
144
+ end
145
+ end
@@ -0,0 +1,126 @@
1
+ # Workaround for: `rdoc --fmt xml` does not dump information about methods.
2
+
3
+ require 'rdoc/rdoc'
4
+
5
+ module RDoc
6
+ class TopLevel
7
+ # Returns an array of all classes recorded thus far.
8
+ def self.all_classes
9
+ @@all_classes.values
10
+ end
11
+
12
+ # Returns an array of all modules recorded thus far.
13
+ def self.all_modules
14
+ @@all_modules.values
15
+ end
16
+
17
+ # Returns an array of RDoc::AnyMethod objects
18
+ # representing all methods recorded thus far.
19
+ def self.all_methods
20
+ all_classes_and_modules.map {|c| c.method_list }.flatten
21
+ end
22
+
23
+ # Update the return value of the all_classes_and_modules() method
24
+ # to *really* include every class and every module seen thus far.
25
+ def self.refresh_all_classes_and_modules
26
+ visit = lambda do |node|
27
+ if node.is_a? NormalClass or node.is_a? SingleClass
28
+ @@all_classes[node.full_name] = node
29
+
30
+ elsif node.is_a? NormalModule
31
+ @@all_modules[node.full_name] = node
32
+ end
33
+
34
+ (node.classes + node.modules).each {|n| visit[n] }
35
+ end
36
+
37
+ all_classes_and_modules.each {|n| visit[n] }
38
+ end
39
+
40
+ # Returns a RDoc::TopLevel object containing information
41
+ # parsed from the given code string. This information is
42
+ # also added to the global TopLevel class state, so you can
43
+ # access it via the class methods of the TopLevel class.
44
+ #
45
+ # If the file name (which signifies the origin
46
+ # of the given code) is given, it MUST have a
47
+ # ".c" or ".rb" file extension. Otherwise,
48
+ # RDoc will ignore the given code string! :-(
49
+ #
50
+ def self.parse aCodeString, aFileName = __FILE__
51
+ top = ParserFactory.parser_for(
52
+ TopLevel.new(aFileName), aFileName,
53
+ aCodeString, DummyOptions.new, Stats.new
54
+ ).scan
55
+
56
+ refresh_all_classes_and_modules
57
+
58
+ top
59
+ end
60
+
61
+ # Returns a RDoc::TopLevel object containing information
62
+ # parsed from the code in the given file. This information
63
+ # is also added to the global TopLevel class state, so you
64
+ # can access it via the class methods of the TopLevel class.
65
+ #
66
+ # The given file name MUST have a ".c" or ".rb" file
67
+ # extension. Otherwise, RDoc will ignore the file! :-(
68
+ #
69
+ def self.parse_file aFileName
70
+ parse File.read(aFileName), aFileName
71
+ end
72
+ end
73
+
74
+ class AnyMethod
75
+ # Returns the fully qualified name of this method.
76
+ def full_name
77
+ [parent.full_name, name].join(singleton ? '::' : '#')
78
+ end
79
+
80
+ # Returns a complete method declaration with block parameters and all.
81
+ def decl
82
+ a = params.dup
83
+ if b = block_params
84
+ a.sub! %r/\s*\#.*(?=.$)/, '' # remove "# :yields: ..." string
85
+ a << " {|#{b}| ... }"
86
+ end
87
+ full_name << a
88
+ end
89
+
90
+ # Returns a HTML version of this method's comment.
91
+ def comment_html
92
+ DummyMarkup.new.markup comment
93
+ end
94
+
95
+ # Returns the RDoc::TopLevel object which contains this method.
96
+ def top_level
97
+ n = parent
98
+ while n && n.parent
99
+ n = n.parent
100
+ end
101
+ n
102
+ end
103
+ end
104
+
105
+ private
106
+
107
+ module DummyMixin #:nodoc:
108
+ def method_missing *args
109
+ # ignore all messages
110
+ end
111
+ end
112
+
113
+ class DummyOptions #:nodoc:
114
+ include DummyMixin
115
+
116
+ def quiet # supress '...c..m...' output on STDERR
117
+ true
118
+ end
119
+ end
120
+
121
+ class DummyMarkup #:nodoc:
122
+ require 'rdoc/generators/html_generator'
123
+ include Generators::MarkUp
124
+ include DummyMixin
125
+ end
126
+ end
metadata ADDED
@@ -0,0 +1,141 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: erbook
3
+ version: !ruby/object:Gem::Version
4
+ version: 4.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Suraj N. Kurapati
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-11-15 00:00:00 -08:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: maruku
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ~>
22
+ - !ruby/object:Gem::Version
23
+ version: "0.5"
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: coderay
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "0.7"
34
+ version:
35
+ description: Extensible document processor based on eRuby.
36
+ email: sunaku@gmail.com
37
+ executables:
38
+ - erbook
39
+ extensions: []
40
+
41
+ extra_rdoc_files: []
42
+
43
+ files:
44
+ - fmt
45
+ - fmt/html.icons
46
+ - fmt/html.icons/warning.png
47
+ - fmt/html.icons/tip.png
48
+ - fmt/html.icons/caution.png
49
+ - fmt/html.icons/quote.png
50
+ - fmt/html.icons/important.png
51
+ - fmt/html.icons/note.png
52
+ - fmt/html.icons/LICENSE
53
+ - fmt/html.icons/README
54
+ - fmt/latex.yaml
55
+ - fmt/html.yaml
56
+ - fmt/man.yaml
57
+ - fmt/text.yaml
58
+ - lib
59
+ - lib/erbook
60
+ - lib/erbook/html.rb
61
+ - lib/erbook/rdoc.rb
62
+ - lib/erbook.rb
63
+ - Rakefile
64
+ - bin
65
+ - bin/erbook
66
+ - LICENSE
67
+ - README
68
+ - doc
69
+ - doc/manual.erb
70
+ - doc/erbook.svg
71
+ - doc/erbook.png
72
+ - doc/HelloWorld.input
73
+ - doc/feed-icon-28x28.png
74
+ - doc/HelloWorld.spec
75
+ - doc/index.html
76
+ - doc/api
77
+ - doc/api/classes
78
+ - doc/api/classes/RDoc.html
79
+ - doc/api/classes/String.src
80
+ - doc/api/classes/String.src/M000001.html
81
+ - doc/api/classes/String.src/M000004.html
82
+ - doc/api/classes/String.src/M000003.html
83
+ - doc/api/classes/String.src/M000002.html
84
+ - doc/api/classes/String.html
85
+ - doc/api/classes/ERBook.html
86
+ - doc/api/classes/RDoc
87
+ - doc/api/classes/RDoc/TopLevel.src
88
+ - doc/api/classes/RDoc/TopLevel.src/M000013.html
89
+ - doc/api/classes/RDoc/TopLevel.src/M000010.html
90
+ - doc/api/classes/RDoc/TopLevel.src/M000011.html
91
+ - doc/api/classes/RDoc/TopLevel.src/M000014.html
92
+ - doc/api/classes/RDoc/TopLevel.src/M000012.html
93
+ - doc/api/classes/RDoc/TopLevel.src/M000009.html
94
+ - doc/api/classes/RDoc/TopLevel.html
95
+ - doc/api/classes/RDoc/AnyMethod.src
96
+ - doc/api/classes/RDoc/AnyMethod.src/M000005.html
97
+ - doc/api/classes/RDoc/AnyMethod.src/M000008.html
98
+ - doc/api/classes/RDoc/AnyMethod.src/M000006.html
99
+ - doc/api/classes/RDoc/AnyMethod.src/M000007.html
100
+ - doc/api/classes/RDoc/AnyMethod.html
101
+ - doc/api/fr_method_index.html
102
+ - doc/api/rdoc-style.css
103
+ - doc/api/files
104
+ - doc/api/files/lib
105
+ - doc/api/files/lib/erbook_rb.html
106
+ - doc/api/files/lib/erbook
107
+ - doc/api/files/lib/erbook/rdoc_rb.html
108
+ - doc/api/files/lib/erbook/html_rb.html
109
+ - doc/api/created.rid
110
+ - doc/api/index.html
111
+ - doc/api/fr_file_index.html
112
+ - doc/api/fr_class_index.html
113
+ - doc/README
114
+ has_rdoc: true
115
+ homepage: http://snk.tuxfamily.org/lib/erbook
116
+ post_install_message:
117
+ rdoc_options: []
118
+
119
+ require_paths:
120
+ - lib
121
+ required_ruby_version: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: "0"
126
+ version:
127
+ required_rubygems_version: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: "0"
132
+ version:
133
+ requirements: []
134
+
135
+ rubyforge_project: sunaku
136
+ rubygems_version: 1.2.0
137
+ signing_key:
138
+ specification_version: 2
139
+ summary: Extensible document processor based on eRuby.
140
+ test_files: []
141
+