]> git.cameronkatri.com Git - mandoc.git/blob - mandoc_headers.3
If man(7) next-line scope is open and the line ends with \c,
[mandoc.git] / mandoc_headers.3
1 .Dd $Mdocdate: August 24 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 mdoc 7
29 parser
30 .It
31 .Xr man 7
32 parser
33 .It
34 .Xr roff 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 .El
49 .Pp
50 Note that mere usage of an opaque struct type does
51 .Em not
52 require inclusion of the header where that type is defined.
53 .Ss Parser interface
54 Each of the following headers can be included without including
55 any other mandoc header.
56 These headers should be included before any other mandoc headers.
57 .Bl -tag -width Ds
58 .It Qq Pa mandoc_aux.h
59 Requires
60 .In sys/types.h
61 for
62 .Vt size_t .
63 .Pp
64 Provides the utility functions documented in
65 .Xr mandoc_malloc 3 .
66 .It Qq Pa mandoc_ohash.h
67 Requires
68 .In stddef.h
69 for
70 .Vt ptrdiff_t
71 and
72 .In stdint.h
73 for
74 .Vt uint32_t .
75 .Pp
76 Includes
77 .In ohash.h
78 and provides
79 .Fn mandoc_ohash_init .
80 .It Qq Pa mandoc.h
81 Requires
82 .In sys/types.h
83 for
84 .Vt size_t .
85 .Pp
86 Provides
87 .Vt enum mandoc_esc ,
88 .Vt enum mandocerr ,
89 .Vt enum mandoclevel ,
90 .Vt enum mandoc_os ,
91 .Vt enum tbl_cellt ,
92 .Vt enum tbl_datt ,
93 .Vt enum tbl_spant ,
94 .Vt enum eqn_boxt ,
95 .Vt enum eqn_fontt ,
96 .Vt enum eqn_pilet ,
97 .Vt enum eqn_post ,
98 .Vt struct tbl_opts ,
99 .Vt struct tbl_cell ,
100 .Vt struct tbl_row ,
101 .Vt struct tbl_dat ,
102 .Vt struct tbl_span ,
103 .Vt struct eqn_box ,
104 the function prototype typedef
105 .Fn mandocmsg ,
106 the function
107 .Xr mandoc_escape 3 ,
108 the functions described in
109 .Xr mchars_alloc 3 ,
110 and the functions
111 .Fn mparse_*
112 described in
113 .Xr mandoc 3 .
114 .Pp
115 Uses the opaque type
116 .Vt struct mparse
117 from
118 .Pa read.c
119 for function prototypes.
120 Uses the type
121 .Vt struct roff_man
122 from
123 .Pa roff.h
124 as an opaque type for function prototypes.
125 .It Qq Pa mandoc_xr.h
126 Provides
127 .Vt struct mandoc_xr
128 and the functions
129 .Fn mandoc_xr_reset ,
130 .Fn mandoc_xr_add ,
131 .Fn mandoc_xr_get ,
132 and
133 .Fn mandoc_xr_free .
134 .It Qq Pa roff.h
135 Requires
136 .Qq Pa mandoc_ohash.h
137 for
138 .Vt struct ohash
139 and
140 .Qq Pa mandoc.h
141 for
142 .Vt enum mandoc_os .
143 .Pp
144 Provides
145 .Vt enum mdoc_endbody ,
146 .Vt enum roff_macroset ,
147 .Vt enum roff_next ,
148 .Vt enum roff_sec ,
149 .Vt enum roff_tok ,
150 .Vt enum roff_type ,
151 .Vt struct roff_man ,
152 .Vt struct roff_meta ,
153 .Vt struct roff_node ,
154 the constant array
155 .Va roff_name
156 and the functions
157 .Fn deroff ,
158 .Fn roffhash_alloc ,
159 .Fn roffhash_find ,
160 .Fn roffhash_free ,
161 and
162 .Fn roff_validate .
163 .Pp
164 Uses pointers to the types
165 .Vt struct mdoc_arg
166 and
167 .Vt union mdoc_data
168 from
169 .Pa mdoc.h
170 as opaque struct members.
171 .El
172 .Pp
173 The following two require
174 .Qq Pa roff.h
175 but no other mandoc headers.
176 Afterwards, any other mandoc headers can be included as needed.
177 .Bl -tag -width Ds
178 .It Qq Pa mdoc.h
179 Requires
180 .In sys/types.h
181 for
182 .Vt size_t .
183 .Pp
184 Provides
185 .Vt enum mdocargt ,
186 .Vt enum mdoc_auth ,
187 .Vt enum mdoc_disp ,
188 .Vt enum mdoc_font ,
189 .Vt enum mdoc_list ,
190 .Vt struct mdoc_argv ,
191 .Vt struct mdoc_arg ,
192 .Vt struct mdoc_an ,
193 .Vt struct mdoc_bd ,
194 .Vt struct mdoc_bf ,
195 .Vt struct mdoc_bl ,
196 .Vt struct mdoc_rs ,
197 .Vt union mdoc_data ,
198 and the functions
199 .Fn mdoc_*
200 described in
201 .Xr mandoc 3 .
202 .Pp
203 Uses the type
204 .Vt struct roff_man
205 from
206 .Pa roff.h
207 as an opaque type for function prototypes.
208 .Pp
209 When this header is included, the same file should not include
210 .Pa libman.h
211 or
212 .Pa libroff.h .
213 .It Qq Pa man.h
214 Provides the functions
215 .Fn man_*
216 described in
217 .Xr mandoc 3 .
218 .Pp
219 Uses the opaque type
220 .Vt struct mparse
221 from
222 .Pa read.c
223 for function prototypes.
224 Uses the type
225 .Vt struct roff_man
226 from
227 .Pa roff.h
228 as an opaque type for function prototypes.
229 .Pp
230 When this header is included, the same file should not include
231 .Pa libmdoc.h
232 or
233 .Pa libroff.h .
234 .El
235 .Ss Parser internals
236 The following headers require inclusion of a parser interface header
237 before they can be included.
238 All parser interface headers should precede all parser internal headers.
239 When any parser internal headers are included, the same file should
240 not include any formatter headers.
241 .Bl -tag -width Ds
242 .It Qq Pa libmandoc.h
243 Requires
244 .In sys/types.h
245 for
246 .Vt size_t
247 and
248 .Qq Pa mandoc.h
249 for
250 .Vt enum mandocerr .
251 .Pp
252 Provides
253 .Vt struct buf ,
254 utility functions needed by multiple parsers,
255 and the top-level functions to call the parsers.
256 .Pp
257 Uses the opaque types
258 .Vt struct mparse
259 from
260 .Pa read.c
261 and
262 .Vt struct roff
263 from
264 .Pa roff.c
265 for function prototypes.
266 Uses the type
267 .Vt struct roff_man
268 from
269 .Pa roff.h
270 as an opaque type for function prototypes.
271 .It Qq Pa roff_int.h
272 Requires
273 .Qq Pa roff.h
274 for
275 .Vt enum roff_type .
276 .Pp
277 Provides functions named
278 .Fn roff_*
279 to handle roff nodes and the two special functions
280 .Fn man_breakscope
281 and
282 .Fn mdoc_argv_free
283 because the latter two are needed by
284 .Qq Pa roff.c .
285 .Pp
286 Uses the types
287 .Vt struct roff_man
288 and
289 .Vt struct roff_node
290 from
291 .Pa roff.h
292 and
293 .Vt struct mdoc_arg
294 from
295 .Pa mdoc.h
296 as opaque types for function prototypes.
297 .It Qq Pa libmdoc.h
298 Requires
299 .Qq Pa roff.h
300 for
301 .Vt enum roff_tok
302 and
303 .Qq Pa mdoc.h
304 for
305 .Vt enum mdoc_*
306 and
307 .Vt struct mdoc_* .
308 .Pp
309 Provides
310 .Vt enum margserr ,
311 .Vt enum mdelim ,
312 .Vt struct mdoc_macro ,
313 and many functions internal to the
314 .Xr mdoc 7
315 parser.
316 .Pp
317 Uses the opaque type
318 .Vt struct mparse
319 from
320 .Pa read.c .
321 Uses the types
322 .Vt struct roff_man
323 and
324 .Vt struct roff_node
325 from
326 .Pa roff.h
327 as opaque types for function prototypes.
328 .Pp
329 When this header is included, the same file should not include
330 .Pa man.h ,
331 .Pa libman.h ,
332 or
333 .Pa libroff.h .
334 .It Qq Pa libman.h
335 Requires
336 .Qq Pa roff.h
337 for
338 .Vt enum roff_tok .
339 .Pp
340 Provides
341 .Vt struct man_macro
342 and some functions internal to the
343 .Xr man 7
344 parser.
345 .Pp
346 Uses the types
347 .Vt struct roff_man
348 and
349 .Vt struct roff_node
350 from
351 .Pa roff.h
352 as opaque types for function prototypes.
353 .Pp
354 When this header is included, the same file should not include
355 .Pa mdoc.h ,
356 .Pa libmdoc.h ,
357 or
358 .Pa libroff.h .
359 .It Qq Pa libroff.h
360 Requires
361 .In sys/types.h
362 for
363 .Vt size_t
364 and
365 .Qq Pa mandoc.h
366 for
367 .Vt struct tbl_*
368 and
369 .Vt struct eqn_box .
370 .Pp
371 Provides
372 .Vt enum tbl_part ,
373 .Vt struct tbl_node ,
374 .Vt struct eqn_def ,
375 .Vt struct eqn_node ,
376 and many functions internal to the
377 .Xr tbl 7
378 and
379 .Xr eqn 7
380 parsers.
381 .Pp
382 Uses the opaque type
383 .Vt struct mparse
384 from
385 .Pa read.c .
386 .Pp
387 When this header is included, the same file should not include
388 .Pa man.h ,
389 .Pa mdoc.h ,
390 .Pa libman.h ,
391 or
392 .Pa libmdoc.h .
393 .El
394 .Ss Formatter interface
395 These headers should be included after any parser interface headers.
396 No parser internal headers should be included by the same file.
397 .Bl -tag -width Ds
398 .It Qq Pa out.h
399 Requires
400 .In sys/types.h
401 for
402 .Vt size_t .
403 .Pp
404 Provides
405 .Vt enum roffscale ,
406 .Vt struct roffcol ,
407 .Vt struct roffsu ,
408 .Vt struct rofftbl ,
409 .Fn a2roffsu ,
410 and
411 .Fn tblcalc .
412 .Pp
413 Uses
414 .Vt struct tbl_span
415 from
416 .Pa mandoc.h
417 as an opaque type for function prototypes.
418 .Pp
419 When this header is included, the same file should not include
420 .Pa mansearch.h .
421 .It Qq Pa term.h
422 Requires
423 .In sys/types.h
424 for
425 .Vt size_t
426 and
427 .Qq Pa out.h
428 for
429 .Vt struct roffsu
430 and
431 .Vt struct rofftbl .
432 .Pp
433 Provides
434 .Vt enum termenc ,
435 .Vt enum termfont ,
436 .Vt enum termtype ,
437 .Vt struct termp_tbl ,
438 .Vt struct termp ,
439 .Fn roff_term_pre ,
440 and many terminal formatting functions.
441 .Pp
442 Uses the opaque type
443 .Vt struct termp_ps
444 from
445 .Pa term_ps.c .
446 Uses
447 .Vt struct tbl_span
448 and
449 .Vt struct eqn_box
450 from
451 .Pa mandoc.h
452 and
453 .Vt struct roff_meta
454 and
455 .Vt struct roff_node
456 from
457 .Pa roff.h
458 as opaque types for function prototypes.
459 .Pp
460 When this header is included, the same file should not include
461 .Pa html.h
462 or
463 .Pa mansearch.h .
464 .It Qq Pa html.h
465 Requires
466 .In sys/types.h
467 for
468 .Vt size_t
469 and
470 .Qq Pa out.h
471 for
472 .Vt struct roffsu
473 and
474 .Vt struct rofftbl .
475 .Pp
476 Provides
477 .Vt enum htmltag ,
478 .Vt enum htmlattr ,
479 .Vt enum htmlfont ,
480 .Vt struct tag ,
481 .Vt struct tagq ,
482 .Vt struct htmlpair ,
483 .Vt struct html ,
484 .Fn roff_html_pre ,
485 and many HTML formatting functions.
486 .Pp
487 Uses
488 .Vt struct tbl_span
489 and
490 .Vt struct eqn_box
491 from
492 .Pa mandoc.h
493 and
494 .Vt struct roff_node
495 from
496 .Pa roff.h
497 as opaque types for function prototypes.
498 .Pp
499 When this header is included, the same file should not include
500 .Pa term.h
501 or
502 .Pa mansearch.h .
503 .It Qq Pa tag.h
504 Requires
505 .In sys/types.h
506 for
507 .Vt size_t .
508 .Pp
509 Provides an interface to generate
510 .Xr ctags 1
511 files for the
512 .Ic :t
513 functionality mentioned in
514 .Xr man 1 .
515 .It Qq Pa main.h
516 Provides the top level steering functions for all formatters.
517 .Pp
518 Uses the type
519 .Vt struct roff_man
520 from
521 .Pa roff.h
522 as an opaque type for function prototypes.
523 .It Qq Pa manconf.h
524 Requires
525 .In sys/types.h
526 for
527 .Vt size_t .
528 .Pp
529 Provides
530 .Vt struct manconf ,
531 .Vt struct manpaths ,
532 .Vt struct manoutput ,
533 and the functions
534 .Fn manconf_parse ,
535 .Fn manconf_output ,
536 .Fn manconf_free ,
537 and
538 .Fn manpath_base .
539 .It Qq Pa mansearch.h
540 Requires
541 .In sys/types.h
542 for
543 .Vt size_t
544 and
545 .In stdint.h
546 for
547 .Vt uint64_t .
548 .Pp
549 Provides
550 .Vt enum argmode ,
551 .Vt struct manpage ,
552 .Vt struct mansearch ,
553 and the functions
554 .Fn mansearch
555 and
556 .Fn mansearch_free .
557 .Pp
558 Uses
559 .Vt struct manpaths
560 from
561 .Pa manconf.h
562 as an opaque type for function prototypes.
563 .Pp
564 When this header is included, the same file should not include
565 .Pa out.h ,
566 .Pa term.h ,
567 or
568 .Pa html.h .
569 .El