1 .\" $Id: mandoc_headers.3,v 1.31 2019/03/17 18:21:45 schwarze Exp $
3 .\" Copyright (c) 2014-2019 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 17 2019 $
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 ,
237 The following two require
239 but no other mandoc headers.
240 Afterwards, any other mandoc headers can be included as needed.
254 .Vt struct mdoc_argv ,
255 .Vt struct mdoc_arg ,
261 .Vt union mdoc_data ,
275 as opaque types for function prototypes.
277 When this header is included, the same file should not include
278 internals of different parsers.
280 Provides the functions
289 as an opaque type for function prototypes.
291 When this header is included, the same file should not include
292 internals of different parsers.
295 Most of the following headers require inclusion of a parser interface header
296 before they can be included.
297 All parser interface headers should precede all parser internal headers.
298 When any parser internal headers are included, the same file should
299 not include any formatter headers.
301 .It Qq Pa libmandoc.h
313 utility functions needed by multiple parsers,
314 and the top-level functions to call the parsers.
320 for function prototypes.
325 as an opaque type for function prototypes.
327 Parser internals shared by multiple parsers.
328 Can be used in all parsers, but not in main programs or formatters.
339 .Vt struct roff_man ,
342 to handle roff nodes,
348 and the two special functions
352 because the latter two are needed by
358 .Qq Pa mandoc_ohash.h ,
371 as opaque types for function prototypes.
383 .Vt struct mdoc_macro ,
384 and many functions internal to the
399 as opaque types for function prototypes.
401 When this header is included, the same file should not include
402 interfaces of different parsers.
411 and some 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.
427 .It Qq Pa eqn_parse.h
428 External interface of the
430 parser, for use in the
457 as an opaque type for function prototypes.
466 as opaque struct members.
468 When this header is included, the same file should not include
469 internals of different parsers.
470 .It Qq Pa tbl_parse.h
471 External interface of the
473 parser, for use in the
479 Provides the functions documented in
490 as opaque types for function prototypes.
492 When this header is included, the same file should not include
493 internals of different parsers.
495 Internal interfaces of the
497 parser, for use inside the
504 .Vt struct tbl_opts .
508 .Vt struct tbl_node ,
517 When this header is included, the same file should not include
518 interfaces of different parsers.
520 .Ss Formatter interface
521 These headers should be included after any parser interface headers.
522 No parser internal headers should be included by the same file.
543 as an opaque type for function prototypes.
545 When this header is included, the same file should not include
563 .Vt struct termp_tbl ,
566 and many terminal formatting functions.
584 as opaque types for function prototypes.
586 When this header is included, the same file should not include
597 .Vt enum mandoc_esc ,
614 .Vt struct htmlpair ,
617 and many HTML formatting functions.
629 as opaque types for function prototypes.
631 When this header is included, the same file should not include
641 Provides an interface to generate
645 functionality mentioned in
648 Provides the top level steering functions for all formatters.
654 as an opaque type for function prototypes.
663 .Vt struct manpaths ,
664 .Vt struct manoutput ,
671 .It Qq Pa mansearch.h
684 .Vt struct mansearch ,
694 as an opaque type for function prototypes.
696 When this header is included, the same file should not include