1 .Dd $Mdocdate: December 14 2018 $
6 .Nd ordering of mandoc include files
8 To support a cleaner coding style, the mandoc header files do not
9 contain any include directives and do not guard against multiple
11 The application developer has to make sure that the headers are
12 included in a proper order, and that no header is included more
15 The headers and functions form three major groups:
16 .Sx Parser interface ,
17 .Sx Parser internals ,
19 .Sx Formatter interface .
21 Various rules are given below prohibiting the inclusion of certain
22 combinations of headers into the same file.
23 The intention is to keep the following functional components
24 separate from each other:
26 .Bl -dash -offset indent -compact
52 Note that mere usage of an opaque struct type does
54 require inclusion of the header where that type is defined.
56 Each of the following headers can be included without including
57 any other mandoc header.
58 These headers should be included before any other mandoc headers.
60 .It Qq Pa mandoc_aux.h
61 Memory allocation utility functions; can be used everywhere.
68 Provides the functions documented in
70 .It Qq Pa mandoc_ohash.h
71 Hashing utility functions; can be used everywhere.
85 .Fn mandoc_ohash_init .
87 Error handling, escape sequence, and character utilities;
88 can be used everywhere.
100 .Vt enum mandoc_esc ,
102 .Vt enum mandoclevel ,
104 .Xr mandoc_escape 3 ,
105 the functions described in
111 Common data types for all syntax trees and related functions;
112 can be used everywhere.
116 .Vt enum mdoc_endbody ,
117 .Vt enum roff_macroset ,
122 .Vt struct roff_man ,
123 .Vt struct roff_meta ,
124 .Vt struct roff_node ,
132 Uses pointers to the types
142 as opaque struct members.
144 Data structures for the
146 parse tree; can be used everywhere.
157 .Vt struct tbl_opts ,
158 .Vt struct tbl_cell ,
162 .Vt struct tbl_span .
164 Data structures for the
166 parse tree; can be used everywhere.
179 .It Qq Pa mandoc_parse.h
180 Top level parser interface, for use in the main program
181 and in the main parser, but not in formatters.
187 .Vt enum mandoclevel ,
199 for function prototypes.
204 as an opaque type for function prototypes.
205 .It Qq Pa mandoc_xr.h
206 Cross reference validation; intended for use in the main program
207 and in parsers, but not in formatters.
212 .Fn mandoc_xr_reset ,
219 The following two require
221 but no other mandoc headers.
222 Afterwards, any other mandoc headers can be included as needed.
236 .Vt struct mdoc_argv ,
237 .Vt struct mdoc_arg ,
243 .Vt union mdoc_data ,
253 as an opaque type for function prototypes.
255 When this header is included, the same file should not include
256 internals of different parsers.
258 Provides the functions
267 for function prototypes.
272 as an opaque type for function prototypes.
274 When this header is included, the same file should not include
275 internals of different parsers.
278 Most of the following headers require inclusion of a parser interface header
279 before they can be included.
280 All parser interface headers should precede all parser internal headers.
281 When any parser internal headers are included, the same file should
282 not include any formatter headers.
284 .It Qq Pa libmandoc.h
296 utility functions needed by multiple parsers,
297 and the top-level functions to call the parsers.
299 Uses the opaque types
307 for function prototypes.
312 as an opaque type for function prototypes.
314 Parser internals shared by multiple parsers.
315 Can be used in all parsers, but not in main programs or formatters.
324 Provides functions named
326 to handle roff nodes,
331 and the two special functions
335 because the latter two are needed by
348 as opaque types for function prototypes.
360 .Vt struct mdoc_macro ,
361 and many functions internal to the
375 as opaque types for function prototypes.
377 When this header is included, the same file should not include
378 interfaces of different parsers.
387 and some functions internal to the
397 as opaque types for function prototypes.
399 When this header is included, the same file should not include
400 interfaces of different parsers.
401 .It Qq Pa eqn_parse.h
402 External interface of the
404 parser, for use in the
431 for function prototypes.
436 as an opaque type for function prototypes.
445 as opaque struct members.
447 When this header is included, the same file should not include
448 internals of different parsers.
449 .It Qq Pa tbl_parse.h
450 External interface of the
452 parser, for use in the
458 Provides the functions documented in
473 as opaque types for function prototypes.
475 When this header is included, the same file should not include
476 internals of different parsers.
478 Internal interfaces of the
480 parser, for use inside the
487 .Vt struct tbl_opts .
491 .Vt struct tbl_node ,
500 Uses a pointer to the opaque type
504 as an opaque struct member.
506 When this header is included, the same file should not include
507 interfaces of different parsers.
509 .Ss Formatter interface
510 These headers should be included after any parser interface headers.
511 No parser internal headers should be included by the same file.
532 as an opaque type for function prototypes.
534 When this header is included, the same file should not include
552 .Vt struct termp_tbl ,
555 and many terminal formatting functions.
573 as opaque types for function prototypes.
575 When this header is included, the same file should not include
597 .Vt struct htmlpair ,
600 and many HTML formatting functions.
612 as opaque types for function prototypes.
614 When this header is included, the same file should not include
624 Provides an interface to generate
628 functionality mentioned in
631 Provides the top level steering functions for all formatters.
637 as an opaque type for function prototypes.
646 .Vt struct manpaths ,
647 .Vt struct manoutput ,
654 .It Qq Pa mansearch.h
667 .Vt struct mansearch ,
677 as an opaque type for function prototypes.
679 When this header is included, the same file should not include