1 .\" $Id: mandoc_headers.3,v 1.33 2020/03/13 15:32:28 schwarze Exp $
3 .\" Copyright (c) 2014-2020 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: March 13 2020 $
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.
176 .Vt struct tbl_opts ,
177 .Vt struct tbl_cell ,
181 .Vt struct tbl_span .
183 Data structures for the
185 parse tree; can be used everywhere.
198 .It Qq Pa mandoc_parse.h
199 Top level parser interface, for use in the main program
200 and in the main parser, but not in formatters.
217 for function prototypes.
222 as an opaque type for function prototypes.
223 .It Qq Pa mandoc_xr.h
224 Cross reference validation; intended for use in the main program
225 and in parsers, but not in formatters.
230 .Fn mandoc_xr_reset ,
236 Internal interfaces to tag syntax tree nodes,
237 for use by validation modules only.
244 Provides the functions
258 as an opaque type for function prototypes.
261 The following two require
263 but no other mandoc headers.
264 Afterwards, any other mandoc headers can be included as needed.
278 .Vt struct mdoc_argv ,
279 .Vt struct mdoc_arg ,
285 .Vt union mdoc_data ,
299 as opaque types for function prototypes.
301 When this header is included, the same file should not include
302 internals of different parsers.
304 Provides the functions
313 as an opaque type for function prototypes.
315 When this header is included, the same file should not include
316 internals of different parsers.
319 Most of the following headers require inclusion of a parser interface header
320 before they can be included.
321 All parser interface headers should precede all parser internal headers.
322 When any parser internal headers are included, the same file should
323 not include any formatter headers.
325 .It Qq Pa libmandoc.h
337 utility functions needed by multiple parsers,
338 and the top-level functions to call the parsers.
344 for function prototypes.
349 as an opaque type for function prototypes.
351 Parser internals shared by multiple parsers.
352 Can be used in all parsers, but not in main programs or formatters.
363 .Vt struct roff_man ,
366 to handle roff nodes,
372 and the two special functions
376 because the latter two are needed by
382 .Qq Pa mandoc_ohash.h ,
395 as opaque types for function prototypes.
407 .Vt struct mdoc_macro ,
408 and many functions internal to the
423 as opaque types for function prototypes.
425 When this header is included, the same file should not include
426 interfaces of different parsers.
435 and some functions internal to the
447 as opaque types for function prototypes.
449 When this header is included, the same file should not include
450 interfaces of different parsers.
451 .It Qq Pa eqn_parse.h
452 External interface of the
454 parser, for use in the
481 as an opaque type for function prototypes.
490 as opaque struct members.
492 When this header is included, the same file should not include
493 internals of different parsers.
494 .It Qq Pa tbl_parse.h
495 External interface of the
497 parser, for use in the
503 Provides the functions documented in
514 as opaque types for function prototypes.
516 When this header is included, the same file should not include
517 internals of different parsers.
519 Internal interfaces of the
521 parser, for use inside the
528 .Vt struct tbl_opts .
532 .Vt struct tbl_node ,
541 When this header is included, the same file should not include
542 interfaces of different parsers.
544 .Ss Formatter interface
545 These headers should be included after any parser interface headers.
546 No parser internal headers should be included by the same file.
567 as an opaque type for function prototypes.
569 When this header is included, the same file should not include
587 .Vt struct termp_tbl ,
590 and many terminal formatting functions.
608 as opaque types for function prototypes.
610 When this header is included, the same file should not include
624 Provides an interface to generate
628 functionality mentioned in
635 as an opaque type for function prototypes.
637 When this header is included, the same file should not include
648 .Vt enum mandoc_esc ,
665 .Vt struct htmlpair ,
668 and many HTML formatting functions.
680 as opaque types for function prototypes.
682 When this header is included, the same file should not include
688 Provides the top level steering functions for all formatters.
694 as an opaque type for function prototypes.
703 .Vt struct manpaths ,
704 .Vt struct manoutput ,
711 .It Qq Pa mansearch.h
724 .Vt struct mansearch ,
734 as an opaque type for function prototypes.
736 When this header is included, the same file should not include