[BACK]Return to mandoc_headers.3 CVS log [TXT][DIR] Up to [cvsweb.bsd.lv] / mandoc

Annotation of mandoc/mandoc_headers.3, Revision 1.20

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

CVSweb