-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathabout_nimibook.nim
227 lines (201 loc) Β· 4.33 KB
/
about_nimibook.nim
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
import nimib, nimislides
import our
template sectionSlide* =
slide:
nbText """
## Intro to Nimibook
"""
template what* =
autoAnimateSlides(14):
showUntil(9):
nbText "### What is Nimibook ππ"
showAt(2..4):
nbText "nimib works for single documents"
showAt(3..4):
nbText "how do we show a collection of documents?"
showAt(4):
nbText "enter Nimibook!"
showAt(5..8, 10, 11):
nbText "Nimibook is"
showAt(6..9):
nbText "1. a minimal **static site generator** for nimib"
showAt(7..9):
nbText "2. implemented using **theme** feature of nimib"
showAt(8..11):
nbText "3. a port of [mdbook]()"
showAt(10..11):
nbText "so..."
showFrom(11):
nbText "### What is mdbook"
showFrom(12):
nbText "1. a popular **static site generator** (π¦)"
showFrom(13):
nbText "2. with a single book 'theme'"
showFrom(14):
nbText "3. and with minimal customization"
template mdbookExample* =
slide:
nbText "### a mdbook example"
slide:
nbImage("nimdays.png")
nbText "[xmonader.github.io/nimdays](https://xmonader.github.io/nimdays/day16_asciitables.html)"
slide:
nbText """### SUMMARY.MD
```md
# Nim Days
Documenting my days with The Nim Programming language.
- [Intro](book_intro.md)
- [Day 1 DMIDecode](day01_dmidecode.md)
- [Day 2: Parsing Bencode](day02_bencode.md)
- [Day 3: FFI and Libmagic](day03_libmagic.md)
- ...
```
"""
slide:
nbText """### content.MD
````md
or let nim decide for you
```nim
t.tableWidth = 0
printTable(t)
```
```
+---+-------+---------+
|ID |Name |Date |
+---+-------+---------+
|1 |Aaaa |2018-10-2|
+---+-------+---------+
```
````
"""
template nimibookExample* =
slide:
nbText "### A nimibook example"
slide:
nbImage("scinim.png")
nbText "[scinim.github.io/getting-started](https://scinim.github.io/getting-started/basics/basic_plotting.html)"
slide:
nbText """### `toc.nim`
```nim
import nimibook
var book = initBookWithToc:
entry("Introduction", "index.md")
entry("Ecosystem overview", "overview/index.md")
section("Basic topics", "basics/index.md"):
entry("Common datatypes", "common_datatypes")
entry("Data wrangling with dataframes", "data_wrangling")
entry("Plotting", "basic_plotting")
...
nimibookCli(book)
```
"""
slide:
nbText """### `content.nim`
```nim
import nimib, nimibook
nbInit(theme = useNimibook)
nbCode:
import ggplotnim
let x1 = @[0.0, 1.0, 2.0, 3.0]
let y1 = @[0.0, 1.0, 4.0, 9.0]
let df1 = toDf(x1, y1)
ggplot(df1, aes("x1", "y1")) +
geom_line() +
ggsave("images/line_plot.png")
nbImage("images/line_plot.png")
```
"""
template howIstart* =
slide:
nbText "### How I start"
autoAnimateSlides(4):
nbText "#### `nim r toc init`"
showAt(1):
nbText """
In a new folder create a `toc.nim` file:
```nim
import nimibook
var book = initBookWithToc:
entry("Introduction", "index.md")
entry("Example", "example")
nimibookCli(book)
```
"""
nbTextSmall "you can pick any name instead of `toc` (e.g `nbook`, ...)"
showAt(2):
nbText """
result:
```
.
βββ book
β βββ example.nim
β βββ index.md
βββ docs
β βββ assets
β βββ ...
βββ nimib.toml
βββ toc.nim
```
"""
showAt(3):
nbText """
`example.nim`:
```nim
import nimib, nimibook
nbInit(theme = useNimibook)
nbText: "## Example"
nbSave
```
"""
showAt(4):
nbText """
`nimib.toml`:
```toml
[nimib]
srcDir = "book"
homeDir = "docs"
[nimibook]
language = "en-us"
title = "My book"
description = "a book built with nimibook"
```
"""
slide:
nbText "#### `nim r toc build`"
nbText """
result:
```
.
βββ book
β βββ example.nim
β βββ index.md
βββ docs
β βββ assets
β β βββ ...
β βββ book.json
β βββ example.html
β βββ index.html
βββ nimib.toml
βββ toc.nim
```
"""
slide:
nbText "[pietroppeter.github.io/nimibook](https://pietroppeter.github.io/nimibook/cli.html)"
nbImage "nimibook.png"
template howIcontribute* =
slide:
nbText "### How I contribute"
template all* =
sectionSlide
slide:
what
mdbookExample
slide:
nimibookExample
slide:
howIstart
#howIcontribute
when isMainModule:
myInit("about_nimibook")
all
nbSave