-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.zd
613 lines (457 loc) · 18.2 KB
/
README.zd
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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
Zerodoc
=======
Version 0.2.3 Last updated 2014-08-17 [email protected]
Zerodoc is a "plain text format" in the spirit of `asciidoc`, `POD`,
`reStructuredText` or `markdown`, with an emphasis on simplicity and
extensibility. Very few formatting options are avaliable, both to
keep the parser simple and to make it easy to write new generators
for the whole format.
Included are a Python library can be used to translate an input
file or buffer into a tree that for wich generators can be easily
written, and a command line tool to call existing generators for
HTML, reStructuredText (that can then be converted or integrated
with other tools like Sphinx) and a JSON intermediate representation.
Table of contents
- 1. The zerodoc format
- 1.1 Paragraphs and lines
- 1.2 Lists
- 1.3 Formatting attributes
- 1.4 Links
- 1.5 Source code
- 1.6 Diagrams and images
- 1.6.1 ASCIIToSVG ascii-art diagrams
- 1.6.2 aafigure ascii-art diagrams
- 1.6.3 ditaa ascii-art diagrams
- 1.6.4 TikZ diagrams
- 1.7 Definition lists
- 1.8 The default zerodoc structure
- 1.8.1 Header
- 1.8.1.1 Title
- 1.8.1.2 Abstract
- 1.8.1.3 Table of contents
- 1.8.2 Body
- 2. Installing zerodoc
- 2.1 Prerrequisites
- 2.2 Installing the library and interpreter
- 2.2.1 Using a git snapshot
- 2.2.2 Using pypi
- 3. Using the command line converter
- 3.1 SYNOPSIS
- 3.2 HTML output options
- 3.3 reStructuredText output options
- 3.4 JSON output options
- 3.5 Confluence output options
1. THE ZERODOC FORMAT
1.1 PARAGRAPHS AND LINES
Zerodoc files are simple text files organized in paragraphs. A
paragraph is a group of text lines separated from other paragraphs
by blank lines. Lists and source code copied *verbatim* can be
defined. An unintrusive format for links is used, based on
a references system.
Lines are limited to 72 characters for regular (not code
or diagrams) text. If you need to put something more into a line
(for example, a long URL), divide it in two and put a backslash (\)
with no spaces at the end.
Example:
This is a very long url that needs to be splitted in three:
http://www.reallyreallyreallylonguniformresourcelocatorredir\
ection.com/redirectionator.php?theredirectioncode=d72a565ab8\
7dedf7b5fa84b3ec4b9f11
Renders into:
This is a very long url that needs to be splitted in three:
http://www.reallyreallyreallylonguniformresourcelocatorredir\
ection.com/redirectionator.php?theredirectioncode=d72a565ab8\
7dedf7b5fa84b3ec4b9f11
1.2 LISTS
Lists are defined as paragrahps prefixed with a dash, and can be
nested. Example
- The first element in a list
- A nested element into the first consisting of two lines
that are joined on output
- Another nested element
- The third element in a list
Renders into:
- The first element in a list
- A nested element into the first consisting of two lines
that are joined on output
- Another nested element
- The third element in a list
Backslash joining also occur inside list elements:
- The first element in a list. as it have two lines
with no backslash, an space is inserted between 'lines' and 'with'
- To join the two lines without adding a space a back\
slash is used. Note that the two spaces formatting the listline are
removed
renders into:
- The first element in a list. as it have two lines
with no backslash, an space is inserted between 'lines' and 'with'
- To join the two lines without adding a space a back\
slash is used. Note that the two spaces formatting the listline are
removed after the backslash
NOTE: There are no numbered lists. In the "phylosophy" of zerodoc,
numbers can not be omited from the original text nor 'computed'
because that will make the text less readable than it's processed
output.
1.3 FORMATTING ATTRIBUTES
Some attributes for the text inherited from other common formats and
email conventions are supported:
- This is an *emphasis*
- This is an _underline_ (cursive on certain displays or formats,
as in manual pages)
- This is a 'cursive'
Renders into:
- This is an *emphasis*
- This is an _underline_ (cursive on certain displays or formats,
as in manual pages)
- This is a 'cursive'
1.4 LINKS
Links can be included directly in the text along with their destination,
or referenced first in the text and then 'resolved' in another line.
Source of a link:
This `link`:http://www.google.com will redirect to google
Will render as:
This `link`:http://www.google.com will redirect to google
Referenced links are 'resolved' in lists of links. This lists of links
will be removed from output directly. If the list is contained in a
section alone, the section is also removed from output. See the
'References' section at the end of the source code of this document
for an example. An 'autocontained' example could be:
This line contains two referenced links: `firstlink` and `secondlink`
- `firstlink`:http://www.google.com
- `secondlink`:http://www.google.com
Wich renders into:
This line contains two referenced links: `firstlink` and `secondlink`
- `firstlink`:http://www.google.com
- `secondlink`:http://www.google.com
1.5 SOURCE CODE
Source code is text that will be included verbatim in the output. In
source code, newlines are meaningful and no limits on line-length are
imposed. An example:
#include <stdio.h>
int main() {
// print hello world 100 times
for (int i = 0; i < 100; i++) {
printf("Hello, world!\n");
}
}
Source code is identified by one space before the content of
the first line and one or more spaces in the rest. No tabs can
be used, so either transform tabs-only source code before pasting
or use a tool like expand(1) to do it for you. Blank lines are also
included verbatim, up to the one delimiting the next 'regular'
paragraph (one that contains text and starts on the first column)
To illustrate source code, i am going to paste the source code (yo
dawg) of the example above, along with the regular paragraph-lines
sorrounding it:
source code, newlines are meaningful and no limits on line-length are
imposed. An example:
#include <stdio.h>
int main() {
// print hello world 100 times
for (int i = 0; i < 100; i++) {
printf("Hello, world!\n");
}
}
Source code is identified by one space before the content of
the first line and one or more spaces in the rest. No tabs can
When pygmentize is used, the default language for syntax highlighting
can be specified in options.
1.6 DIAGRAMS AND IMAGES
Diagrams can be either included directly in the output, just as
source code, or optionally converted to images (when this is
possible, for example in a manual page it does not make sense to
include images). Diagrams are converted using ditaa, aafigure,
ascii2svg or tikz depending on the options parsed to the renderer.
Refer to the `aafigure manual page` or to the `ditaa website` for
help on this formats.
Diagrams are recognized by using TWO or more spaces before the
first line of them. Anything up to the next 'regular' paragraph
is considered part of the diagram.
Source-code paragraphs and diagrams can not be adjacent; they need
a 'regular' text paragraph (starting on the first column) between
them. This makes sense since no diagram can follow source code or
viceversa without at least an introduction of what the reader is
seeing.
1.6.1 ASCIITOSVG ASCII-ART DIAGRAMS
The default for ascii art diagrams is `asciitosvg`. As it name implies,
it converts text to SVG wich is quite convenient. It is written in php.
Example diagram: (asciitosvg)
This is an asciitosvg diagram
.-------------------------.
|[Logo] |
| .---.-. .-----. .-----. |
| | .-. | +--> | | <--| |
| | '-' | | <--| +--> | |
| '---'-' '-----' '-----' |
| ascii 2 svg |
| |
'-------------------------'
https://9vx.org/~dho/a2s/
[Logo]: {"fill":"#88d","a2s:delref":true}
1.6.2 AAFIGURE ASCII-ART DIAGRAMS
Another format to convert ascii art diagrams to graphics is aafigure. it
is written in Python and have quite convenient idioms for things like
sequence diagrams:
Example diagram: (aafigure)
+---------+ +---------+ +---------+
|Object 1 | |Object 2 | |Object 3 |
+----+----+ +----+----+ +----+----+
| | |
| | |
X Example | |
X----------->X |
X X |
X<-----------X |
X | |
X Example | |
X------------------------>X
| | X
X----------->X X---+
X X X |
| | X<--+
X<------------------------X
X | |
| | |
| | |
1.6.3 DITAA ASCII-ART DIAGRAMS
Another common format for ascii art diagrams is ditaa. It does not
support svg output.
This is the source code of the following paragraph
(diagram taken from the `ditaa website`:
Example diagram: (ditaa)
+--------+ +-------+ +-------+
| | --+ ditaa +--> | |
| Text | +-------+ |diagram|
|Document| |!magic!| | |
| {d}| | | | |
+---+----+ +-------+ +-------+
: ^
| Lots of work |
+-------------------------+
This is the source code of the following paragraph
(diagram taken from the `ditaa website`:
Example diagram: (ditaa)
+--------+ +-------+ +-------+
| | --+ ditaa +--> | |
| Text | +-------+ |diagram|
|Document| |!magic!| | |
| {d}| | | | |
+---+----+ +-------+ +-------+
: ^
| Lots of work |
+-------------------------+
Note that there are two spaces before the first +---
1.6.4 TIKZ DIAGRAMS
A Tikz diagram (from the Tikz examples)
\begin{tikzpicture}[auto,node distance=3cm,
thick,main node/.style={circle,fill=blue!20,draw,
font=\sffamily\Large\bfseries}]
\node[main node] (1) {1};
\node[main node] (2) [below left of=1] {2};
\node[main node] (3) [below right of=2] {3};
\node[main node] (4) [below right of=1] {4};
\path[every node/.style={font=\sffamily\small}]
(1) edge node [left] {0.6} (4)
edge [bend right] node[left] {0.3} (2)
edge [loop above] node {0.1} (1)
(2) edge node [right] {0.4} (1)
edge node {0.3} (4)
edge [loop left] node {0.4} (2)
edge [bend right] node[left] {0.1} (3)
(3) edge node [right] {0.8} (2)
edge [bend right] node[right] {0.2} (4)
(4) edge node [left] {0.2} (3)
edge [loop right] node {0.6} (4)
edge [bend right] node[right] {0.2} (1);
\end{tikzpicture}
LaTeX source code for that Tikz chunk:
\begin{tikzpicture}[auto,node distance=3cm,
thick,main node/.style={circle,fill=blue!20,draw,
font=\sffamily\Large\bfseries}]
\node[main node] (1) {1};
\node[main node] (2) [below left of=1] {2};
\node[main node] (3) [below right of=2] {3};
\node[main node] (4) [below right of=1] {4};
\path[every node/.style={font=\sffamily\small}]
(1) edge node [left] {0.6} (4)
edge [bend right] node[left] {0.3} (2)
edge [loop above] node {0.1} (1)
(2) edge node [right] {0.4} (1)
edge node {0.3} (4)
edge [loop left] node {0.4} (2)
edge [bend right] node[left] {0.1} (3)
(3) edge node [right] {0.8} (2)
edge [bend right] node[right] {0.2} (4)
(4) edge node [left] {0.2} (3)
edge [loop right] node {0.6} (4)
edge [bend right] node[right] {0.2} (1);
\end{tikzpicture}
1.6.6 Diagram tagging and autodetection
As with source code, the type of diagram is autodetected for Tikz and
gnuplot diagrams. This detection can be overriden by specifing it in
the first line of the diagram, between parenthesis.
1.7 DEFINITION LISTS
A definition list is a list of terms and corresponding definitions.
It usually renders (in HTML, man pages, ReST) in the text of the
definition indented with respect to the title. It is useful for
documenting functions and command line parameters.
Following is an example:
man ls
Display the manual page for the item (program) ls.
man -a intro
Display, in succession, all of the available intro manual
pages contained within the manual. It is possible
to quit between successive displays or skip any of them.
that renders into:
man ls
Display the manual page for the item (program) ls.
man -a intro
Display, in succession, all of the available intro manual
pages contained within the manual. It is possible
to quit between successive displays or skip any of them.
1.8 THE DEFAULT ZERODOC STRUCTURE
1.8.1 HEADER
The header in a zerodoc document contains the title, an optional
abstract and a table of contents. The table of contents needs to
be updated by hand (this is different from other well known text
formats but allow zerodoc to have free-form titles (no --- nor
~~~ nor any other form of markup is needed):
This is the title, that can spawn several
lines
This are one or several paragraphs of abstract
1. Title 1
2. Title 2
1.8.1.1 TITLE
The title can spawn several lines (a whole paragraph) that will be
joined together on output
The table of contents can be prefixed by a 'Table of conents' line
that will be recognized automatically as the TOC title. If that line
is not present, it will also be ommited on the transformed output.
1.8.1.2 ABSTRACT
The abstract is a group of paragraphs that appear before the Table
of content.
1.8.1.3 TABLE OF CONTENTS
The table of contents is a list of the titles of the different
sections, for example
- 1. Section one
- 2. Section two
- 3. Third section
Will define the table of contents of a document, if found in the
header (after the abstract). If a title listed here is not found
in the document, an error is yielded.
1.8.2 BODY
The body is formed by several paragraphs. Paragraphs are divided
into sections by lines with titles. The lines with titles should
appear in the TOC and should have the same content as the TOC.
Optionally they can be in uppercase for clarity. As the transformed
document usually will have better ways to emphasize the title,
the lowercase format used in the TOC will be used regardless of
uppercase being used. For example, the next section of this document
starts with
2. INSTALLING ZERODOC
2.1 Prerrequisites
And in the TOC the pertinent lines appear as:
-- toc fragment --
- 1.7.1.3 Table of contents
- 1.7.2 Body
- 2. Installing zerodoc
- 2.1 Prerrequisites
As you can see on the start of the next section, the title appears
in lowercase (as in the TOC above)
2. INSTALLING ZERODOC
2.1 PRERREQUISITES
Zerodoc needs Python (2.6 or newer) the Python PLY 'lex and yacc'
utilities (2.5 or newer) and distutils for installation. Aditionally
when generating diagrams, the programs to parse them need to be
installed as well.
As an example, in a GNU/Linux Debian 6.0 'Squeeze' system, the
requirements can be installed using:
# apt-get install python-ply python-aafigure ditaa
To generate diagrams with gnuplot or tikz, install the pertinent
packages
# apt-get install gnuplot
# apt-get install texlive-picture
2.2 INSTALLING THE LIBRARY AND INTERPRETER
2.2.1 USING A GIT SNAPSHOT
Clone the github repository using
$ git clone git://github.com/odkq/zerodoc.git
Change to the zerodoc dir and call setup.py as root
$ cd zerodoc/
$ sudo ./setup.py install
2.2.2 USING PYPI
3. USING THE COMMAND LINE CONVERTER
zerodoc - converts a zerodoc text file to HTML and many
other formats
3.1 SYNOPSIS
Usage: zerodoc [options]
Options:
-h, --help
show this help message and exit
-f FORMAT, --format=FORMAT
Output format. If ommited, 'html'
-o OPTIONS, --options=OPTIONS
Options for format renderer
-i FILE, --input=FILE
Use <filename> as input file. If ommited, use
stdin.
-O FILE, --output=FILE
Use <filename> as output file. If ommited,use
stdout.
3.2 HTML OUTPUT OPTIONS
ditaa
Use ditaa to format diagrams. When this option
is used, you can specify the path of the ditaa
.jar file with jarpath:<path>. If jarpath is
ommited, 'ditta' will be called (you can install
a command-line ditta wraper in Debian and others
with apt-get install ditaa)
jarpath:<path>
Location of the .jar path (there is no default,
'java' must be in the $PATH)
aafigure
Use aafigure to format diagrams
svg
Prefer svg in output when applicable (when the
converter outputs it and when the rendered format allows
for scalable graphics)
datauri
Do not generate image files, embbed the images
directly in the HTML using `DataURIscheme`
3.3 reStructuredText output options
notoc
Usually `reStructuredText` processors attach their own index in the
side (`sphinx-doc`, for example). In that case, you better do not
output the toc (it is still used to get section titles)
3.4 JSON OUTPUT OPTIONS
Json output has no options. It's output is the json render of the
parsed tree with no interpretation whatsoever
3.5 CONFLUENCE OUTPUT OPTIONS
ditaa, jarpath, aafigure, datauri
With the same meaning as in the HTML output options
You can specify an output file, and paste it by hand into
the confluence 'edition' formulary, or you can make zerodoc client
upload it directly with this options:
folder:<folder>
Folder (path) for the uploaded document
user:<user>
User to use
passwd:<passd>
Password
host:<host>
Host
- `DataURIscheme`:http://en.wikipedia.org/wiki/Data_URI_scheme
- `git`:http://git-scm.com/
- `POD`:http://search.cpan.org/dist/perl/pod/perlpod.pod
- `markdown`:http://daringfireball.net/projects/markdown/
- `orgmode`:http://orgmode.org/
- `creole`:http://wikicreole.org/
- `mediawiki`:http://www.mediawiki.org/wiki/Help:Formatting
- `reST`:http://docutils.sourceforge.net/rst.html
- `asciidoc`:http://www.methods.co.nz/asciidoc/
- `rdoc`:http://rdoc.sourceforge.net/
- `textile`:http://www.textism.com/tools/textile/index.php
- `aafigure manual page`:http://packages.python.org/aafigure/manual.html
- `asciitosvg`:https://9vx.org/~dho/a2s/
- `ditaa website`:http://ditaa.sourceforge.net/
- `reStructuredText`:http://docutils.sourceforge.net/rst.html
- `sphinx-doc`:http://sphinx-doc.org/