]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/mandoc/mandoc_headers.3
Add two missing eventhandler.h headers
[FreeBSD/FreeBSD.git] / contrib / mandoc / mandoc_headers.3
1 .Dd $Mdocdate: December 30 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, escape sequence, and character utilities;
88 can be used everywhere.
89 .Pp
90 Requires
91 .In sys/types.h
92 for
93 .Vt size_t
94 and
95 .In stdio.h
96 for
97 .Vt FILE .
98 .Pp
99 Provides
100 .Vt enum mandoc_esc ,
101 .Vt enum mandocerr ,
102 .Vt enum mandoclevel ,
103 the function
104 .Xr mandoc_escape 3 ,
105 the functions described in
106 .Xr mchars_alloc 3 ,
107 and the
108 .Fn mandoc_msg*
109 functions.
110 .It Qq Pa roff.h
111 Common data types for all syntax trees and related functions;
112 can be used everywhere.
113 .Pp
114 Provides
115 .Vt enum mandoc_os ,
116 .Vt enum mdoc_endbody ,
117 .Vt enum roff_macroset ,
118 .Vt enum roff_sec ,
119 .Vt enum roff_tok ,
120 .Vt enum roff_type ,
121 .Vt struct roff_man ,
122 .Vt struct roff_meta ,
123 .Vt struct roff_node ,
124 the constant array
125 .Va roff_name
126 and the function
127 .Fn deroff .
128 .Pp
129 Uses pointers to the types
130 .Vt struct ohash
131 from
132 .Pa mandoc_ohash.h ,
133 .Vt struct mdoc_arg
134 and
135 .Vt union mdoc_data
136 from
137 .Pa mdoc.h ,
138 .Vt struct tbl_span
139 from
140 .Pa tbl.h ,
141 and
142 .Vt struct eqn_box
143 from
144 .Pa eqn.h
145 as opaque struct members.
146 .It Qq Pa tbl.h
147 Data structures for the
148 .Xr tbl 7
149 parse tree; can be used everywhere.
150 .Pp
151 Requires
152 .In sys/types.h
153 for
154 .Vt size_t .
155 .Pp
156 Provides
157 .Vt enum tbl_cellt ,
158 .Vt enum tbl_datt ,
159 .Vt enum tbl_spant ,
160 .Vt struct tbl_opts ,
161 .Vt struct tbl_cell ,
162 .Vt struct tbl_row ,
163 .Vt struct tbl_dat ,
164 and
165 .Vt struct tbl_span .
166 .It Qq Pa eqn.h
167 Data structures for the
168 .Xr eqn 7
169 parse tree; can be used everywhere.
170 .Pp
171 Requires
172 .In sys/types.h
173 for
174 .Vt size_t .
175 .Pp
176 Provides
177 .Vt enum eqn_boxt ,
178 .Vt enum eqn_fontt ,
179 .Vt enum eqn_post ,
180 and
181 .Vt struct eqn_box .
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.
185 .Pp
186 Requires
187 .Pa mandoc.h
188 for
189 .Vt enum mandocerr
190 and
191 .Vt enum mandoclevel
192 and
193 .Pa roff.h
194 for
195 .Vt enum mandoc_os .
196 .Pp
197 Uses the opaque type
198 .Vt struct mparse
199 from
200 .Pa read.c
201 for function prototypes.
202 Uses
203 .Vt struct roff_meta
204 from
205 .Pa roff.h
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.
210 .Pp
211 Provides
212 .Vt struct mandoc_xr
213 and the functions
214 .Fn mandoc_xr_reset ,
215 .Fn mandoc_xr_add ,
216 .Fn mandoc_xr_get ,
217 and
218 .Fn mandoc_xr_free .
219 .El
220 .Pp
221 The following two require
222 .Qq Pa roff.h
223 but no other mandoc headers.
224 Afterwards, any other mandoc headers can be included as needed.
225 .Bl -tag -width Ds
226 .It Qq Pa mdoc.h
227 Requires
228 .In sys/types.h
229 for
230 .Vt size_t .
231 .Pp
232 Provides
233 .Vt enum mdocargt ,
234 .Vt enum mdoc_auth ,
235 .Vt enum mdoc_disp ,
236 .Vt enum mdoc_font ,
237 .Vt enum mdoc_list ,
238 .Vt struct mdoc_argv ,
239 .Vt struct mdoc_arg ,
240 .Vt struct mdoc_an ,
241 .Vt struct mdoc_bd ,
242 .Vt struct mdoc_bf ,
243 .Vt struct mdoc_bl ,
244 .Vt struct mdoc_rs ,
245 .Vt union mdoc_data ,
246 and the functions
247 .Fn mdoc_*
248 described in
249 .Xr mandoc 3 .
250 .Pp
251 Uses the types
252 .Vt struct roff_node
253 from
254 .Pa roff.h
255 and
256 .Vt struct roff_man
257 from
258 .Pa roff_int.h
259 as opaque types for function prototypes.
260 .Pp
261 When this header is included, the same file should not include
262 internals of different parsers.
263 .It Qq Pa man.h
264 Provides the functions
265 .Fn man_*
266 described in
267 .Xr mandoc 3 .
268 .Pp
269 Uses the type
270 .Vt struct roff_man
271 from
272 .Pa roff.h
273 as an opaque type for function prototypes.
274 .Pp
275 When this header is included, the same file should not include
276 internals of different parsers.
277 .El
278 .Ss Parser internals
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.
284 .Bl -tag -width Ds
285 .It Qq Pa libmandoc.h
286 Requires
287 .In sys/types.h
288 for
289 .Vt size_t
290 and
291 .Qq Pa mandoc.h
292 for
293 .Vt enum mandocerr .
294 .Pp
295 Provides
296 .Vt struct buf ,
297 utility functions needed by multiple parsers,
298 and the top-level functions to call the parsers.
299 .Pp
300 Uses the opaque type
301 .Vt struct roff
302 from
303 .Pa roff.c
304 for function prototypes.
305 Uses the type
306 .Vt struct roff_man
307 from
308 .Pa roff.h
309 as an opaque type for function prototypes.
310 .It Qq Pa roff_int.h
311 Parser internals shared by multiple parsers.
312 Can be used in all parsers, but not in main programs or formatters.
313 .Pp
314 Requires
315 .Qq Pa roff.h
316 for
317 .Vt enum roff_type
318 and
319 .Vt enum roff_tok .
320 .Pp
321 Provides
322 .Vt enum roff_next ,
323 .Vt struct roff_man ,
324 functions named
325 .Fn roff_*
326 to handle roff nodes,
327 .Fn roffhash_alloc ,
328 .Fn roffhash_find ,
329 .Fn roffhash_free ,
330 and
331 .Fn roff_validate ,
332 and the two special functions
333 .Fn man_breakscope
334 and
335 .Fn mdoc_argv_free
336 because the latter two are needed by
337 .Qq Pa roff.c .
338 .Pp
339 Uses the types
340 .Vt struct ohash
341 from
342 .Pa mandoc_ohash.h ,
343 .Vt struct roff_node
344 and
345 .Vt struct roff_meta
346 from
347 .Pa roff.h ,
348 .Vt struct roff
349 from
350 .Pa roff.c ,
351 and
352 .Vt struct mdoc_arg
353 from
354 .Pa mdoc.h
355 as opaque types for function prototypes.
356 .It Qq Pa libmdoc.h
357 Requires
358 .Qq Pa roff.h
359 for
360 .Vt enum roff_tok
361 and
362 .Vt enum roff_sec .
363 .Pp
364 Provides
365 .Vt enum margserr ,
366 .Vt enum mdelim ,
367 .Vt struct mdoc_macro ,
368 and many functions internal to the
369 .Xr mdoc 7
370 parser.
371 .Pp
372 Uses the types
373 .Vt struct roff_node
374 from
375 .Pa roff.h ,
376 .Vt struct roff_man
377 from
378 .Pa roff_int.h ,
379 and
380 .Vt struct mdoc_arg
381 from
382 .Pa mdoc.h
383 as opaque types for function prototypes.
384 .Pp
385 When this header is included, the same file should not include
386 interfaces of different parsers.
387 .It Qq Pa libman.h
388 Requires
389 .Qq Pa roff.h
390 for
391 .Vt enum roff_tok .
392 .Pp
393 Provides
394 .Vt struct man_macro
395 and some functions internal to the
396 .Xr man 7
397 parser.
398 .Pp
399 Uses the types
400 .Vt struct roff_node
401 from
402 .Pa roff.h
403 and
404 .Vt struct roff_man
405 from
406 .Pa roff_int.h
407 as opaque types for function prototypes.
408 .Pp
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
413 .Xr eqn 7
414 parser, for use in the
415 .Xr roff 7
416 and
417 .Xr eqn 7
418 parsers only.
419 .Pp
420 Requires
421 .In sys/types.h
422 for
423 .Vt size_t .
424 .Pp
425 Provides
426 .Vt struct eqn_node
427 and the functions
428 .Fn eqn_alloc ,
429 .Fn eqn_box_new ,
430 .Fn eqn_box_free ,
431 .Fn eqn_free ,
432 .Fn eqn_parse ,
433 .Fn eqn_read ,
434 and
435 .Fn eqn_reset .
436 .Pp
437 Uses the type
438 .Vt struct eqn_box
439 from
440 .Pa mandoc.h
441 as an opaque type for function prototypes.
442 Uses the types
443 .Vt struct roff_node
444 from
445 .Pa roff.h
446 and
447 .Vt struct eqn_def
448 from
449 .Pa eqn.c
450 as opaque struct members.
451 .Pp
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
456 .Xr tbl 7
457 parser, for use in the
458 .Xr roff 7
459 and
460 .Xr tbl 7
461 parsers only.
462 .Pp
463 Provides the functions documented in
464 .Xr tbl 3 .
465 .Pp
466 Uses the types
467 .Vt struct tbl_span
468 from
469 .Pa tbl.h
470 and
471 .Vt struct tbl_node
472 from
473 .Pa tbl_int.h
474 as opaque types for function prototypes.
475 .Pp
476 When this header is included, the same file should not include
477 internals of different parsers.
478 .It Qq Pa tbl_int.h
479 Internal interfaces of the
480 .Xr tbl 7
481 parser, for use inside the
482 .Xr tbl 7
483 parser only.
484 .Pp
485 Requires
486 .Qq Pa tbl.h
487 for
488 .Vt struct tbl_opts .
489 .Pp
490 Provides
491 .Vt enum tbl_part ,
492 .Vt struct tbl_node ,
493 and the functions
494 .Fn tbl_option ,
495 .Fn tbl_layout ,
496 .Fn tbl_data ,
497 .Fn tbl_cdata ,
498 and
499 .Fn tbl_reset .
500 .Pp
501 When this header is included, the same file should not include
502 interfaces of different parsers.
503 .El
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.
507 .Bl -tag -width Ds
508 .It Qq Pa out.h
509 Requires
510 .In sys/types.h
511 for
512 .Vt size_t .
513 .Pp
514 Provides
515 .Vt enum roffscale ,
516 .Vt struct roffcol ,
517 .Vt struct roffsu ,
518 .Vt struct rofftbl ,
519 .Fn a2roffsu ,
520 and
521 .Fn tblcalc .
522 .Pp
523 Uses
524 .Vt struct tbl_span
525 from
526 .Pa mandoc.h
527 as an opaque type for function prototypes.
528 .Pp
529 When this header is included, the same file should not include
530 .Pa mansearch.h .
531 .It Qq Pa term.h
532 Requires
533 .In sys/types.h
534 for
535 .Vt size_t
536 and
537 .Qq Pa out.h
538 for
539 .Vt struct roffsu
540 and
541 .Vt struct rofftbl .
542 .Pp
543 Provides
544 .Vt enum termenc ,
545 .Vt enum termfont ,
546 .Vt enum termtype ,
547 .Vt struct termp_tbl ,
548 .Vt struct termp ,
549 .Fn roff_term_pre ,
550 and many terminal formatting functions.
551 .Pp
552 Uses the opaque type
553 .Vt struct termp_ps
554 from
555 .Pa term_ps.c .
556 Uses
557 .Vt struct tbl_span
558 and
559 .Vt struct eqn_box
560 from
561 .Pa mandoc.h
562 and
563 .Vt struct roff_meta
564 and
565 .Vt struct roff_node
566 from
567 .Pa roff.h
568 as opaque types for function prototypes.
569 .Pp
570 When this header is included, the same file should not include
571 .Pa html.h
572 or
573 .Pa mansearch.h .
574 .It Qq Pa html.h
575 Requires
576 .In sys/types.h
577 for
578 .Vt size_t ,
579 .Pa mandoc.h
580 for
581 .Vt enum mandoc_esc ,
582 and
583 .Qq Pa out.h
584 for
585 .Vt struct roffsu
586 and
587 .Vt struct rofftbl .
588 .Pp
589 Provides
590 .Vt enum htmltag ,
591 .Vt enum htmlattr ,
592 .Vt enum htmlfont ,
593 .Vt struct tag ,
594 .Vt struct tagq ,
595 .Vt struct htmlpair ,
596 .Vt struct html ,
597 .Fn roff_html_pre ,
598 and many HTML formatting functions.
599 .Pp
600 Uses
601 .Vt struct tbl_span
602 and
603 .Vt struct eqn_box
604 from
605 .Pa mandoc.h
606 and
607 .Vt struct roff_node
608 from
609 .Pa roff.h
610 as opaque types for function prototypes.
611 .Pp
612 When this header is included, the same file should not include
613 .Pa term.h
614 or
615 .Pa mansearch.h .
616 .It Qq Pa tag.h
617 Requires
618 .In sys/types.h
619 for
620 .Vt size_t .
621 .Pp
622 Provides an interface to generate
623 .Xr ctags 1
624 files for the
625 .Ic :t
626 functionality mentioned in
627 .Xr man 1 .
628 .It Qq Pa main.h
629 Provides the top level steering functions for all formatters.
630 .Pp
631 Uses the type
632 .Vt struct roff_meta
633 from
634 .Pa roff.h
635 as an opaque type for function prototypes.
636 .It Qq Pa manconf.h
637 Requires
638 .In sys/types.h
639 for
640 .Vt size_t .
641 .Pp
642 Provides
643 .Vt struct manconf ,
644 .Vt struct manpaths ,
645 .Vt struct manoutput ,
646 and the functions
647 .Fn manconf_parse ,
648 .Fn manconf_output ,
649 .Fn manconf_free ,
650 and
651 .Fn manpath_base .
652 .It Qq Pa mansearch.h
653 Requires
654 .In sys/types.h
655 for
656 .Vt size_t
657 and
658 .In stdint.h
659 for
660 .Vt uint64_t .
661 .Pp
662 Provides
663 .Vt enum argmode ,
664 .Vt struct manpage ,
665 .Vt struct mansearch ,
666 and the functions
667 .Fn mansearch
668 and
669 .Fn mansearch_free .
670 .Pp
671 Uses
672 .Vt struct manpaths
673 from
674 .Pa manconf.h
675 as an opaque type for function prototypes.
676 .Pp
677 When this header is included, the same file should not include
678 .Pa out.h ,
679 .Pa term.h ,
680 or
681 .Pa html.h .
682 .El