Giter VIP home page Giter VIP logo

md-ruby-eval's Introduction

md-ruby-eval

Usage: #{$0} [options] --auto
       #{$0} [options] INPUT_FILE OUTPUT_FILE

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 it's result is not added to the output as a comment, which is useful for method and class definitions.

Example usage of --auto

  • cd doc_dir go to directory with documentation

  • ls list the files

    a.in.md
    a.init.rb
    b.in.md
    c.md
    
  • md-ruby-eval --auto call the tool

    • Creates files a.out.md and b.out.md evaluating each in isolated environments, before a.out.md is evaluated a.init.md is required to setup its environment. c.md is ignored since it does not have in marker.

md-ruby-eval's People

Contributors

pitr-ch avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.