literate maruku

20
Literate Maruku www.rug -b.com/wiki/show/schmidt 2007-10-04

Upload: gregor-schmidt

Post on 03-Jul-2015

3.524 views

Category:

Technology


3 download

DESCRIPTION

Introductory talk on Literate Maruku, the first gem released by the Ruby User Group Berlin - rug-b.

TRANSCRIPT

Page 1: Literate Maruku

Literate Marukuwww.rug-b.com/wiki/show/schmidt

2007-10-04

Page 2: Literate Maruku

Literate Programming

Instead of imagining that our main task is to instruct a computer what to do, let us

concentrate rather on explaining to human beings what we want a computer to do.

--- Donald E. Knuth (1984)

Page 3: Literate Maruku

Implemented in

• WEB, CWEB, noweb

• (Pascal, C, any) Code embedded in LaTeX

• RubyWeb

• Extended RDoc syntax

• Literate Ruby (Ruby Quiz #102)

Page 4: Literate Maruku

but my problem was ...

Page 5: Literate Maruku

Primary use case

• Write documentation for a library

• Usage examples

• Tutorials

• How-Tos

Page 6: Literate Maruku

Primary use case

• Write documentation for a library

• Usage examples

• Tutorials

• How-Tos

Be sure that they work !

Make them tests !!!

Page 7: Literate Maruku

Some lines in test_helper.rb• For more information see

Executable code in usage examples (rubyurl.com/0fO)

# The String class provides a * method# which allows easy duplication.

example do output_of("bla" * 2) == "blabla" output_of("bla" * 3) == "blablabla"end

Page 8: Literate Maruku

Want that on a website?

Page 9: Literate Maruku

RDoc ???

Page 10: Literate Maruku

RDoc ???Annotates

methods and classes,

not blocks

Page 11: Literate Maruku

Literate Maruku

Page 12: Literate Maruku

Libraries and Names

• Maruku is as Markdown library for Ruby

• Markdown was originally done for Perl

• BlueCloth is the most popular implementation

• Maruku is better !!!

Page 13: Literate Maruku

MarkdownMarkdown Heading================

A paragraph is separated by \n\n.

* a bullet list

> a quote

a code block

Page 14: Literate Maruku

Maruku brings Meta data

Markdown Heading================

A paragraph is separated by \n\n.{: class=introduction}

This will be replaced with a table of contents...{: toc}

Page 15: Literate Maruku

Literate Maruku brings fun### String#*

The String class provides a `*` method which allows easy duplication.

example do output_of("bla" * 2) == "blabla" output_of("bla" * 3) == "blablabla" end{: execute}

string.mkd

Page 16: Literate Maruku

Literate Maruku brings fun### String#*

The String class provides a `*` method which allows easy duplication.

example do output_of("bla" * 2) == "blabla" output_of("bla" * 3) == "blablabla" end{: execute}

string.mkd

$ literate_maruku string.mkd# executes the file# like “ruby string.rb“ does

$ literate_maruku --output-dir=. string.mkd# executes the file # and generates string.html

Page 17: Literate Maruku

But ...No stack traces !

Page 18: Literate Maruku

Where can I get it?

$ gem install literate_maruku

rug-b.rubyforge.org/literate_maruku

Page 19: Literate Maruku

Example usage in ContextR

Page 20: Literate Maruku

???