]> git.cameronkatri.com Git - mandoc.git/blob - mandoc_headers.3
Test the handling of some additional one-character escape sequences
[mandoc.git] / mandoc_headers.3
1 .\" $Id: mandoc_headers.3,v 1.35 2022/04/14 16:43:44 schwarze Exp $
2 .\"
3 .\" Copyright (c) 2014-2022 Ingo Schwarze <schwarze@openbsd.org>
4 .\"
5 .\" Permission to use, copy, modify, and distribute this software for any
6 .\" purpose with or without fee is hereby granted, provided that the above
7 .\" copyright notice and this permission notice appear in all copies.
8 .\"
9 .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 .\"
17 .Dd $Mdocdate: April 14 2022 $
18 .Dt MANDOC_HEADERS 3
19 .Os
20 .Sh NAME
21 .Nm mandoc_headers
22 .Nd ordering of mandoc include files
23 .Sh DESCRIPTION
24 To support a cleaner coding style, the mandoc header files do not
25 contain any include directives and do not guard against multiple
26 inclusion.
27 The application developer has to make sure that the headers are
28 included in the order shown in this manual page,
29 and that no header is included more than once.
30 .Pp
31 The headers and functions form three major groups:
32 .Sx Parser interface ,
33 .Sx Parser internals ,
34 and
35 .Sx Formatter interface .
36 .Pp
37 Various rules are given below prohibiting the inclusion of certain
38 combinations of headers into the same file.
39 The intention is to keep the following functional components
40 separate from each other:
41 .Pp
42 .Bl -dash -offset indent -compact
43 .It
44 .Xr roff 7
45 parser
46 .It
47 .Xr mdoc 7
48 parser
49 .It
50 .Xr man 7
51 parser
52 .It
53 .Xr tbl 7
54 parser
55 .It
56 .Xr eqn 7
57 parser
58 .It
59 terminal formatters
60 .It
61 HTML formatters
62 .It
63 search tools
64 .It
65 main programs
66 .El
67 .Pp
68 Note that mere usage of an opaque struct type does
69 .Em not
70 require inclusion of the header where that type is defined.
71 .Ss Parser interface
72 Each of the following headers can be included without including
73 any other mandoc header.
74 These headers should be included before any other mandoc headers.
75 .Bl -tag -width Ds
76 .It Qq Pa mandoc_aux.h
77 Memory allocation utility functions; can be used everywhere.
78 .Pp
79 Requires
80 .In sys/types.h
81 for
82 .Vt size_t .
83 .Pp
84 Provides the functions documented in
85 .Xr mandoc_malloc 3 .
86 .Pp
87 When this header is included, the same file must not include
88 .Qq Pa mandoc_dbg.h
89 because
90 .Qq Pa mandoc_aux.h
91 automatically includes
92 .Qq Pa mandoc_dbg.h
93 if and only if the preprocessor symbol
94 .Dv DEBUG_MEMORY
95 is defined.
96 .It Qq Pa mandoc_dbg.h
97 Debugging utility functions and
98 debugging wrappers around memory allocation functions.
99 .Pp
100 Requires
101 .In sys/types.h
102 for
103 .Vt size_t .
104 .Pp
105 Provides the functions documented in
106 .Xr mandoc_dbg_init 3 .
107 .Pp
108 This header must not be included unless the preprocessor symbol
109 .Dv DEBUG_MEMORY
110 is defined.
111 When this header is included, the same file must not include
112 .Qq Pa mandoc_aux.h .
113 .It Qq Pa mandoc_ohash.h
114 Hashing utility functions; can be used everywhere.
115 .Pp
116 Requires
117 .In stddef.h
118 for
119 .Vt ptrdiff_t
120 and
121 .In stdint.h
122 for
123 .Vt uint32_t .
124 .Pp
125 Includes
126 .In ohash.h
127 and provides
128 .Fn mandoc_ohash_init .
129 .It Qq Pa mandoc.h
130 Error handling, escape sequence, and character utilities;
131 can be used everywhere.
132 .Pp
133 Requires
134 .In sys/types.h
135 for
136 .Vt size_t
137 and
138 .In stdio.h
139 for
140 .Vt FILE .
141 .Pp
142 Provides
143 .Vt enum mandoc_esc ,
144 .Vt enum mandocerr ,
145 .Vt enum mandoclevel ,
146 the function
147 .Xr mandoc_escape 3 ,
148 the functions described in
149 .Xr mchars_alloc 3 ,
150 and the
151 .Fn mandoc_msg*
152 functions.
153 .It Qq Pa roff.h
154 Common data types for all syntax trees and related functions;
155 can be used everywhere.
156 .Pp
157 Provides
158 .Vt enum mandoc_os ,
159 .Vt enum mdoc_endbody ,
160 .Vt enum roff_macroset ,
161 .Vt enum roff_sec ,
162 .Vt enum roff_tok ,
163 .Vt enum roff_type ,
164 .Vt struct roff_man ,
165 .Vt struct roff_meta ,
166 .Vt struct roff_node ,
167 the constant array
168 .Va roff_name
169 and the function
170 .Fn deroff .
171 .Pp
172 Uses pointers to the types
173 .Vt struct ohash
174 from
175 .Qq Pa mandoc_ohash.h ,
176 .Vt struct mdoc_arg
177 and
178 .Vt union mdoc_data
179 from
180 .Qq Pa mdoc.h ,
181 .Vt struct tbl_span
182 from
183 .Qq Pa tbl.h ,
184 and
185 .Vt struct eqn_box
186 from
187 .Qq Pa eqn.h
188 as opaque struct members.
189 .It Qq Pa tbl.h
190 Data structures for the
191 .Xr tbl 7
192 parse tree; can be used everywhere.
193 .Pp
194 Requires
195 .In sys/types.h
196 for
197 .Vt size_t
198 and
199 .Qq Pa mandoc.h
200 for
201 .Vt enum mandoc_esc .
202 .Pp
203 Provides
204 .Vt enum tbl_cellt ,
205 .Vt enum tbl_datt ,
206 .Vt enum tbl_spant ,
207 .Vt struct tbl_opts ,
208 .Vt struct tbl_cell ,
209 .Vt struct tbl_row ,
210 .Vt struct tbl_dat ,
211 and
212 .Vt struct tbl_span .
213 .It Qq Pa eqn.h
214 Data structures for the
215 .Xr eqn 7
216 parse tree; can be used everywhere.
217 .Pp
218 Requires
219 .In sys/types.h
220 for
221 .Vt size_t .
222 .Pp
223 Provides
224 .Vt enum eqn_boxt ,
225 .Vt enum eqn_fontt ,
226 .Vt enum eqn_post ,
227 and
228 .Vt struct eqn_box .
229 .It Qq Pa mandoc_parse.h
230 Top level parser interface, for use in the main program
231 and in the main parser, but not in formatters.
232 .Pp
233 Requires
234 .Qq Pa mandoc.h
235 for
236 .Vt enum mandocerr
237 and
238 .Vt enum mandoclevel
239 and
240 .Qq Pa roff.h
241 for
242 .Vt enum mandoc_os .
243 .Pp
244 Uses the opaque type
245 .Vt struct mparse
246 from
247 .Pa read.c
248 for function prototypes.
249 Uses
250 .Vt struct roff_meta
251 from
252 .Qq Pa roff.h
253 as an opaque type for function prototypes.
254 .It Qq Pa mandoc_xr.h
255 Cross reference validation; intended for use in the main program
256 and in parsers, but not in formatters.
257 .Pp
258 Provides
259 .Vt struct mandoc_xr
260 and the functions
261 .Fn mandoc_xr_reset ,
262 .Fn mandoc_xr_add ,
263 .Fn mandoc_xr_get ,
264 and
265 .Fn mandoc_xr_free .
266 .It Qq Pa tag.h
267 Internal interfaces to tag syntax tree nodes,
268 for use by validation modules only.
269 .Pp
270 Requires
271 .In limits.h
272 for
273 .Dv INT_MAX .
274 .Pp
275 Provides the functions
276 .Fn tag_alloc ,
277 .Fn tag_put ,
278 .Fn tag_check ,
279 and
280 .Fn tag_free
281 and some
282 .Dv TAG_*
283 constants.
284 .Pp
285 Uses the type
286 .Vt struct roff_node
287 from
288 .Qq Pa roff.h
289 as an opaque type for function prototypes.
290 .El
291 .Pp
292 The following two require
293 .Qq Pa roff.h
294 but no other mandoc headers.
295 Afterwards, any other mandoc headers can be included as needed.
296 .Bl -tag -width Ds
297 .It Qq Pa mdoc.h
298 Requires
299 .In sys/types.h
300 for
301 .Vt size_t .
302 .Pp
303 Provides
304 .Vt enum mdocargt ,
305 .Vt enum mdoc_auth ,
306 .Vt enum mdoc_disp ,
307 .Vt enum mdoc_font ,
308 .Vt enum mdoc_list ,
309 .Vt struct mdoc_argv ,
310 .Vt struct mdoc_arg ,
311 .Vt struct mdoc_an ,
312 .Vt struct mdoc_bd ,
313 .Vt struct mdoc_bf ,
314 .Vt struct mdoc_bl ,
315 .Vt struct mdoc_rs ,
316 .Vt union mdoc_data ,
317 and the functions
318 .Fn mdoc_*
319 described in
320 .Xr mandoc 3 .
321 .Pp
322 Uses the types
323 .Vt struct roff_node
324 from
325 .Qq Pa roff.h
326 and
327 .Vt struct roff_man
328 from
329 .Qq Pa roff_int.h
330 as opaque types for function prototypes.
331 .Pp
332 When this header is included, the same file should not include
333 internals of different parsers.
334 .It Qq Pa man.h
335 Provides the functions
336 .Fn man_*
337 described in
338 .Xr mandoc 3 .
339 .Pp
340 Uses the type
341 .Vt struct roff_man
342 from
343 .Qq Pa roff.h
344 as an opaque type for function prototypes.
345 .Pp
346 When this header is included, the same file should not include
347 internals of different parsers.
348 .El
349 .Ss Parser internals
350 Most of the following headers require inclusion of a parser interface header
351 before they can be included.
352 All parser interface headers should precede all parser internal headers.
353 When any parser internal headers are included, the same file should
354 not include any formatter headers.
355 .Bl -tag -width Ds
356 .It Qq Pa libmandoc.h
357 Requires
358 .In sys/types.h
359 for
360 .Vt size_t
361 and
362 .Qq Pa mandoc.h
363 for
364 .Vt enum mandocerr .
365 .Pp
366 Provides
367 .Vt struct buf ,
368 utility functions needed by multiple parsers,
369 and the top-level functions to call the parsers.
370 .Pp
371 Uses the opaque type
372 .Vt struct roff
373 from
374 .Pa roff.c
375 for function prototypes.
376 Uses the type
377 .Vt struct roff_man
378 from
379 .Qq Pa roff.h
380 as an opaque type for function prototypes.
381 .It Qq Pa roff_int.h
382 Parser internals shared by multiple parsers.
383 Can be used in all parsers, but not in main programs or formatters.
384 .Pp
385 Requires
386 .Qq Pa roff.h
387 for
388 .Vt enum roff_type
389 and
390 .Vt enum roff_tok .
391 .Pp
392 Provides
393 .Vt enum roff_next ,
394 .Vt struct roff_man ,
395 functions named
396 .Fn roff_*
397 to handle roff nodes,
398 .Fn roffhash_alloc ,
399 .Fn roffhash_find ,
400 .Fn roffhash_free ,
401 and
402 .Fn roff_validate ,
403 and the two special functions
404 .Fn man_breakscope
405 and
406 .Fn mdoc_argv_free
407 because the latter two are needed by
408 .Pa roff.c .
409 .Pp
410 Uses the types
411 .Vt struct ohash
412 from
413 .Qq Pa mandoc_ohash.h ,
414 .Vt struct roff_node
415 and
416 .Vt struct roff_meta
417 from
418 .Qq Pa roff.h ,
419 .Vt struct roff
420 from
421 .Pa roff.c ,
422 and
423 .Vt struct mdoc_arg
424 from
425 .Qq Pa mdoc.h
426 as opaque types for function prototypes.
427 .It Qq Pa libmdoc.h
428 Requires
429 .Qq Pa roff.h
430 for
431 .Vt enum roff_tok
432 and
433 .Vt enum roff_sec .
434 .Pp
435 Provides
436 .Vt enum margserr ,
437 .Vt enum mdelim ,
438 .Vt struct mdoc_macro ,
439 and many functions internal to the
440 .Xr mdoc 7
441 parser.
442 .Pp
443 Uses the types
444 .Vt struct roff_node
445 from
446 .Qq Pa roff.h ,
447 .Vt struct roff_man
448 from
449 .Qq Pa roff_int.h ,
450 and
451 .Vt struct mdoc_arg
452 from
453 .Qq Pa mdoc.h
454 as opaque types for function prototypes.
455 .Pp
456 When this header is included, the same file should not include
457 interfaces of different parsers.
458 .It Qq Pa libman.h
459 Requires
460 .Qq Pa roff.h
461 for
462 .Vt enum roff_tok .
463 .Pp
464 Provides
465 .Vt struct man_macro
466 and some functions internal to the
467 .Xr man 7
468 parser.
469 .Pp
470 Uses the types
471 .Vt struct roff_node
472 from
473 .Qq Pa roff.h
474 and
475 .Vt struct roff_man
476 from
477 .Qq Pa roff_int.h
478 as opaque types for function prototypes.
479 .Pp
480 When this header is included, the same file should not include
481 interfaces of different parsers.
482 .It Qq Pa eqn_parse.h
483 External interface of the
484 .Xr eqn 7
485 parser, for use in the
486 .Xr roff 7
487 and
488 .Xr eqn 7
489 parsers only.
490 .Pp
491 Requires
492 .In sys/types.h
493 for
494 .Vt size_t .
495 .Pp
496 Provides
497 .Vt struct eqn_node
498 and the functions
499 .Fn eqn_alloc ,
500 .Fn eqn_box_new ,
501 .Fn eqn_box_free ,
502 .Fn eqn_free ,
503 .Fn eqn_parse ,
504 .Fn eqn_read ,
505 and
506 .Fn eqn_reset .
507 .Pp
508 Uses the type
509 .Vt struct eqn_box
510 from
511 .Qq Pa mandoc.h
512 as an opaque type for function prototypes.
513 Uses the types
514 .Vt struct roff_node
515 from
516 .Qq Pa roff.h
517 and
518 .Vt struct eqn_def
519 from
520 .Pa eqn.c
521 as opaque struct members.
522 .Pp
523 When this header is included, the same file should not include
524 internals of different parsers.
525 .It Qq Pa tbl_parse.h
526 External interface of the
527 .Xr tbl 7
528 parser, for use in the
529 .Xr roff 7
530 and
531 .Xr tbl 7
532 parsers only.
533 .Pp
534 Provides the functions documented in
535 .Xr tbl 3 .
536 .Pp
537 Uses the types
538 .Vt struct tbl_span
539 from
540 .Qq Pa tbl.h
541 and
542 .Vt struct tbl_node
543 from
544 .Qq Pa tbl_int.h
545 as opaque types for function prototypes.
546 .Pp
547 When this header is included, the same file should not include
548 internals of different parsers.
549 .It Qq Pa tbl_int.h
550 Internal interfaces of the
551 .Xr tbl 7
552 parser, for use inside the
553 .Xr tbl 7
554 parser only.
555 .Pp
556 Requires
557 .Qq Pa tbl.h
558 for
559 .Vt struct tbl_opts .
560 .Pp
561 Provides
562 .Vt enum tbl_part ,
563 .Vt struct tbl_node ,
564 and the functions
565 .Fn tbl_option ,
566 .Fn tbl_layout ,
567 .Fn tbl_data ,
568 .Fn tbl_cdata ,
569 and
570 .Fn tbl_reset .
571 .Pp
572 When this header is included, the same file should not include
573 interfaces of different parsers.
574 .El
575 .Ss Formatter interface
576 These headers should be included after any parser interface headers.
577 No parser internal headers should be included by the same file.
578 .Bl -tag -width Ds
579 .It Qq Pa out.h
580 Requires
581 .In sys/types.h
582 for
583 .Vt size_t .
584 .Pp
585 Provides
586 .Vt enum roffscale ,
587 .Vt struct roffcol ,
588 .Vt struct roffsu ,
589 .Vt struct rofftbl ,
590 .Fn a2roffsu ,
591 and
592 .Fn tblcalc .
593 .Pp
594 Uses
595 .Vt struct tbl_span
596 from
597 .Qq Pa mandoc.h
598 as an opaque type for function prototypes.
599 .Pp
600 When this header is included, the same file should not include
601 .Qq Pa mansearch.h .
602 .It Qq Pa term.h
603 Requires
604 .In sys/types.h
605 for
606 .Vt size_t
607 and
608 .Qq Pa out.h
609 for
610 .Vt struct roffsu
611 and
612 .Vt struct rofftbl .
613 .Pp
614 Provides
615 .Vt enum termenc ,
616 .Vt enum termfont ,
617 .Vt enum termtype ,
618 .Vt struct termp_tbl ,
619 .Vt struct termp ,
620 .Fn roff_term_pre ,
621 and many terminal formatting functions.
622 .Pp
623 Uses the opaque type
624 .Vt struct termp_ps
625 from
626 .Pa term_ps.c .
627 Uses
628 .Vt struct tbl_span
629 and
630 .Vt struct eqn_box
631 from
632 .Qq Pa mandoc.h
633 and
634 .Vt struct roff_meta
635 and
636 .Vt struct roff_node
637 from
638 .Qq Pa roff.h
639 as opaque types for function prototypes.
640 .Pp
641 When this header is included, the same file should not include
642 .Qq Pa html.h
643 or
644 .Qq Pa mansearch.h .
645 .It Qq Pa tag_term.h
646 Requires
647 .In sys/types.h
648 for
649 .Vt size_t
650 and
651 .In stdio.h
652 for
653 .Vt FILE .
654 .Pp
655 Provides an interface to generate
656 .Xr ctags 1
657 files for the
658 .Ic :t
659 functionality mentioned in
660 .Xr man 1 .
661 .Pp
662 Uses the type
663 .Vt struct roff_node
664 from
665 .Qq Pa roff.h
666 as an opaque type for function prototypes.
667 .Pp
668 When this header is included, the same file should not include
669 .Qq Pa html.h
670 or
671 .Qq Pa mansearch.h .
672 .It Qq Pa html.h
673 Requires
674 .In sys/types.h
675 for
676 .Vt size_t ,
677 .Qq Pa mandoc.h
678 for
679 .Vt enum mandoc_esc ,
680 .Qq Pa roff.h
681 for
682 .Vt enum roff_tok ,
683 and
684 .Qq Pa out.h
685 for
686 .Vt struct roffsu
687 and
688 .Vt struct rofftbl .
689 .Pp
690 Provides
691 .Vt enum htmltag ,
692 .Vt enum htmlattr ,
693 .Vt enum htmlfont ,
694 .Vt struct tag ,
695 .Vt struct tagq ,
696 .Vt struct htmlpair ,
697 .Vt struct html ,
698 .Fn roff_html_pre ,
699 and many HTML formatting functions.
700 .Pp
701 Uses
702 .Vt struct tbl_span
703 and
704 .Vt struct eqn_box
705 from
706 .Qq Pa mandoc.h
707 and
708 .Vt struct roff_node
709 from
710 .Qq Pa roff.h
711 as opaque types for function prototypes.
712 .Pp
713 When this header is included, the same file should not include
714 .Qq Pa term.h ,
715 .Qq Pa tab_term.h ,
716 or
717 .Qq Pa mansearch.h .
718 .It Qq Pa main.h
719 Provides the top level steering functions for all formatters.
720 .Pp
721 Uses the type
722 .Vt struct roff_meta
723 from
724 .Qq Pa roff.h
725 as an opaque type for function prototypes.
726 .It Qq Pa manconf.h
727 Requires
728 .In sys/types.h
729 for
730 .Vt size_t .
731 .Pp
732 Provides
733 .Vt struct manconf ,
734 .Vt struct manpaths ,
735 .Vt struct manoutput ,
736 and the functions
737 .Fn manconf_parse ,
738 .Fn manconf_output ,
739 .Fn manconf_free ,
740 and
741 .Fn manpath_base .
742 .It Qq Pa mansearch.h
743 Requires
744 .In sys/types.h
745 for
746 .Vt size_t
747 and
748 .In stdint.h
749 for
750 .Vt uint64_t .
751 .Pp
752 Provides
753 .Vt enum argmode ,
754 .Vt struct manpage ,
755 .Vt struct mansearch ,
756 and the functions
757 .Fn mansearch
758 and
759 .Fn mansearch_free .
760 .Pp
761 Uses
762 .Vt struct manpaths
763 from
764 .Qq Pa manconf.h
765 as an opaque type for function prototypes.
766 .Pp
767 When this header is included, the same file should not include
768 .Qq Pa out.h ,
769 .Qq Pa term.h ,
770 .Qq Pa tab_term.h ,
771 or
772 .Qq Pa html.h .
773 .El