md-ruby-eval
Usage: md-ruby-eval [options] --auto
md-ruby-eval [options] INPUT_FILE OUTPUT_FILE
md-ruby-eval --help
Evaluates Ruby examples in MD files.
It looks for code blocks starting with '```ruby'. The blocks are evaluated in same order as they appear in the markdown file. Each top_level parseable piece of code is evaluated and the value is added as a comment, e.g.:
# Title
First evaluated block:
```ruby
a = 1 + 2
def a; :a; end #
[a,
:b]
```
Continuing in next block
```ruby
a
```
becomes
# Title
First evaluated block:
```ruby
a = 1 + 2 # => 3
def a; :a; end
[a,
:b] # => [:a,:b]
```
Continuing in next block
```ruby
a # => 3
```
A parseable piece of code ended with '#' will be evaluated but its result is not added to the output as a comment, which is useful for method and class definitions.
Example usage of --auto
-
cd doc_dirgo to directory with documentation -
lslist the filesa.in.md a.init.rb b.in.rb c.md -
md-ruby-eval --autocall the toolCreates files
a.out.mdandb.out.rbevaluating each in isolated environments, beforea.out.mdis evaluateda.init.mdis required to setup its environment.c.mdis ignored since it does not haveinmarker.