summaryrefslogtreecommitdiffstats
path: root/README.md
blob: dbf1c8a18c0d12a3fdea085021469054e5bf5a80 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
GitBook
=======

GiBook is a command line tool (and Node.js library) for building beautiful programming books and exercises using GitHub/Git and Markdown. You can see an example: [Learn Javascript](http://gitbookio.github.io/javascript/).

## How to use it:

GitBook can be installed from **NPM** using:

```
$ npm install gitbook -g
```

You can serve a repository as a book using:

```
$ gitbook serve ./repository
```

Or simply build the static website using:

```
$ gitbook build ./repository --output=./outputFolder
```

Options for commands `build` and `serve` are:

```
-t, --title <name> Name of the book to generate, defaults to repo name
-i, --intro <intro> Description of the book to generate
-g, --github <repo_path> ID of github repo like : username/repo
```

## Book Format

A book is a GitHub repository containing at least 2 files: `README.md` and `SUMMARY.md`.

#### README.md

As usual, it should contains an introduction for your book. It will be automatically added to the final summary.

#### SUMMARY.md

The `SUMMARY.md` is used for getting the complete summary of the book. It should contains a list of items (deep items are allowed) with links to the different pages.

Example:

```
# Summary

This is the summary of my book.

* [section 1](section1/README.md)
    * [example 1](section1/example1.md)
    * [example 2](section1/example2.md)
* [section 2](section2/README.md)
    * [example 1](section2/example1.md)
```

All the other content than the summary list will be ignored.

#### Exercises

A book can contains interactive exercises (currently only in Javascript but Python and Ruby are coming soon ;) ).

An exercise is defined by 3 different parts:

* Exercise Message/Goals (in markdown/text)
* Base code to show to the user
* Solution to show to the user when he gives up
* Validation code for testing the result of the user input

Exercises are defined in the markdown using the following format:


---

Define a variable `c` as the modulus of the decremented value of `x` by 3.

```js
var x = 10;

var c = 
```

```js
var x = 10;

var c = (x--) % 3;
```

```js
assert(c == 1);
```

---