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