Skip to content

Commit 9a2b7b1

Browse files
committed
wrap all long lines
I couldn't make it work without removing GFM cfrom _config.yml but apparently it isn't needed anyway.
1 parent f97efe7 commit 9a2b7b1

File tree

4 files changed

+51
-25
lines changed

4 files changed

+51
-25
lines changed

_config.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
name: mruby
22
markdown: kramdown
3-
kramdown:
4-
input: GFM
53
highlighter: pygments
64
exclude:
75
- Gemfile

_posts/2014-02-09-mruby-1.0.0-released.markdown

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ categories: releases
88
mruby 1.0.0 released
99
====================
1010

11-
The first release of mruby is now available. Download [mruby 1.0.0][mruby-1.0.0-dl] now.
11+
The first release of mruby is now available.
12+
Download [mruby 1.0.0][mruby-1.0.0-dl] now.
1213

1314
[mruby-1.0.0-dl]: https://github.com/mruby/mruby/archive/1.0.0.zip

docs/articles/executing-ruby-code-with-mruby.md

Lines changed: 44 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@ categories: articles
88

99
**originally written by [Daniel Bovensiepen](http://bovensiepen.net/)**
1010

11-
The traditional way to execute Ruby code is distributing the plain source code and requiring a Ruby interpreter with lots of files to be installed. mruby can be used like that too. So if you have experience with another Ruby implementation you may know some of the examples listed here. However with mruby you can also build standalone programs and compileto bytecode which can be dumped and loaded.
11+
The traditional way to execute Ruby code is distributing the plain source code
12+
and requiring a Ruby interpreter with lots of files to be installed.
13+
mruby can be used like that too. So if you have experience with
14+
another Ruby implementation you may know some of the examples listed here.
15+
However with mruby you can also build standalone programs and compile to
16+
bytecode which can be dumped and loaded.
1217

1318
A file called `test_program.rb` is used in some of the examples. Its content is:
1419

@@ -18,7 +23,8 @@ puts 'hello world'
1823

1924
## REPL (mirb)
2025

21-
Not exactly directly used for program execution but still, Ruby code can be evaluated by using the `mirb` program:
26+
Not exactly directly used for program execution but still,
27+
Ruby code can be evaluated by using the `mirb` program:
2228

2329
~~~
2430
$ mruby/bin/mirb
@@ -35,11 +41,13 @@ hello world
3541

3642
✘ not usable for productive execution
3743

38-
✘ the input needs to be parsed twice: first `mirb` checks if the code is complete and afterwards `mirb` compiles it into bytecode and executes it
44+
✘ the input needs to be parsed twice: first `mirb` checks if the code is
45+
complete and afterwards `mirb` compiles it into bytecode and executes it
3946

4047
## Source code (.rb)
4148

42-
The probably most common way to run Ruby code is by passing a filename as argument to an interpreter. In mruby that's the `mruby` program:
49+
The probably most common way to run Ruby code is by passing a filename as
50+
argument to an interpreter. In mruby that's the `mruby` program:
4351

4452
~~~
4553
$ mruby/bin/mruby test_program.rb
@@ -58,7 +66,8 @@ hello world
5866

5967
## Source code (.c)
6068

61-
Ruby code can also be written as a C string. This is similar to the `-e` switch of the `mruby` program.
69+
Ruby code can also be written as a C string. This is similar to
70+
the `-e` switch of the `mruby` program.
6271

6372
~~~c
6473
#include "mruby.h"
@@ -69,7 +78,7 @@ main(void)
6978
{
7079
mrb_state *mrb = mrb_open();
7180
if (!mrb) { /* handle error */ }
72-
// mrb_load_nstring() for strings without null terminator or known length
81+
// mrb_load_nstring() for strings without null terminator or with known length
7382
mrb_load_string(mrb, "puts 'hello world'");
7483
mrb_close(mrb);
7584
}
@@ -78,7 +87,8 @@ main(void)
7887
To compile and link:
7988
8089
~~~
81-
$ gcc -std=c99 -Imruby/include test_program.c -o test_program test_program.o mruby/build/host/lib/libmruby.a
90+
$ gcc -std=c99 -Imruby/include test_program.c -o test_program
91+
test_program.o mruby/build/host/lib/libmruby.a
8292
~~~
8393
8494
To execute:
@@ -90,27 +100,31 @@ hello world
90100
91101
### Pros & Cons
92102
93-
✔ simple development cycle: programming → compiling (`gcc`) → testing → programming
103+
✔ simple development cycle:
104+
programming → compiling (`gcc`) → testing → programming
94105
95106
✔ the program is fully standalone
96107
97108
✘ additional boilerplate is needed to get the program up and running
98109
99110
✘ Ruby code has to be parsed and compiled to bytecode before its execution
100111
101-
✘ updating the Ruby code might require a recompilation of the C code or an advanced updating mechanism
112+
✘ updating the Ruby code might require a recompilation of the C code or
113+
an advanced updating mechanism
102114
103115
## Bytecode (.mrb)
104116
105-
mruby provides a Java-like execution style by compiling to an intermediate representation form which then will be executed.
117+
mruby provides a Java-like execution style by compiling to an
118+
intermediate representation form which then will be executed.
106119
107120
The first step is to compile source code to bytecode with the `mrbc` program:
108121
109122
~~~
110123
$ mruby/bin/mrbc test_program.rb
111124
~~~
112125
113-
This will produce a file called `test_program.mrb` which contains the intermediate representation of the previously given Ruby code:
126+
This will produce a file called `test_program.mrb` which contains the
127+
intermediate representation of the previously given Ruby code:
114128
115129
~~~
116130
$ hexdump -C test_program.mrb
@@ -124,7 +138,9 @@ $ hexdump -C test_program.mrb
124138
00000065
125139
~~~
126140
127-
This file can be executed by the `mruby` program or the `mrb_load_irep_file()` function. The `-b` switch tells the program that the file is binary rather than plain Ruby code:
141+
This file can be executed by the `mruby` program or the `mrb_load_irep_file()`
142+
function. The `-b` switch tells the program that the file is binary rather than
143+
plain Ruby code:
128144
129145
~~~
130146
$ mruby/bin/mruby -b test_program.mrb
@@ -139,21 +155,25 @@ hello world
139155
140156
✔ bytecode can easily be updated by replacing the file
141157
142-
✘ complex development cycle: programming → compiling (`mrbc`) → testing (`mruby`) → programming
158+
✘ complex development cycle:
159+
programming → compiling (`mrbc`) → testing (`mruby`) → programming
143160
144161
✘ the `mruby` program and a file system is required
145162
146163
## Bytecode (.c)
147164
148-
This variant is interesting for those who want to integrate Ruby code directly into their C code. It will create a C array containg the bytecode which you then have to execute by yourself.
165+
This variant is interesting for those who want to integrate Ruby code directly
166+
into their C code. It will create a C array containg the bytecode which you
167+
then have to execute by yourself.
149168
150-
The first step is to compile the Ruby program. This is done by using `mrbc` and its `-B` switch. An identifier for the array also has to be given:
169+
The first step is to compile the Ruby program. This is done by using `mrbc`
170+
and its `-B` switch. An identifier for the array also has to be given:
151171
152172
~~~
153173
$ mruby/bin/mrbc -Btest_symbol test_program.rb
154174
~~~
155175
156-
This will create a C file called `test_program.c` containing the `test_symbol` array:
176+
This creates a file called `test_program.c` containing the `test_symbol` array:
157177
158178
~~~c
159179
/* dumped in little endian order.
@@ -176,7 +196,8 @@ test_symbol[] = {
176196
};
177197
~~~
178198

179-
To execute this bytecode the following boilerplate has to be written. It reads the array and executes the bytecode immediately:
199+
To execute this bytecode the following boilerplate has to be written.
200+
It reads the array and executes the bytecode immediately:
180201

181202
~~~c
182203
#include "mruby.h"
@@ -195,7 +216,8 @@ main(void)
195216
To compile and link:
196217
197218
~~~
198-
$ gcc -std=c99 -Imruby/include test_program.c -o test_program test_program.o mruby/build/host/lib/libmruby.a
219+
$ gcc -std=c99 -Imruby/include test_program.c -o test_program
220+
test_program.o mruby/build/host/lib/libmruby.a
199221
~~~
200222
201223
To execute:
@@ -213,9 +235,10 @@ hello world
213235
214236
✔ the program is fully standalone
215237
216-
✘ even more complex development cycle: programming → compiling (`mrbc`) → integrating C code → compiling (`gcc`) → testing → programming
238+
✘ even more complex development cycle: programming → compiling (`mrbc`) →
239+
integrating C code → compiling (`gcc`) → testing → programming
217240
218241
✘ additional boilerplate is needed to get the program up and running
219242
220-
✘ updating the bytecode requires a recompilation of the C code or an advanced updating mechanism
221-
243+
✘ updating the bytecode requires a recompilation of the C code or
244+
an advanced updating mechanism

docs/index.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ title: mruby - docs
55

66
# Documentation
77

8-
At the moment the source code ([`mruby/doc/`](https://github.com/mruby/mruby/tree/master/doc)) includes further documentation about compiling, configurating (`mrbconf`), debugging (`mrdb`), and extending (`mrbgems`) mruby.
8+
At the moment the source code ([`mruby/doc/`][mruby-doc]) includes further
9+
documentation about compiling, configurating (`mrbconf`), debugging (`mrdb`),
10+
and extending (`mrbgems`) mruby.
11+
12+
[mruby-doc]: https://github.com/mruby/mruby/tree/master/doc
913

1014
## Articles
1115

0 commit comments

Comments
 (0)