literate_maruku 0.1.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.
@@ -0,0 +1,27 @@
1
+ desc 'Release the website and new gem version'
2
+ task :deploy => [:check_version, :website, :release] do
3
+ puts "Remember to create SVN tag:"
4
+ puts "svn copy svn+ssh://rubyforge.org/var/svn/#{PATH}/trunk " +
5
+ "svn+ssh://rubyforge.org/var/svn/#{PATH}/tags/REL-#{VERS} "
6
+ puts "Suggested comment:"
7
+ puts "Tagging release #{CHANGES}"
8
+ end
9
+
10
+ desc 'Runs tasks website_generate and install_gem as a local deployment of the gem'
11
+ task :local_deploy => [:website_generate, :install_gem]
12
+
13
+ task :check_version do
14
+ unless ENV['VERSION']
15
+ puts 'Must pass a VERSION=x.y.z release version'
16
+ exit
17
+ end
18
+ unless ENV['VERSION'] == VERS
19
+ puts "Please update your version.rb to match the release version, currently #{VERS}"
20
+ exit
21
+ end
22
+ end
23
+
24
+ desc 'Install the package as a gem, without generating documentation(ri/rdoc)'
25
+ task :install_gem_no_doc => [:clean, :package] do
26
+ sh "#{'sudo ' unless Hoe::WINDOZE }gem install pkg/*.gem --no-rdoc --no-ri"
27
+ end
@@ -0,0 +1,7 @@
1
+ task :ruby_env do
2
+ RUBY_APP = if RUBY_PLATFORM =~ /java/
3
+ "jruby"
4
+ else
5
+ "ruby"
6
+ end unless defined? RUBY_APP
7
+ end
@@ -0,0 +1,17 @@
1
+ desc 'Generate website files'
2
+ task :website_generate => :ruby_env do
3
+ (Dir['website/**/*.txt'] - Dir['website/version*.txt']).each do |txt|
4
+ sh %{ #{RUBY_APP} script/txt2html #{txt} > #{txt.gsub(/txt$/,'html')} }
5
+ end
6
+ end
7
+
8
+ desc 'Upload website files to rubyforge'
9
+ task :website_upload do
10
+ host = "#{rubyforge_username}@rubyforge.org"
11
+ remote_dir = "/var/www/gforge-projects/#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
12
+ local_dir = 'website'
13
+ sh %{rsync -aCv #{local_dir}/ #{host}:#{remote_dir}}
14
+ end
15
+
16
+ desc 'Generate and upload website files'
17
+ task :website => [:website_generate, :website_upload, :publish_docs]
@@ -0,0 +1,25 @@
1
+ Test Literate Maruku Document
2
+ =============================
3
+
4
+ This contains some code examples, that are used for testing.
5
+
6
+ Normal markdown code environments are simply rendered
7
+
8
+ $this_code_block_will_not_be_executed = true
9
+
10
+ Annotated code environments are rendered and executed - in the root context.
11
+
12
+ $this_code_block_will_be_executed = true
13
+ {: execute}
14
+
15
+ Code definitions also work across code environments, of course.
16
+
17
+ a_test_method = lambda do |string|
18
+ string
19
+ end
20
+ {: execute}
21
+
22
+ And you may automatically attach the output of your code blocks.
23
+
24
+ a_test_method.call("a test string")
25
+ {: execute attach_output}
@@ -0,0 +1,2 @@
1
+ require 'test/unit'
2
+ require File.dirname(__FILE__) + '/../lib/literate_maruku'
@@ -0,0 +1,70 @@
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+
3
+ class TestMaRuKu < Test::Unit::TestCase
4
+ def test_should_not_execute_each_and_every_code_environment
5
+ doc = Maruku.new(%q{ THIS_CONSTANT_WILL_NOT_BE_DEFINED = true})
6
+
7
+ output = %q{
8
+ <pre><code>THIS_CONSTANT_WILL_NOT_BE_DEFINED = true</code></pre>
9
+ }
10
+
11
+ assert_equal output, doc.to_html
12
+ assert !Object.const_defined?("THIS_CONSTANT_WILL_NOT_BE_DEFINED")
13
+ end
14
+
15
+ def test_should_execute_code_with_metadata
16
+ doc = Maruku.new(%q{
17
+ TEST_WORKS = true
18
+ {: execute}})
19
+
20
+ output = %q{
21
+ <pre><code>TEST_WORKS = true</code></pre>
22
+ }
23
+
24
+ assert_equal output, doc.to_html
25
+ assert Object.const_defined?("TEST_WORKS")
26
+ assert TEST_WORKS
27
+ end
28
+
29
+ def test_should_attach_output_if_requested
30
+ doc = Maruku.new(%q{
31
+ 1 + 1 == 2
32
+ {: execute attach_output}})
33
+
34
+ output = %q{
35
+ <pre><code>1 + 1 == 2
36
+ &gt;&gt; true</code></pre>
37
+ }
38
+
39
+ assert_equal output, doc.to_html
40
+ end
41
+ end
42
+
43
+ class LiterateMarukuTest < Test::Unit::TestCase
44
+ def setup
45
+ @dirname = File.dirname(__FILE__)
46
+ @base_filename = "test_document"
47
+
48
+ @mkd_filename = @base_filename + ".mkd"
49
+ @html_filename = @base_filename + ".html"
50
+
51
+ @full_filename = File.join(@dirname, @html_filename)
52
+
53
+ File.delete(@full_filename) if File.exists?(@full_filename)
54
+ end
55
+
56
+ def teardown
57
+ File.delete(@full_filename) if File.exists?(@full_filename)
58
+ end
59
+
60
+ def test_require_should_execute_annotated_code_environments
61
+ LiterateMaruku.require(@mkd_filename)
62
+ assert $this_code_block_will_be_executed
63
+ end
64
+
65
+ def test_require_should_generate_an_html_file
66
+ LiterateMaruku.require(@mkd_filename, :output => @dirname)
67
+
68
+ assert File.exists?(@full_filename)
69
+ end
70
+ end
@@ -0,0 +1,209 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <link rel="stylesheet" href="stylesheets/screen.css" type="text/css" media="screen" />
6
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
7
+ <title>
8
+ literate_maruku
9
+ </title>
10
+ <script src="javascripts/rounded_corners_lite.inc.js" type="text/javascript"></script>
11
+ <style>
12
+
13
+ </style>
14
+ <script type="text/javascript">
15
+ window.onload = function() {
16
+ settings = {
17
+ tl: { radius: 10 },
18
+ tr: { radius: 10 },
19
+ bl: { radius: 10 },
20
+ br: { radius: 10 },
21
+ antiAlias: true,
22
+ autoPad: true,
23
+ validTags: ["div"]
24
+ }
25
+ var versionBox = new curvyCorners(settings, document.getElementById("version"));
26
+ versionBox.applyCornersToAll();
27
+ }
28
+ </script>
29
+ </head>
30
+ <body>
31
+ <div id="main">
32
+
33
+ <h1>literate_maruku</h1>
34
+ <div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/literate_maruku"; return false'>
35
+ <p>Get Version</p>
36
+ <a href="http://rubyforge.org/projects/literate_maruku" class="numbers">0.1.0</a>
37
+ </div>
38
+ <h1>&#x2192; &#8216;literate_maruku&#8217;</h1>
39
+
40
+
41
+ <h2>What</h2>
42
+
43
+
44
+ <p>Literate Maruku is a literate programming libary for ruby based on the markdown
45
+ libary maruku. This is basically what the name say, isn&#8217;t it?</p>
46
+
47
+
48
+ <h2>Installing</h2>
49
+
50
+
51
+ <p><pre class='syntax'><span class="ident">sudo</span> <span class="ident">gem</span> <span class="ident">install</span> <span class="ident">literate_maruku</span></pre></p>
52
+
53
+
54
+ <h2>The basics</h2>
55
+
56
+
57
+ <p>There are to possible accesses to the libary. A programming <span class="caps">API</span> and a command
58
+ line interface. The first may be used to write better documented tests,
59
+ for example. Just write a little bit of code in your test_helper and call
60
+ Literate Maruku there and your markdown formatted tests will be executed.</p>
61
+
62
+
63
+ <p>The command line interface may the be used inside of a rake task for example to
64
+ generate some html files out of your test files, that demonstrate their usage.
65
+ We have used this approach in ContextR, so have a look there to get some input.</p>
66
+
67
+
68
+ <h2>Demonstration of usage</h2>
69
+
70
+
71
+ <h3>The Markdown Syntax</h3>
72
+
73
+
74
+ <p>Literate Maruku simply extends the functionality of Maruku and adds some methods
75
+ to make standard use cases easier. You may find detailed information about maruku at <a href="http://maruku.rubyforge.org/">their project page</a> . They added some nice
76
+ features to
77
+ <a href="http://daringfireball.net/projects/markdown/syntax">Markdown formatting</a> , esp.
78
+ the <a href="http://maruku.rubyforge.org/proposal.html">meta data syntax</a> which made
79
+ implementing literate maruku a charm.</p>
80
+
81
+
82
+ <p>Wanna see examples? Okay, here they are:</p>
83
+
84
+
85
+ <h4>Markdown</h4>
86
+
87
+
88
+ <pre><code>
89
+ This is a normal paragraph, followed by a plain old code block
90
+
91
+ literate_maruku == maruku + ruby
92
+
93
+ And the following code block will not only be rendered, but also executed.
94
+
95
+ def echo_block(string)
96
+ (0...(text.size)).map{|i| text[0..i]}.reverse.join(" ... ")
97
+ end
98
+ {: execute}
99
+
100
+ And, finally, the following block will be executed and its output will be
101
+ rendered as well.
102
+
103
+ echo_block("hallo")
104
+ {: execute attach_output}
105
+ </code></pre>
106
+
107
+ <p>This is how you may write your ruby code. And this is what will be generated
108
+ out of it:</p>
109
+
110
+
111
+ <h4><span class="caps">HTML</span></h4>
112
+
113
+
114
+ <p>This is a normal paragraph, followed by a plain old code block</p>
115
+
116
+
117
+ <pre><code>literate_maruku == maruku + ruby
118
+ </code></pre>
119
+
120
+ <p>And the following code block will not only be rendered, but also executed.</p>
121
+
122
+
123
+ <pre><code>def echo_block(string)
124
+ (0...(text.size)).map{|i| text[0..i]}.reverse.join(" ... ")
125
+ end</code></pre>
126
+
127
+
128
+ <p>And, finally, the following block will be executed and its output will be
129
+ rendered as well.</p>
130
+
131
+
132
+ <pre><code>echo_block("hallo")
133
+ &gt;&gt; "hello ... hell ... hel ... he ... h"</code></pre>
134
+
135
+
136
+ <h3>The command line interface</h3>
137
+
138
+
139
+ <p>Simply call <code>literate_maruku filename.mkd</code> to load your markdown formatted ruby
140
+ files. This will execute the code but not generate any output. It basically works like a simpe <code>ruby filename.rb</code> call, but without all the command line parameters the <code>ruby</code> command supports.</p>
141
+
142
+
143
+ <p>If you like to generate some html files, append an additional parameter, which
144
+ tells literate_maruku where to put the output.
145
+ <code>literate_maruku --output_path=test filename.mkd</code> would file the output of
146
+ <code>filename.mkd</code> to <code>test/filename.html</code>. That&#8217;s all, folks.</p>
147
+
148
+
149
+ <h3>The programming interface</h3>
150
+
151
+
152
+ <p>To use Literate Maruku in your own special way simply use the
153
+ <code>LiterateMaruku#require</code> method.</p>
154
+
155
+
156
+ <pre><code>require 'literate_maruku'</code></pre>
157
+
158
+
159
+ <pre><code>LiterateMaruku.require('filename.mkd') # or
160
+ LiterateMaruku.require('filename.mkd', :output =&gt; "test")</code></pre>
161
+
162
+
163
+ <p>These will have the same result as the command line examples.</p>
164
+
165
+
166
+ <p>If you are unhappy with these little possibilities, no problem: You may still
167
+ use the standard maruku interface to do with your markdown string, what you like
168
+ after require&#8217;ing literate_maruku the maruku code base is extended for the
169
+ literate programming style.</p>
170
+
171
+
172
+ <h2>Other resources</h2>
173
+
174
+
175
+ <ul>
176
+ <li><a href="http://groups.google.com/group/rug-b">Mailing list</a></li>
177
+ <li><a href="http://rug-b.rubyforge.org/literate_maruku/rdoc">RDoc</a></li>
178
+ </ul>
179
+
180
+
181
+ <h2>How to submit patches</h2>
182
+
183
+
184
+ <p>Read the <a href="http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/">8 steps for fixing other people&#8217;s code</a> and for section <a href="http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/#8b-google-groups">8b: Submit patch to Google Groups</a>, use the Google Group above.</p>
185
+
186
+
187
+ <p>The trunk repository is <code>svn://rubyforge.org/var/svn/rug-b/literate_maruku/trunk</code> for anonymous access.</p>
188
+
189
+
190
+ <h2>License</h2>
191
+
192
+
193
+ <p>This code is free to use under the terms of the <span class="caps">MIT</span> license.</p>
194
+
195
+
196
+ <h2>Contact</h2>
197
+
198
+
199
+ <p>Comments are welcome. Send an email to <a href="mailto:ruby@schmidtwisser.de">Gregor Schmidt</a> or via the <a href="http://groups.google.com/group/literate_maruku">mailing list</a></p>
200
+ <p class="coda">
201
+ <a href="ruby@schmidtwisser.de">Gregor Schmidt</a>, 30th September 2007<br>
202
+ Theme extended from <a href="http://rb2js.rubyforge.org/">Paul Battley</a>
203
+ </p>
204
+ </div>
205
+
206
+ <!-- insert site tracking codes here, like Google Urchin -->
207
+
208
+ </body>
209
+ </html>
data/website/index.txt ADDED
@@ -0,0 +1,131 @@
1
+ h1. literate_maruku
2
+
3
+ h1. &#x2192; 'literate_maruku'
4
+
5
+
6
+ h2. What
7
+
8
+ Literate Maruku is a literate programming libary for ruby based on the markdown
9
+ libary maruku. This is basically what the name say, isn't it?
10
+
11
+
12
+ h2. Installing
13
+
14
+ <pre syntax="ruby">sudo gem install literate_maruku</pre>
15
+
16
+ h2. The basics
17
+
18
+ There are to possible accesses to the libary. A programming API and a command
19
+ line interface. The first may be used to write better documented tests,
20
+ for example. Just write a little bit of code in your test_helper and call
21
+ Literate Maruku there and your markdown formatted tests will be executed.
22
+
23
+ The command line interface may the be used inside of a rake task for example to
24
+ generate some html files out of your test files, that demonstrate their usage.
25
+ We have used this approach in ContextR, so have a look there to get some input.
26
+
27
+ h2. Demonstration of usage
28
+
29
+ h3. The Markdown Syntax
30
+
31
+ Literate Maruku simply extends the functionality of Maruku and adds some methods
32
+ to make standard use cases easier. You may find detailed information about maruku at "their project page":http://maruku.rubyforge.org/ . They added some nice
33
+ features to
34
+ "Markdown formatting":http://daringfireball.net/projects/markdown/syntax , esp.
35
+ the "meta data syntax":http://maruku.rubyforge.org/proposal.html which made
36
+ implementing literate maruku a charm.
37
+
38
+ Wanna see examples? Okay, here they are:
39
+
40
+ h4. Markdown
41
+
42
+ <pre><code>
43
+ This is a normal paragraph, followed by a plain old code block
44
+
45
+ literate_maruku == maruku + ruby
46
+
47
+ And the following code block will not only be rendered, but also executed.
48
+
49
+ def echo_block(string)
50
+ (0...(text.size)).map{|i| text[0..i]}.reverse.join(" ... ")
51
+ end
52
+ {: execute}
53
+
54
+ And, finally, the following block will be executed and its output will be
55
+ rendered as well.
56
+
57
+ echo_block("hallo")
58
+ {: execute attach_output}
59
+ </code></pre>
60
+
61
+ This is how you may write your ruby code. And this is what will be generated
62
+ out of it:
63
+
64
+ h4. HTML
65
+
66
+
67
+
68
+ This is a normal paragraph, followed by a plain old code block
69
+
70
+ <pre><code>literate_maruku == maruku + ruby
71
+ </code></pre>
72
+
73
+ And the following code block will not only be rendered, but also executed.
74
+
75
+ def echo_block(string)
76
+ (0...(text.size)).map{|i| text[0..i]}.reverse.join(" ... ")
77
+ end
78
+
79
+ And, finally, the following block will be executed and its output will be
80
+ rendered as well.
81
+
82
+ echo_block("hallo")
83
+ >> "hello ... hell ... hel ... he ... h"
84
+
85
+
86
+ h3. The command line interface
87
+
88
+ Simply call @literate_maruku filename.mkd@ to load your markdown formatted ruby
89
+ files. This will execute the code but not generate any output. It basically works like a simpe @ruby filename.rb@ call, but without all the command line parameters the @ruby@ command supports.
90
+
91
+ If you like to generate some html files, append an additional parameter, which
92
+ tells literate_maruku where to put the output.
93
+ @literate_maruku --output_path=test filename.mkd@ would file the output of
94
+ @filename.mkd@ to @test/filename.html@. That's all, folks.
95
+
96
+ h3. The programming interface
97
+
98
+ To use Literate Maruku in your own special way simply use the
99
+ @LiterateMaruku#require@ method.
100
+
101
+ require 'literate_maruku'
102
+
103
+ LiterateMaruku.require('filename.mkd') # or
104
+ LiterateMaruku.require('filename.mkd', :output => "test")
105
+
106
+ These will have the same result as the command line examples.
107
+
108
+ If you are unhappy with these little possibilities, no problem: You may still
109
+ use the standard maruku interface to do with your markdown string, what you like
110
+ after require'ing literate_maruku the maruku code base is extended for the
111
+ literate programming style.
112
+
113
+ h2. Other resources
114
+
115
+ * "Mailing list":http://groups.google.com/group/rug-b
116
+ * "RDoc":http://rug-b.rubyforge.org/literate_maruku/rdoc
117
+
118
+ h2. How to submit patches
119
+
120
+ Read the "8 steps for fixing other people's code":http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/ and for section "8b: Submit patch to Google Groups":http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/#8b-google-groups, use the Google Group above.
121
+
122
+ The trunk repository is <code>svn://rubyforge.org/var/svn/rug-b/literate_maruku/trunk</code> for anonymous access.
123
+
124
+ h2. License
125
+
126
+ This code is free to use under the terms of the MIT license.
127
+
128
+ h2. Contact
129
+
130
+ Comments are welcome. Send an email to "Gregor Schmidt":mailto:ruby@schmidtwisser.de or via the "mailing list":http://groups.google.com/group/literate_maruku
131
+