The cirros image was rebuilt against the 3.13.0-83 kernel, drivers e1000e, igbvf...
[packages/trusty/cirros-testvm.git] / cirros-testvm / src-cirros / buildroot-2015.05 / build / docs / manual / adding-packages-asciidoc.txt
1 // -*- mode:doc; -*-
2 // vim: syntax=asciidoc
3
4 === Infrastructure for asciidoc documents
5
6 [[asciidoc-documents-tutorial]]
7
8 The Buildroot manual, which you are currently reading, is entirely written
9 using the http://asciidoc.org/[AsciiDoc] mark-up syntax. The manual is then
10 rendered to many formats:
11
12 * html
13 * split-html
14 * pdf
15 * epub
16 * text
17
18 Although Buildroot only contains one document written in AsciiDoc, there
19 is, as for packages, an infrastructure for rendering documents using the
20 AsciiDoc syntax.
21
22 Also as for packages, the AsciiDoc infrastructure is available from
23 xref:outside-br-custom[BR2_EXTERNAL]. This allows documentation for a
24 BR2_EXTERNAL tree to match the Buildroot documentation, as it will be
25 rendered to the same formats and use the same layout and theme.
26
27 ==== +asciidoc-document+ tutorial
28
29 Whereas package infrastructures are suffixed with +-package+, the document
30 infrastructures are suffixed with +-document+. So, the AsciiDoc infrastructure
31 is named +asciidoc-document+.
32
33 Here is an example to render a simple AsciiDoc document.
34
35 ----
36 01: ################################################################################
37 02: #
38 03: # foo-document
39 04: #
40 05: ################################################################################
41 06:
42 07: FOO_SOURCES = $(sort $(wildcard $(pkgdir)/*))
43 08: $(eval $(call asciidoc-document))
44 ----
45
46 On line 7, the Makefile declares what the sources of the document are.
47 Currently, it is expected that the document's sources are only local;
48 Buildroot will not attempt to download anything to render a document.
49 Thus, you must indicate where the sources are. Usually, the string
50 above is sufficient for a document with no sub-directory structure.
51
52 On line 8, we call the +asciidoc-document+ function, which generates all
53 the Makefile code necessary to render the document.
54
55 ==== +asciidoc-document+ reference
56
57 The list of variables that can be set in a +.mk+ file to give metadata
58 information is (assuming the document name is +foo+) :
59
60 * +FOO_SOURCES+, mandatory, defines the source files for the document.
61
62 * +FOO_RESOURCES+, optional, may contain a space-separated list of paths
63   to one or more directories containing so-called resources (like CSS or
64   images). By default, empty.
65
66 There are also additional hooks (see xref:hooks[] for general information
67 on hooks), that a document may set to define extra actions to be done at
68 various steps:
69
70 * +FOO_POST_RSYNC_HOOKS+ to run additional commands after the sources
71   have been copied by Buildroot. This can for example be used to
72   generate part of the manual with information extracted from the
73   tree. As an example, Buildroot uses this hook to generate the tables
74   in the appendices.
75
76 * +FOO_CHECK_DEPENDENCIES_HOOKS+ to run additional tests on required
77   components to generate the document. In AsciiDoc, it is possible to
78   call filters, that is, programs that will parse an AsciiDoc block and
79   render it appropriately (e.g. http://ditaa.sourceforge.net/[ditaa] or
80   https://pythonhosted.org/aafigure/[aafigure]).
81
82 * +FOO_CHECK_DEPENDENCIES_<FMT>_HOOKS+, to run additional tests for
83   the specified format +<FMT>+ (see the list of rendered formats, above).
84
85 Here is a complete example that uses all variables and all hooks:
86
87 ----
88 01: ################################################################################
89 02: #
90 03: # foo-document
91 04: #
92 05: ################################################################################
93 06:
94 07: FOO_SOURCES = $(sort $(wildcard $(pkgdir)/*))
95 08: FOO_RESOURCES = $(sort $(wildcard $(pkgdir)/ressources))
96 09:
97 10: define FOO_GEN_EXTRA_DOC
98 11:     /path/to/generate-script --outdir=$(@D)
99 12: endef
100 13: FOO_POST_RSYNC_HOOKS += FOO_GEN_EXTRA_DOC
101 14:
102 15: define FOO_CHECK_MY_PROG
103 16:     if ! which my-prog >/dev/null 2>&1; then \
104 17:         echo "You need my-prog to generate the foo document"; \
105 18:         exit 1; \
106 19:     fi
107 20: endef
108 21: FOO_CHECK_DEPENDENCIES_HOOKS += FOO_CHECK_MY_PROG
109 22:
110 23: define FOO_CHECK_MY_OTHER_PROG
111 24:     if ! which my-other-prog >/dev/null 2>&1; then \
112 25:         echo "You need my-other-prog to generate the foo document as PDF"; \
113 26:         exit 1; \
114 27:     fi
115 28: endef
116 29: FOO_CHECK_DEPENDENCIES_PDF_HOOKS += FOO_CHECK_MY_OTHER_PROG
117 30:
118 31: $(eval $(call asciidoc-document))
119 ----