redcloth-formatters-rdoc 0.0.1
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.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.textile +38 -0
- data/Rakefile +2 -0
- data/lib/redcloth-formatters-rdoc.rb +5 -0
- data/lib/redcloth-formatters-rdoc/formatters/r_doc.rb +114 -0
- data/lib/redcloth-formatters-rdoc/textile_doc.rb +16 -0
- data/lib/redcloth-formatters-rdoc/version.rb +7 -0
- data/redcloth-formatters-rdoc.gemspec +17 -0
- data/spec/fixtures/sample.rdoc +53 -0
- data/spec/fixtures/sample.textile +35 -0
- data/spec/helpers.rb +9 -0
- data/spec/rdoc_spec.rb +12 -0
- metadata +65 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Thomas Fankhauser
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.textile
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
h1. Redcloth::Formatters::Rdoc
|
2
|
+
|
3
|
+
A RedCloth formatter that enables to convert @.textile@ files to @.rdoc@ files. This is useful for compiling a @README.textile@ into a @README.rdoc@ file and use it as the main index file in the corresponding RDoc documentation.
|
4
|
+
|
5
|
+
h2. Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
bc.. gem 'redcloth-formatters-rdoc'
|
10
|
+
|
11
|
+
p. And then execute:
|
12
|
+
|
13
|
+
bc.. $ bundle
|
14
|
+
|
15
|
+
p. Or install it yourself as:
|
16
|
+
|
17
|
+
bc.. $ gem install redcloth-formatters-rdoc
|
18
|
+
|
19
|
+
h2. Usage
|
20
|
+
|
21
|
+
bc.. # Compile the readme to the rdoc format
|
22
|
+
readme_textile = File.open('README.textile', 'r+'){ |file| file.read }
|
23
|
+
readme_rdoc = RedCloth.new(readme_textile).to_rdoc
|
24
|
+
File.open('README.rdoc', 'w+'){ |file| file.write(readme_rdoc) }
|
25
|
+
|
26
|
+
# Create rdoc with the readme as main file
|
27
|
+
`rdoc --main README.rdoc`
|
28
|
+
|
29
|
+
# Clean up the rdoc file
|
30
|
+
File.delete("README.rdoc")
|
31
|
+
|
32
|
+
h2. Contributing
|
33
|
+
|
34
|
+
1. Fork it
|
35
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
36
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
37
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
38
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
module RedCloth::Formatters::RDoc
|
2
|
+
include RedCloth::Formatters::Base
|
3
|
+
|
4
|
+
[1, 2, 3, 4, 5, 6].each do |level|
|
5
|
+
define_method("h#{level}".to_sym) do |opts|
|
6
|
+
"#{'=' * level} #{opts[:text]}\n\n"
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
[:p, :pre, :div].each do |m|
|
11
|
+
define_method(m) do |opts|
|
12
|
+
"#{opts[:text]}\n\n"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def strong(opts)
|
17
|
+
"<b>#{opts[:text]}</b>"
|
18
|
+
end
|
19
|
+
alias_method :b, :strong
|
20
|
+
|
21
|
+
def em(opts)
|
22
|
+
"<em>#{opts[:text]}</em>"
|
23
|
+
end
|
24
|
+
alias_method :i, :em
|
25
|
+
|
26
|
+
[:ol, :ul].each do |m|
|
27
|
+
define_method("#{m}_open") do |opts|
|
28
|
+
opts[:block] = true
|
29
|
+
""
|
30
|
+
end
|
31
|
+
define_method("#{m}_close") do |opts|
|
32
|
+
"#{"\n" if opts[:nest] <= 1}"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def li_open(opts)
|
37
|
+
"#{"* " * opts[:nest]}#{opts[:text]}\n"
|
38
|
+
end
|
39
|
+
|
40
|
+
def li_close(opts=nil)
|
41
|
+
""
|
42
|
+
end
|
43
|
+
|
44
|
+
def td(opts)
|
45
|
+
tdtype = opts[:th] ? 'th' : 'td'
|
46
|
+
"\t\t<#{tdtype}#{pba(opts)}>#{opts[:text]}</#{tdtype}>\n"
|
47
|
+
end
|
48
|
+
|
49
|
+
def tr_open(opts)
|
50
|
+
"\t<tr#{pba(opts)}>\n"
|
51
|
+
end
|
52
|
+
|
53
|
+
def tr_close(opts)
|
54
|
+
"\t</tr>\n"
|
55
|
+
end
|
56
|
+
|
57
|
+
def table_open(opts)
|
58
|
+
"<table#{pba(opts)}>\n"
|
59
|
+
end
|
60
|
+
|
61
|
+
def table_close(opts)
|
62
|
+
"</table>\n\n"
|
63
|
+
end
|
64
|
+
|
65
|
+
def code(opts)
|
66
|
+
if opts[:block]
|
67
|
+
block = ""
|
68
|
+
opts[:text].lines.each { |line| block += " #{line}" }
|
69
|
+
return block
|
70
|
+
end
|
71
|
+
|
72
|
+
"<tt>#{opts[:text]}</tt>"
|
73
|
+
end
|
74
|
+
|
75
|
+
def bc_open(opts)
|
76
|
+
opts[:block] = true
|
77
|
+
""
|
78
|
+
end
|
79
|
+
|
80
|
+
def bc_close(opts)
|
81
|
+
opts[:block] = false
|
82
|
+
"\n\n"
|
83
|
+
end
|
84
|
+
|
85
|
+
def link(opts)
|
86
|
+
"{#{opts[:name]}}[#{opts[:href]}]"
|
87
|
+
end
|
88
|
+
|
89
|
+
def image(opts)
|
90
|
+
"#{opts[:src]}"
|
91
|
+
end
|
92
|
+
|
93
|
+
private
|
94
|
+
|
95
|
+
# escapement for regular HTML (not in PRE tag)
|
96
|
+
def escape(text)
|
97
|
+
text
|
98
|
+
end
|
99
|
+
|
100
|
+
# escapement for HTML in a PRE tag
|
101
|
+
def escape_pre(text)
|
102
|
+
text
|
103
|
+
end
|
104
|
+
|
105
|
+
# escaping for HTML attributes
|
106
|
+
def escape_attribute(text)
|
107
|
+
text
|
108
|
+
end
|
109
|
+
|
110
|
+
def after_transform(text)
|
111
|
+
text.chomp!
|
112
|
+
end
|
113
|
+
|
114
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module RedCloth
|
2
|
+
class TextileDoc
|
3
|
+
|
4
|
+
#
|
5
|
+
# Generates DocBook from the Textile contents.
|
6
|
+
#
|
7
|
+
# RedCloth.new( "And then? She *fell*!" ).to_rdoc
|
8
|
+
# #=> "And then? She fell!"
|
9
|
+
#
|
10
|
+
def to_rdoc(*rules)
|
11
|
+
apply_rules(rules)
|
12
|
+
|
13
|
+
to(RedCloth::Formatters::RDoc)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/redcloth-formatters-rdoc/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Thomas Fankhauser"]
|
6
|
+
gem.email = ["tommylefunk@googlemail.com"]
|
7
|
+
gem.description = %q{A RedCloth formatter that compiles textile to rdoc}
|
8
|
+
gem.summary = %q{A RedCloth formatter that enables to convert *.textile files to .rdoc files. This is useful for compiling a README.textile into a README.rdoc file and use it as the main index file in the corresponding RDoc documentation.}
|
9
|
+
gem.homepage = "http://southdesign.github.com/redcloth-formatters-rdoc"
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "redcloth-formatters-rdoc"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = Redcloth::Formatters::RDoc::VERSION
|
17
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
= Text Markup and Links
|
2
|
+
|
3
|
+
Some text which contains <b>bold</b> and <tt>code</tt> and <em>emphasized</em>. Okay
|
4
|
+
let's see how it is doing with links:
|
5
|
+
|
6
|
+
* {RDoc}[http://rdoc.org]
|
7
|
+
|
8
|
+
== Source Code
|
9
|
+
|
10
|
+
Multiple lines of code:
|
11
|
+
|
12
|
+
# This is some code
|
13
|
+
That should be parsed right
|
14
|
+
|
15
|
+
Single line of code:
|
16
|
+
|
17
|
+
#and some code again
|
18
|
+
|
19
|
+
== A List
|
20
|
+
|
21
|
+
* <b>A list entry</b>
|
22
|
+
* * A sublist entry
|
23
|
+
* A sublist entry
|
24
|
+
* * * A sublist entry
|
25
|
+
|
26
|
+
== A Table
|
27
|
+
|
28
|
+
<table>
|
29
|
+
<tr>
|
30
|
+
<th>Value </th>
|
31
|
+
<th>JMeter </th>
|
32
|
+
<th>BigBench </th>
|
33
|
+
</tr>
|
34
|
+
<tr>
|
35
|
+
<td> Total Requests </td>
|
36
|
+
<td> 48.014 </td>
|
37
|
+
<td> 55.484 </td>
|
38
|
+
</tr>
|
39
|
+
<tr>
|
40
|
+
<td> Requests/sec </td>
|
41
|
+
<td> 377 </td>
|
42
|
+
<td> 462 </td>
|
43
|
+
</tr>
|
44
|
+
<tr>
|
45
|
+
<td> Percentages </td>
|
46
|
+
<td> 100%% </td>
|
47
|
+
<td> 116% </td>
|
48
|
+
</tr>
|
49
|
+
</table>
|
50
|
+
|
51
|
+
== An Image
|
52
|
+
|
53
|
+
http://southdesign.github.com/bigbench/images/structure.png
|
@@ -0,0 +1,35 @@
|
|
1
|
+
h1. Text Markup and Links
|
2
|
+
|
3
|
+
Some text which contains *bold* and @code@ and _emphasized_. Okay
|
4
|
+
let's see how it is doing with links:
|
5
|
+
|
6
|
+
* "RDoc":http://rdoc.org
|
7
|
+
|
8
|
+
h2. Source Code
|
9
|
+
|
10
|
+
Multiple lines of code:
|
11
|
+
|
12
|
+
bc.. # This is some code
|
13
|
+
That should be parsed right
|
14
|
+
|
15
|
+
p. Single line of code:
|
16
|
+
|
17
|
+
bc.. #and some code again
|
18
|
+
|
19
|
+
h2. A List
|
20
|
+
|
21
|
+
* *A list entry*
|
22
|
+
** A sublist entry
|
23
|
+
* A sublist entry
|
24
|
+
*** A sublist entry
|
25
|
+
|
26
|
+
h2. A Table
|
27
|
+
|
28
|
+
|_. Value |_. JMeter |_. BigBench |
|
29
|
+
| Total Requests | 48.014 | 55.484 |
|
30
|
+
| Requests/sec | 377 | 462 |
|
31
|
+
| Percentages | 100%% | 116% |
|
32
|
+
|
33
|
+
h2. An Image
|
34
|
+
|
35
|
+
!http://southdesign.github.com/bigbench/images/structure.png(BigBench Request Structure)!
|
data/spec/helpers.rb
ADDED
data/spec/rdoc_spec.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require_relative "./helpers"
|
2
|
+
|
3
|
+
describe RedCloth::Formatters::RDoc do
|
4
|
+
|
5
|
+
it "should convert the textile fixture to the rdoc fixture" do
|
6
|
+
textile = File.open("spec/fixtures/sample.textile", "r"){ |file| file.read }
|
7
|
+
rdoc = File.open("spec/fixtures/sample.rdoc", "r"){ |file| file.read }
|
8
|
+
|
9
|
+
RedCloth.new(textile).to_rdoc.should == rdoc
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
metadata
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: redcloth-formatters-rdoc
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Thomas Fankhauser
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-04-21 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: A RedCloth formatter that compiles textile to rdoc
|
15
|
+
email:
|
16
|
+
- tommylefunk@googlemail.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- .gitignore
|
22
|
+
- Gemfile
|
23
|
+
- LICENSE
|
24
|
+
- README.textile
|
25
|
+
- Rakefile
|
26
|
+
- lib/redcloth-formatters-rdoc.rb
|
27
|
+
- lib/redcloth-formatters-rdoc/formatters/r_doc.rb
|
28
|
+
- lib/redcloth-formatters-rdoc/textile_doc.rb
|
29
|
+
- lib/redcloth-formatters-rdoc/version.rb
|
30
|
+
- redcloth-formatters-rdoc.gemspec
|
31
|
+
- spec/fixtures/sample.rdoc
|
32
|
+
- spec/fixtures/sample.textile
|
33
|
+
- spec/helpers.rb
|
34
|
+
- spec/rdoc_spec.rb
|
35
|
+
homepage: http://southdesign.github.com/redcloth-formatters-rdoc
|
36
|
+
licenses: []
|
37
|
+
post_install_message:
|
38
|
+
rdoc_options: []
|
39
|
+
require_paths:
|
40
|
+
- lib
|
41
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ! '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
48
|
+
none: false
|
49
|
+
requirements:
|
50
|
+
- - ! '>='
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0'
|
53
|
+
requirements: []
|
54
|
+
rubyforge_project:
|
55
|
+
rubygems_version: 1.8.11
|
56
|
+
signing_key:
|
57
|
+
specification_version: 3
|
58
|
+
summary: A RedCloth formatter that enables to convert *.textile files to .rdoc files.
|
59
|
+
This is useful for compiling a README.textile into a README.rdoc file and use it
|
60
|
+
as the main index file in the corresponding RDoc documentation.
|
61
|
+
test_files:
|
62
|
+
- spec/fixtures/sample.rdoc
|
63
|
+
- spec/fixtures/sample.textile
|
64
|
+
- spec/helpers.rb
|
65
|
+
- spec/rdoc_spec.rb
|