]> git.cameronkatri.com Git - mandoc.git/blob - mandoc_headers.3
Cleanup, no functional change:
[mandoc.git] / mandoc_headers.3
1 .Dd $Mdocdate: December 13 2018 $
2 .Dt MANDOC_HEADERS 3
3 .Os
4 .Sh NAME
5 .Nm mandoc_headers
6 .Nd ordering of mandoc include files
7 .Sh DESCRIPTION
8 To support a cleaner coding style, the mandoc header files do not
9 contain any include directives and do not guard against multiple
10 inclusion.
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
13 than once.
14 .Pp
15 The headers and functions form three major groups:
16 .Sx Parser interface ,
17 .Sx Parser internals ,
18 and
19 .Sx Formatter interface .
20 .Pp
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:
25 .Pp
26 .Bl -dash -offset indent -compact
27 .It
28 .Xr roff 7
29 parser
30 .It
31 .Xr mdoc 7
32 parser
33 .It
34 .Xr man 7
35 parser
36 .It
37 .Xr tbl 7
38 parser
39 .It
40 .Xr eqn 7
41 parser
42 .It
43 terminal formatters
44 .It
45 HTML formatters
46 .It
47 search tools
48 .It
49 main programs
50 .El
51 .Pp
52 Note that mere usage of an opaque struct type does
53 .Em not
54 require inclusion of the header where that type is defined.
55 .Ss Parser interface
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.
59 .Bl -tag -width Ds
60 .It Qq Pa mandoc_aux.h
61 Memory allocation utility functions; can be used everywhere.
62 .Pp
63 Requires
64 .In sys/types.h
65 for
66 .Vt size_t .
67 .Pp
68 Provides the functions documented in
69 .Xr mandoc_malloc 3 .
70 .It Qq Pa mandoc_ohash.h
71 Hashing utility functions; can be used everywhere.
72 .Pp
73 Requires
74 .In stddef.h
75 for
76 .Vt ptrdiff_t
77 and
78 .In stdint.h
79 for
80 .Vt uint32_t .
81 .Pp
82 Includes
83 .In ohash.h
84 and provides
85 .Fn mandoc_ohash_init .
86 .It Qq Pa mandoc.h
87 Error handling utilities and top level parser interface;
88 can be used everywhere.
89 .Pp
90 Requires
91 .In sys/types.h
92 for
93 .Vt size_t .
94 .Pp
95 Provides
96 .Vt enum mandoc_esc ,
97 .Vt enum mandocerr ,
98 .Vt enum mandoclevel ,
99 .Vt enum mandoc_os ,
100 the function prototype typedef
101 .Fn mandocmsg ,
102 the function
103 .Xr mandoc_escape 3 ,
104 the functions described in
105 .Xr mchars_alloc 3 ,
106 and the functions
107 .Fn mparse_*
108 described in
109 .Xr mandoc 3 .
110 .Pp
111 Uses the opaque type
112 .Vt struct mparse
113 from
114 .Pa read.c
115 for function prototypes.
116 Uses the type
117 .Vt struct roff_man
118 from
119 .Pa roff.h
120 as an opaque type for function prototypes.
121 .It Qq Pa tbl.h
122 Data structures for the
123 .Xr tbl 7
124 parse tree; can be used everywhere.
125 .Pp
126 Requires
127 .In sys/types.h
128 for
129 .Vt size_t .
130 .Pp
131 Provides
132 .Vt enum tbl_cellt ,
133 .Vt enum tbl_datt ,
134 .Vt enum tbl_spant ,
135 .Vt struct tbl_opts ,
136 .Vt struct tbl_cell ,
137 .Vt struct tbl_row ,
138 .Vt struct tbl_dat ,
139 and
140 .Vt struct tbl_span .
141 .It Qq Pa eqn.h
142 Data structures for the
143 .Xr eqn 7
144 parse tree; can be used everywhere.
145 .Pp
146 Requires
147 .In sys/types.h
148 for
149 .Vt size_t .
150 .Pp
151 Provides
152 .Vt enum eqn_boxt ,
153 .Vt enum eqn_fontt ,
154 .Vt enum eqn_post ,
155 and
156 .Vt struct eqn_box .
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.
160 .Pp
161 Provides
162 .Vt struct mandoc_xr
163 and the functions
164 .Fn mandoc_xr_reset ,
165 .Fn mandoc_xr_add ,
166 .Fn mandoc_xr_get ,
167 and
168 .Fn mandoc_xr_free .
169 .It Qq Pa roff.h
170 Requires
171 .Qq Pa mandoc_ohash.h
172 for
173 .Vt struct ohash
174 and
175 .Qq Pa mandoc.h
176 for
177 .Vt enum mandoc_os .
178 .Pp
179 Provides
180 .Vt enum mdoc_endbody ,
181 .Vt enum roff_macroset ,
182 .Vt enum roff_next ,
183 .Vt enum roff_sec ,
184 .Vt enum roff_tok ,
185 .Vt enum roff_type ,
186 .Vt struct roff_man ,
187 .Vt struct roff_meta ,
188 .Vt struct roff_node ,
189 the constant array
190 .Va roff_name
191 and the functions
192 .Fn deroff ,
193 .Fn roffhash_alloc ,
194 .Fn roffhash_find ,
195 .Fn roffhash_free ,
196 and
197 .Fn roff_validate .
198 .Pp
199 Uses pointers to the types
200 .Vt struct mdoc_arg
201 and
202 .Vt union mdoc_data
203 from
204 .Pa mdoc.h
205 as opaque struct members.
206 .El
207 .Pp
208 The following two require
209 .Qq Pa roff.h
210 but no other mandoc headers.
211 Afterwards, any other mandoc headers can be included as needed.
212 .Bl -tag -width Ds
213 .It Qq Pa mdoc.h
214 Requires
215 .In sys/types.h
216 for
217 .Vt size_t .
218 .Pp
219 Provides
220 .Vt enum mdocargt ,
221 .Vt enum mdoc_auth ,
222 .Vt enum mdoc_disp ,
223 .Vt enum mdoc_font ,
224 .Vt enum mdoc_list ,
225 .Vt struct mdoc_argv ,
226 .Vt struct mdoc_arg ,
227 .Vt struct mdoc_an ,
228 .Vt struct mdoc_bd ,
229 .Vt struct mdoc_bf ,
230 .Vt struct mdoc_bl ,
231 .Vt struct mdoc_rs ,
232 .Vt union mdoc_data ,
233 and the functions
234 .Fn mdoc_*
235 described in
236 .Xr mandoc 3 .
237 .Pp
238 Uses the type
239 .Vt struct roff_man
240 from
241 .Pa roff.h
242 as an opaque type for function prototypes.
243 .Pp
244 When this header is included, the same file should not include
245 internals of different parsers.
246 .It Qq Pa man.h
247 Provides the functions
248 .Fn man_*
249 described in
250 .Xr mandoc 3 .
251 .Pp
252 Uses the opaque type
253 .Vt struct mparse
254 from
255 .Pa read.c
256 for function prototypes.
257 Uses the type
258 .Vt struct roff_man
259 from
260 .Pa roff.h
261 as an opaque type for function prototypes.
262 .Pp
263 When this header is included, the same file should not include
264 internals of different parsers.
265 .El
266 .Ss Parser internals
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.
272 .Bl -tag -width Ds
273 .It Qq Pa libmandoc.h
274 Requires
275 .In sys/types.h
276 for
277 .Vt size_t
278 and
279 .Qq Pa mandoc.h
280 for
281 .Vt enum mandocerr .
282 .Pp
283 Provides
284 .Vt struct buf ,
285 utility functions needed by multiple parsers,
286 and the top-level functions to call the parsers.
287 .Pp
288 Uses the opaque types
289 .Vt struct mparse
290 from
291 .Pa read.c
292 and
293 .Vt struct roff
294 from
295 .Pa roff.c
296 for function prototypes.
297 Uses the type
298 .Vt struct roff_man
299 from
300 .Pa roff.h
301 as an opaque type for function prototypes.
302 .It Qq Pa roff_int.h
303 Requires
304 .Qq Pa roff.h
305 for
306 .Vt enum roff_type .
307 .Pp
308 Provides functions named
309 .Fn roff_*
310 to handle roff nodes and the two special functions
311 .Fn man_breakscope
312 and
313 .Fn mdoc_argv_free
314 because the latter two are needed by
315 .Qq Pa roff.c .
316 .Pp
317 Uses the types
318 .Vt struct roff_man
319 and
320 .Vt struct roff_node
321 from
322 .Pa roff.h
323 and
324 .Vt struct mdoc_arg
325 from
326 .Pa mdoc.h
327 as opaque types for function prototypes.
328 .It Qq Pa libmdoc.h
329 Requires
330 .Qq Pa roff.h
331 for
332 .Vt enum roff_tok
333 and
334 .Qq Pa mdoc.h
335 for
336 .Vt enum mdoc_*
337 and
338 .Vt struct mdoc_* .
339 .Pp
340 Provides
341 .Vt enum margserr ,
342 .Vt enum mdelim ,
343 .Vt struct mdoc_macro ,
344 and many functions internal to the
345 .Xr mdoc 7
346 parser.
347 .Pp
348 Uses the opaque type
349 .Vt struct mparse
350 from
351 .Pa read.c .
352 Uses the types
353 .Vt struct roff_man
354 and
355 .Vt struct roff_node
356 from
357 .Pa roff.h
358 as opaque types for function prototypes.
359 .Pp
360 When this header is included, the same file should not include
361 interfaces of different parsers.
362 .It Qq Pa libman.h
363 Requires
364 .Qq Pa roff.h
365 for
366 .Vt enum roff_tok .
367 .Pp
368 Provides
369 .Vt struct man_macro
370 and some functions internal to the
371 .Xr man 7
372 parser.
373 .Pp
374 Uses the types
375 .Vt struct roff_man
376 and
377 .Vt struct roff_node
378 from
379 .Pa roff.h
380 as opaque types for function prototypes.
381 .Pp
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
386 .Xr eqn 7
387 parser, for use in the
388 .Xr roff 7
389 and
390 .Xr eqn 7
391 parsers only.
392 .Pp
393 Requires
394 .In sys/types.h
395 for
396 .Vt size_t .
397 .Pp
398 Provides
399 .Vt struct eqn_node
400 and the functions
401 .Fn eqn_alloc ,
402 .Fn eqn_box_new ,
403 .Fn eqn_box_free ,
404 .Fn eqn_free ,
405 .Fn eqn_parse ,
406 .Fn eqn_read ,
407 and
408 .Fn eqn_reset .
409 .Pp
410 Uses the opaque type
411 .Vt struct mparse
412 from
413 .Pa read.c
414 for function prototypes.
415 Uses the type
416 .Vt struct eqn_box
417 from
418 .Pa mandoc.h
419 as an opaque type for function prototypes.
420 Uses the types
421 .Vt struct roff_node
422 from
423 .Pa roff.h
424 and
425 .Vt struct eqn_def
426 from
427 .Pa eqn.c
428 as opaque struct members.
429 .Pp
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
434 .Xr tbl 7
435 parser, for use in the
436 .Xr roff 7
437 and
438 .Xr tbl 7
439 parsers only.
440 .Pp
441 Provides the functions documented in
442 .Xr tbl 3 .
443 .Pp
444 Uses the opaque type
445 .Vt struct mparse
446 from
447 .Pa read.c .
448 Uses the types
449 .Vt struct tbl_span
450 from
451 .Pa tbl.h
452 and
453 .Vt struct tbl_node
454 from
455 .Pa tbl_int.h
456 as opaque types for function prototypes.
457 .Pp
458 When this header is included, the same file should not include
459 internals of different parsers.
460 .It Qq Pa tbl_int.h
461 Internal interfaces of the
462 .Xr tbl 7
463 parser, for use inside the
464 .Xr tbl 7
465 parser only.
466 .Pp
467 Requires
468 .Qq Pa tbl.h
469 for
470 .Vt struct tbl_opts .
471 .Pp
472 Provides
473 .Vt enum tbl_part ,
474 .Vt struct tbl_node ,
475 and the functions
476 .Fn tbl_option ,
477 .Fn tbl_layout ,
478 .Fn tbl_data ,
479 .Fn tbl_cdata ,
480 and
481 .Fn tbl_reset .
482 .Pp
483 Uses a pointer to the opaque type
484 .Vt struct mparse
485 from
486 .Pa read.c
487 as an opaque struct member.
488 .Pp
489 When this header is included, the same file should not include
490 interfaces of different parsers.
491 .El
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.
495 .Bl -tag -width Ds
496 .It Qq Pa out.h
497 Requires
498 .In sys/types.h
499 for
500 .Vt size_t .
501 .Pp
502 Provides
503 .Vt enum roffscale ,
504 .Vt struct roffcol ,
505 .Vt struct roffsu ,
506 .Vt struct rofftbl ,
507 .Fn a2roffsu ,
508 and
509 .Fn tblcalc .
510 .Pp
511 Uses
512 .Vt struct tbl_span
513 from
514 .Pa mandoc.h
515 as an opaque type for function prototypes.
516 .Pp
517 When this header is included, the same file should not include
518 .Pa mansearch.h .
519 .It Qq Pa term.h
520 Requires
521 .In sys/types.h
522 for
523 .Vt size_t
524 and
525 .Qq Pa out.h
526 for
527 .Vt struct roffsu
528 and
529 .Vt struct rofftbl .
530 .Pp
531 Provides
532 .Vt enum termenc ,
533 .Vt enum termfont ,
534 .Vt enum termtype ,
535 .Vt struct termp_tbl ,
536 .Vt struct termp ,
537 .Fn roff_term_pre ,
538 and many terminal formatting functions.
539 .Pp
540 Uses the opaque type
541 .Vt struct termp_ps
542 from
543 .Pa term_ps.c .
544 Uses
545 .Vt struct tbl_span
546 and
547 .Vt struct eqn_box
548 from
549 .Pa mandoc.h
550 and
551 .Vt struct roff_meta
552 and
553 .Vt struct roff_node
554 from
555 .Pa roff.h
556 as opaque types for function prototypes.
557 .Pp
558 When this header is included, the same file should not include
559 .Pa html.h
560 or
561 .Pa mansearch.h .
562 .It Qq Pa html.h
563 Requires
564 .In sys/types.h
565 for
566 .Vt size_t
567 and
568 .Qq Pa out.h
569 for
570 .Vt struct roffsu
571 and
572 .Vt struct rofftbl .
573 .Pp
574 Provides
575 .Vt enum htmltag ,
576 .Vt enum htmlattr ,
577 .Vt enum htmlfont ,
578 .Vt struct tag ,
579 .Vt struct tagq ,
580 .Vt struct htmlpair ,
581 .Vt struct html ,
582 .Fn roff_html_pre ,
583 and many HTML formatting functions.
584 .Pp
585 Uses
586 .Vt struct tbl_span
587 and
588 .Vt struct eqn_box
589 from
590 .Pa mandoc.h
591 and
592 .Vt struct roff_node
593 from
594 .Pa roff.h
595 as opaque types for function prototypes.
596 .Pp
597 When this header is included, the same file should not include
598 .Pa term.h
599 or
600 .Pa mansearch.h .
601 .It Qq Pa tag.h
602 Requires
603 .In sys/types.h
604 for
605 .Vt size_t .
606 .Pp
607 Provides an interface to generate
608 .Xr ctags 1
609 files for the
610 .Ic :t
611 functionality mentioned in
612 .Xr man 1 .
613 .It Qq Pa main.h
614 Provides the top level steering functions for all formatters.
615 .Pp
616 Uses the type
617 .Vt struct roff_man
618 from
619 .Pa roff.h
620 as an opaque type for function prototypes.
621 .It Qq Pa manconf.h
622 Requires
623 .In sys/types.h
624 for
625 .Vt size_t .
626 .Pp
627 Provides
628 .Vt struct manconf ,
629 .Vt struct manpaths ,
630 .Vt struct manoutput ,
631 and the functions
632 .Fn manconf_parse ,
633 .Fn manconf_output ,
634 .Fn manconf_free ,
635 and
636 .Fn manpath_base .
637 .It Qq Pa mansearch.h
638 Requires
639 .In sys/types.h
640 for
641 .Vt size_t
642 and
643 .In stdint.h
644 for
645 .Vt uint64_t .
646 .Pp
647 Provides
648 .Vt enum argmode ,
649 .Vt struct manpage ,
650 .Vt struct mansearch ,
651 and the functions
652 .Fn mansearch
653 and
654 .Fn mansearch_free .
655 .Pp
656 Uses
657 .Vt struct manpaths
658 from
659 .Pa manconf.h
660 as an opaque type for function prototypes.
661 .Pp
662 When this header is included, the same file should not include
663 .Pa out.h ,
664 .Pa term.h ,
665 or
666 .Pa html.h .
667 .El