2 // vim: syntax=asciidoc
4 === Infrastructure for asciidoc documents
6 [[asciidoc-documents-tutorial]]
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:
18 Although Buildroot only contains one document written in AsciiDoc, there
19 is, as for packages, an infrastructure for rendering documents using the
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.
27 ==== +asciidoc-document+ tutorial
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+.
33 Here is an example to render a simple AsciiDoc document.
36 01: ################################################################################
40 05: ################################################################################
42 07: FOO_SOURCES = $(sort $(wildcard $(pkgdir)/*))
43 08: $(eval $(call asciidoc-document))
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.
52 On line 8, we call the +asciidoc-document+ function, which generates all
53 the Makefile code necessary to render the document.
55 ==== +asciidoc-document+ reference
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+) :
60 * +FOO_SOURCES+, mandatory, defines the source files for the document.
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.
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
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
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]).
82 * +FOO_CHECK_DEPENDENCIES_<FMT>_HOOKS+, to run additional tests for
83 the specified format +<FMT>+ (see the list of rendered formats, above).
85 Here is a complete example that uses all variables and all hooks:
88 01: ################################################################################
92 05: ################################################################################
94 07: FOO_SOURCES = $(sort $(wildcard $(pkgdir)/*))
95 08: FOO_RESOURCES = $(sort $(wildcard $(pkgdir)/ressources))
97 10: define FOO_GEN_EXTRA_DOC
98 11: /path/to/generate-script --outdir=$(@D)
100 13: FOO_POST_RSYNC_HOOKS += FOO_GEN_EXTRA_DOC
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"; \
108 21: FOO_CHECK_DEPENDENCIES_HOOKS += FOO_CHECK_MY_PROG
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"; \
116 29: FOO_CHECK_DEPENDENCIES_PDF_HOOKS += FOO_CHECK_MY_OTHER_PROG
118 31: $(eval $(call asciidoc-document))