ron 0.3 → 0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,12 +0,0 @@
1
- <h2 id='NAME'>NAME</h2>
2
- <p><code>angle_bracket_syntax</code> -- angle bracket syntax test</p>
3
- <p>A <var>WORD</var> in angle brackets is converted to <var>WORD</var>,</p>
4
-
5
- <pre><code>except when &lt;WORD&gt; is
6
- part of a preformatted
7
- code block,
8
- </code></pre>
9
-
10
- <p>or when <code>&lt;WORD&gt;</code> is enclosed in backticks.</p>
11
-
12
- <p>or when <var>WORD</var> has a &lt;dot.&gt; or &lt;foo:colon&gt;.</p>
@@ -1,12 +0,0 @@
1
- angle_bracket_syntax(5) -- angle bracket syntax test
2
- ====================================================
3
-
4
- A <WORD> in angle brackets is converted to <var>WORD</var>,
5
-
6
- except when <WORD> is
7
- part of a preformatted
8
- code block,
9
-
10
- or when `<WORD>` is enclosed in backticks.
11
-
12
- or when <WORD> has a <dot.> or <foo:colon>.
@@ -1,3 +0,0 @@
1
- <h2 id='NAME'>NAME</h2>
2
- <p><code>simple</code> -- a simple ron example</p>
3
- <p>This document created by ron.</p>
@@ -1,4 +0,0 @@
1
- simple(7) -- a simple ron example
2
- =================================
3
-
4
- This document created by ron.
@@ -1,3 +0,0 @@
1
- <h1>custom_title_document -- This is a custom title</h1>
2
- <p>It doesn't define the name or section of this manual page and is
3
- output as a simple <code>&lt;h1&gt;</code> instead of a <code>NAME</code> section.</p>
@@ -1,5 +0,0 @@
1
- This is a custom title
2
- ======================
3
-
4
- It doesn't define the name or section of this manual page and is
5
- output as a simple `<h1>` instead of a `NAME` section.
@@ -1,21 +0,0 @@
1
- <h2 id='NAME'>NAME</h2>
2
- <p><code>defition_list_syntax</code> -- hiya</p>
3
- <p>Definition lists look like unordered lists:</p>
4
-
5
- <dl>
6
- <dt class="flush">term</dt>
7
- <dd><p>definition</p></dd>
8
- <dt>another one</dt>
9
- <dd>
10
- <p>The definition may span
11
- multiple lines and even</p>
12
-
13
- <p>start</p>
14
-
15
- <p>new paragraphs</p>
16
- </dd>
17
- <dt>
18
- <code>--somearg</code>=<var>VALUE</var>
19
- </dt>
20
- <dd><p>We can do that too.</p></dd>
21
- </dl>
@@ -1,18 +0,0 @@
1
- defition_list_syntax(5) -- hiya
2
- ===============================
3
-
4
- Definition lists look like unordered lists:
5
-
6
- * term:
7
- definition
8
-
9
- * another one:
10
- The definition may span
11
- multiple lines and even
12
-
13
- start
14
-
15
- new paragraphs
16
-
17
- * `--somearg`=<VALUE>:
18
- We can do that too.
@@ -1,88 +0,0 @@
1
- require 'contest'
2
- require 'ron/document'
3
-
4
- class DocumentTest < Test::Unit::TestCase
5
- SIMPLE_FILE = "#{File.dirname(__FILE__)}/basic_document.ron"
6
-
7
- test "new with path" do
8
- doc = Ron::Document.new(SIMPLE_FILE)
9
- assert_equal File.read(SIMPLE_FILE), doc.data
10
- end
11
-
12
- test "new with path and block" do
13
- doc = Ron::Document.new('hello.1.ron') { "# hello(1) -- hello world" }
14
- assert_equal "# hello(1) -- hello world", doc.data
15
- end
16
-
17
- test "new with path and block but missing name section" do
18
- doc = Ron::Document.new('foo.7.ron') { '' }
19
- assert_equal 'foo', doc.name
20
- assert_equal '7', doc.section
21
- end
22
-
23
- test "new with non conventional path and missing name section" do
24
- doc = Ron::Document.new('bar.ron') { '' }
25
- assert_equal 'bar', doc.name
26
- assert_equal nil, doc.section
27
- assert_equal "./bar.html", doc.path_for('html')
28
- assert_equal "./bar", doc.path_for('roff')
29
- assert_equal "./bar", doc.path_for('')
30
- assert_equal "./bar", doc.path_for(nil)
31
- end
32
-
33
- test "new with path and name section mismatch" do
34
- doc = Ron::Document.new('foo/rick.7.ron') { "# randy(3) -- I'm confused." }
35
- assert_equal 'randy', doc.name
36
- assert_equal 'rick', doc.path_name
37
- assert_equal '3', doc.section
38
- assert_equal '7', doc.path_section
39
- assert_equal 'rick.7', doc.basename
40
- assert_equal 'foo/rick.7.bar', doc.path_for(:bar)
41
- end
42
-
43
- test "new with no path and a name section" do
44
- doc = Ron::Document.new { "# brandy(5) -- wootderitis" }
45
- assert_equal nil, doc.path_name
46
- assert_equal nil, doc.path_section
47
- assert_equal 'brandy', doc.name
48
- assert_equal '5', doc.section
49
- assert_equal 'brandy.5', doc.basename
50
- assert_equal 'brandy.5.foo', doc.path_for(:foo)
51
- end
52
-
53
- context "simple conventionally named document" do
54
- setup do
55
- @doc = Ron::Document.new('hello.1.ron') { "# hello(1) -- hello world" }
56
- end
57
-
58
- should "load data" do
59
- assert_equal "# hello(1) -- hello world", @doc.data
60
- end
61
-
62
- should "extract the manual page name from the filename or document" do
63
- assert_equal 'hello', @doc.name
64
- end
65
-
66
- should "extract the manual page section from the filename or document" do
67
- assert_equal '1', @doc.section
68
- end
69
-
70
- should "convert to an HTML fragment" do
71
- assert_equal %[<h2 id='NAME'>NAME</h2>\n<p><code>hello</code> -- hello world</p>\n],
72
- @doc.to_html_fragment
73
- end
74
-
75
- should "convert to HTML with a layout" do
76
- assert_match %r{^<!DOCTYPE html.*}m, @doc.to_html
77
- assert_match %[<h2 id='NAME'>NAME</h2>\n<p><code>hello</code> -- hello world</p>],
78
- @doc.to_html
79
- end
80
-
81
- should "construct a path to related documents" do
82
- assert_equal "./hello.1.html", @doc.path_for(:html)
83
- assert_equal "./hello.1", @doc.path_for(:roff)
84
- assert_equal "./hello.1", @doc.path_for('')
85
- assert_equal "./hello.1", @doc.path_for(nil)
86
- end
87
- end
88
- end
@@ -1,59 +0,0 @@
1
- require 'contest'
2
-
3
- class RonTest < Test::Unit::TestCase
4
- testdir = File.dirname(__FILE__)
5
-
6
- # setup PATH so that we execute the right ron command
7
- bindir = File.dirname(testdir) + "/bin"
8
- ENV['PATH'] = "#{bindir}:#{ENV['PATH']}"
9
-
10
- # make sure the load path is setup correctly
11
- libdir = File.expand_path("#{testdir}/../lib")
12
- $:.unshift(libdir) unless $:.any? { |path| File.expand_path(path) == libdir }
13
- ENV['RUBYLIB'] = $:.join(':')
14
-
15
- require 'ron'
16
-
17
- test "takes ron text on stdin and produces roff on stdout" do
18
- output = `echo '# hello(1) -- hello world' | ron --date=2009-11-23`
19
- lines = output.split("\n")
20
- assert_equal 7, lines.size
21
- assert_equal %[.\\" generated with Ron/v#{Ron::VERSION}], lines.shift
22
- assert_equal %[.\\" http://github.com/rtomayko/ron/], lines.shift
23
- assert_equal %[.], lines.shift
24
- assert_equal %[.TH "HELLO" "1" "November 2009" "" ""], lines.shift
25
- assert_equal %[.], lines.shift
26
- assert_equal %[.SH "NAME"], lines.shift
27
- assert_equal %[\\fBhello\\fR \\-\\- hello world], lines.shift
28
- assert_equal 0, lines.size
29
- end
30
-
31
- test "produces html instead of roff with the --html argument" do
32
- output = `echo '# hello(1) -- hello world' | ron --html`
33
- assert_match(/<h2 id='NAME'>NAME<\/h2>/, output)
34
- end
35
-
36
- test "produces html fragment with the --fragment argument" do
37
- output = `echo '# hello(1) -- hello world' | ron --fragment`
38
- assert_equal "<h2 id='NAME'>NAME</h2>\n<p><code>hello</code> -- hello world</p>\n",
39
- output
40
- end
41
-
42
- # file based tests
43
- Dir[testdir + '/*.ron'].each do |source|
44
- dest = source.sub(/ron$/, 'html')
45
- wrong = source.sub(/ron$/, "wrong")
46
- test File.basename(source, '.ron') do
47
- html = `ron --html --fragment #{source}`
48
- expected = File.read(dest) rescue ''
49
- if expected != html
50
- File.open(wrong, 'wb') { |f| f.write(html) }
51
- diff = `diff -u #{dest} #{wrong} 2>/dev/null`
52
- fail "the #{dest} file does not exist" if diff.empty?
53
- flunk diff
54
- elsif File.exist?(wrong)
55
- File.unlink(wrong)
56
- end
57
- end
58
- end
59
- end
@@ -1,2 +0,0 @@
1
- <p>This is a document without a level 1 heading. It doesn't output
2
- a <code>NAME</code> section or custom <code>&lt;h1&gt;</code>.</p>
@@ -1,2 +0,0 @@
1
- This is a document without a level 1 heading. It doesn't output
2
- a `NAME` section or custom `<h1>`.