1 .Dd $Mdocdate: December 13 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 utilities and top level parser interface;
88 can be used everywhere.
98 .Vt enum mandoclevel ,
100 the function prototype typedef
103 .Xr mandoc_escape 3 ,
104 the functions described in
115 for function prototypes.
120 as an opaque type for function prototypes.
122 Data structures for the
124 parse tree; can be used everywhere.
135 .Vt struct tbl_opts ,
136 .Vt struct tbl_cell ,
140 .Vt struct tbl_span .
142 Data structures for the
144 parse tree; can be used everywhere.
157 .It Qq Pa mandoc_xr.h
158 Cross reference validation; intended for use in the main program
159 and in parsers, but not in formatters.
164 .Fn mandoc_xr_reset ,
171 .Qq Pa mandoc_ohash.h
180 .Vt enum mdoc_endbody ,
181 .Vt enum roff_macroset ,
186 .Vt struct roff_man ,
187 .Vt struct roff_meta ,
188 .Vt struct roff_node ,
199 Uses pointers to the types
205 as opaque struct members.
208 The following two require
210 but no other mandoc headers.
211 Afterwards, any other mandoc headers can be included as needed.
225 .Vt struct mdoc_argv ,
226 .Vt struct mdoc_arg ,
232 .Vt union mdoc_data ,
242 as an opaque type for function prototypes.
244 When this header is included, the same file should not include
245 internals of different parsers.
247 Provides the functions
256 for function prototypes.
261 as an opaque type for function prototypes.
263 When this header is included, the same file should not include
264 internals of different parsers.
267 Most of the following headers require inclusion of a parser interface header
268 before they can be included.
269 All parser interface headers should precede all parser internal headers.
270 When any parser internal headers are included, the same file should
271 not include any formatter headers.
273 .It Qq Pa libmandoc.h
285 utility functions needed by multiple parsers,
286 and the top-level functions to call the parsers.
288 Uses the opaque types
296 for function prototypes.
301 as an opaque type for function prototypes.
308 Provides functions named
310 to handle roff nodes and the two special functions
314 because the latter two are needed by
327 as opaque types for function prototypes.
343 .Vt struct mdoc_macro ,
344 and many functions internal to the
358 as opaque types for function prototypes.
360 When this header is included, the same file should not include
361 interfaces of different parsers.
370 and some functions internal to the
380 as opaque types for function prototypes.
382 When this header is included, the same file should not include
383 interfaces of different parsers.
384 .It Qq Pa eqn_parse.h
385 External interface of the
387 parser, for use in the
414 for function prototypes.
419 as an opaque type for function prototypes.
428 as opaque struct members.
430 When this header is included, the same file should not include
431 internals of different parsers.
432 .It Qq Pa tbl_parse.h
433 External interface of the
435 parser, for use in the
441 Provides the functions documented in
456 as opaque types for function prototypes.
458 When this header is included, the same file should not include
459 internals of different parsers.
461 Internal interfaces of the
463 parser, for use inside the
470 .Vt struct tbl_opts .
474 .Vt struct tbl_node ,
483 Uses a pointer to the opaque type
487 as an opaque struct member.
489 When this header is included, the same file should not include
490 interfaces of different parsers.
492 .Ss Formatter interface
493 These headers should be included after any parser interface headers.
494 No parser internal headers should be included by the same file.
515 as an opaque type for function prototypes.
517 When this header is included, the same file should not include
535 .Vt struct termp_tbl ,
538 and many terminal formatting functions.
556 as opaque types for function prototypes.
558 When this header is included, the same file should not include
580 .Vt struct htmlpair ,
583 and many HTML formatting functions.
595 as opaque types for function prototypes.
597 When this header is included, the same file should not include
607 Provides an interface to generate
611 functionality mentioned in
614 Provides the top level steering functions for all formatters.
620 as an opaque type for function prototypes.
629 .Vt struct manpaths ,
630 .Vt struct manoutput ,
637 .It Qq Pa mansearch.h
650 .Vt struct mansearch ,
660 as an opaque type for function prototypes.
662 When this header is included, the same file should not include