1 .Dd $Mdocdate: December 30 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 ,
121 .Vt struct roff_man ,
122 .Vt struct roff_meta ,
123 .Vt struct roff_node ,
129 Uses pointers to the types
145 as opaque struct members.
147 Data structures for the
149 parse tree; can be used everywhere.
160 .Vt struct tbl_opts ,
161 .Vt struct tbl_cell ,
165 .Vt struct tbl_span .
167 Data structures for the
169 parse tree; can be used everywhere.
182 .It Qq Pa mandoc_parse.h
183 Top level parser interface, for use in the main program
184 and in the main parser, but not in formatters.
201 for function prototypes.
206 as an opaque type for function prototypes.
207 .It Qq Pa mandoc_xr.h
208 Cross reference validation; intended for use in the main program
209 and in parsers, but not in formatters.
214 .Fn mandoc_xr_reset ,
221 The following two require
223 but no other mandoc headers.
224 Afterwards, any other mandoc headers can be included as needed.
238 .Vt struct mdoc_argv ,
239 .Vt struct mdoc_arg ,
245 .Vt union mdoc_data ,
259 as opaque types for function prototypes.
261 When this header is included, the same file should not include
262 internals of different parsers.
264 Provides the functions
273 as an opaque type for function prototypes.
275 When this header is included, the same file should not include
276 internals of different parsers.
279 Most of the following headers require inclusion of a parser interface header
280 before they can be included.
281 All parser interface headers should precede all parser internal headers.
282 When any parser internal headers are included, the same file should
283 not include any formatter headers.
285 .It Qq Pa libmandoc.h
297 utility functions needed by multiple parsers,
298 and the top-level functions to call the parsers.
304 for function prototypes.
309 as an opaque type for function prototypes.
311 Parser internals shared by multiple parsers.
312 Can be used in all parsers, but not in main programs or formatters.
323 .Vt struct roff_man ,
326 to handle roff nodes,
332 and the two special functions
336 because the latter two are needed by
355 as opaque types for function prototypes.
367 .Vt struct mdoc_macro ,
368 and many functions internal to the
383 as opaque types for function prototypes.
385 When this header is included, the same file should not include
386 interfaces of different parsers.
395 and some functions internal to the
407 as opaque types for function prototypes.
409 When this header is included, the same file should not include
410 interfaces of different parsers.
411 .It Qq Pa eqn_parse.h
412 External interface of the
414 parser, for use in the
441 as an opaque type for function prototypes.
450 as opaque struct members.
452 When this header is included, the same file should not include
453 internals of different parsers.
454 .It Qq Pa tbl_parse.h
455 External interface of the
457 parser, for use in the
463 Provides the functions documented in
474 as opaque types for function prototypes.
476 When this header is included, the same file should not include
477 internals of different parsers.
479 Internal interfaces of the
481 parser, for use inside the
488 .Vt struct tbl_opts .
492 .Vt struct tbl_node ,
501 When this header is included, the same file should not include
502 interfaces of different parsers.
504 .Ss Formatter interface
505 These headers should be included after any parser interface headers.
506 No parser internal headers should be included by the same file.
527 as an opaque type for function prototypes.
529 When this header is included, the same file should not include
547 .Vt struct termp_tbl ,
550 and many terminal formatting functions.
568 as opaque types for function prototypes.
570 When this header is included, the same file should not include
581 .Vt enum mandoc_esc ,
595 .Vt struct htmlpair ,
598 and many HTML formatting functions.
610 as opaque types for function prototypes.
612 When this header is included, the same file should not include
622 Provides an interface to generate
626 functionality mentioned in
629 Provides the top level steering functions for all formatters.
635 as an opaque type for function prototypes.
644 .Vt struct manpaths ,
645 .Vt struct manoutput ,
652 .It Qq Pa mansearch.h
665 .Vt struct mansearch ,
675 as an opaque type for function prototypes.
677 When this header is included, the same file should not include