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