1 .\" $Id: mandoc_headers.3,v 1.34 2021/08/10 12:55:03 schwarze Exp $
3 .\" Copyright (c) 2014-2021 Ingo Schwarze <schwarze@openbsd.org>
5 .\" Permission to use, copy, modify, and distribute this software for any
6 .\" purpose with or without fee is hereby granted, provided that the above
7 .\" copyright notice and this permission notice appear in all copies.
9 .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 .Dd $Mdocdate: August 10 2021 $
22 .Nd ordering of mandoc include files
24 To support a cleaner coding style, the mandoc header files do not
25 contain any include directives and do not guard against multiple
27 The application developer has to make sure that the headers are
28 included in a proper order, and that no header is included more
31 The headers and functions form three major groups:
32 .Sx Parser interface ,
33 .Sx Parser internals ,
35 .Sx Formatter interface .
37 Various rules are given below prohibiting the inclusion of certain
38 combinations of headers into the same file.
39 The intention is to keep the following functional components
40 separate from each other:
42 .Bl -dash -offset indent -compact
68 Note that mere usage of an opaque struct type does
70 require inclusion of the header where that type is defined.
72 Each of the following headers can be included without including
73 any other mandoc header.
74 These headers should be included before any other mandoc headers.
76 .It Qq Pa mandoc_aux.h
77 Memory allocation utility functions; can be used everywhere.
84 Provides the functions documented in
86 .It Qq Pa mandoc_ohash.h
87 Hashing utility functions; can be used everywhere.
101 .Fn mandoc_ohash_init .
103 Error handling, escape sequence, and character utilities;
104 can be used everywhere.
116 .Vt enum mandoc_esc ,
118 .Vt enum mandoclevel ,
120 .Xr mandoc_escape 3 ,
121 the functions described in
127 Common data types for all syntax trees and related functions;
128 can be used everywhere.
132 .Vt enum mdoc_endbody ,
133 .Vt enum roff_macroset ,
137 .Vt struct roff_man ,
138 .Vt struct roff_meta ,
139 .Vt struct roff_node ,
145 Uses pointers to the types
148 .Qq Pa mandoc_ohash.h ,
161 as opaque struct members.
163 Data structures for the
165 parse tree; can be used everywhere.
174 .Vt enum mandoc_esc .
180 .Vt struct tbl_opts ,
181 .Vt struct tbl_cell ,
185 .Vt struct tbl_span .
187 Data structures for the
189 parse tree; can be used everywhere.
202 .It Qq Pa mandoc_parse.h
203 Top level parser interface, for use in the main program
204 and in the main parser, but not in formatters.
221 for function prototypes.
226 as an opaque type for function prototypes.
227 .It Qq Pa mandoc_xr.h
228 Cross reference validation; intended for use in the main program
229 and in parsers, but not in formatters.
234 .Fn mandoc_xr_reset ,
240 Internal interfaces to tag syntax tree nodes,
241 for use by validation modules only.
248 Provides the functions
262 as an opaque type for function prototypes.
265 The following two require
267 but no other mandoc headers.
268 Afterwards, any other mandoc headers can be included as needed.
282 .Vt struct mdoc_argv ,
283 .Vt struct mdoc_arg ,
289 .Vt union mdoc_data ,
303 as opaque types for function prototypes.
305 When this header is included, the same file should not include
306 internals of different parsers.
308 Provides the functions
317 as an opaque type for function prototypes.
319 When this header is included, the same file should not include
320 internals of different parsers.
323 Most of the following headers require inclusion of a parser interface header
324 before they can be included.
325 All parser interface headers should precede all parser internal headers.
326 When any parser internal headers are included, the same file should
327 not include any formatter headers.
329 .It Qq Pa libmandoc.h
341 utility functions needed by multiple parsers,
342 and the top-level functions to call the parsers.
348 for function prototypes.
353 as an opaque type for function prototypes.
355 Parser internals shared by multiple parsers.
356 Can be used in all parsers, but not in main programs or formatters.
367 .Vt struct roff_man ,
370 to handle roff nodes,
376 and the two special functions
380 because the latter two are needed by
386 .Qq Pa mandoc_ohash.h ,
399 as opaque types for function prototypes.
411 .Vt struct mdoc_macro ,
412 and many functions internal to the
427 as opaque types for function prototypes.
429 When this header is included, the same file should not include
430 interfaces of different parsers.
439 and some functions internal to the
451 as opaque types for function prototypes.
453 When this header is included, the same file should not include
454 interfaces of different parsers.
455 .It Qq Pa eqn_parse.h
456 External interface of the
458 parser, for use in the
485 as an opaque type for function prototypes.
494 as opaque struct members.
496 When this header is included, the same file should not include
497 internals of different parsers.
498 .It Qq Pa tbl_parse.h
499 External interface of the
501 parser, for use in the
507 Provides the functions documented in
518 as opaque types for function prototypes.
520 When this header is included, the same file should not include
521 internals of different parsers.
523 Internal interfaces of the
525 parser, for use inside the
532 .Vt struct tbl_opts .
536 .Vt struct tbl_node ,
545 When this header is included, the same file should not include
546 interfaces of different parsers.
548 .Ss Formatter interface
549 These headers should be included after any parser interface headers.
550 No parser internal headers should be included by the same file.
571 as an opaque type for function prototypes.
573 When this header is included, the same file should not include
591 .Vt struct termp_tbl ,
594 and many terminal formatting functions.
612 as opaque types for function prototypes.
614 When this header is included, the same file should not include
628 Provides an interface to generate
632 functionality mentioned in
639 as an opaque type for function prototypes.
641 When this header is included, the same file should not include
652 .Vt enum mandoc_esc ,
669 .Vt struct htmlpair ,
672 and many HTML formatting functions.
684 as opaque types for function prototypes.
686 When this header is included, the same file should not include
692 Provides the top level steering functions for all formatters.
698 as an opaque type for function prototypes.
707 .Vt struct manpaths ,
708 .Vt struct manoutput ,
715 .It Qq Pa mansearch.h
728 .Vt struct mansearch ,
738 as an opaque type for function prototypes.
740 When this header is included, the same file should not include