# -*- tcl -*-
#
# -- Extraction of meta information from a manpage (package
#    description), and associating it with package names.
#
# Copyright (c) 2005-2024 Andreas Kupries <andreas_kupries@sourceforge.net>
#
################################################################

# Take the null format as a base and extend it a bit.
dt_source fmt.null

global    data
array set data {}

proc fmt_numpasses   {}     {return 1}
proc fmt_postprocess {text} {
    global data

    # Title in required packages => This is the sole package.
    # Otherwise dump everything required.

    if {[lsearch -exact $data(require) $data(title)] >= 0} {
	return [list $data(title) $data(shortdesc) $data(desc)]
    } else {
	set res {}
	foreach p $data(require) {
	    lappend res [list $p $data(shortdesc) $data(desc)]
	}
	return [join $res \n]
    }
}
proc fmt_plain_text  {text} {return ""}
proc fmt_setup       {n}    {return}

proc fmt_manpage_begin {title section version} {
    global data
    set    data(title)     $title
    set    data(require)   {}
    set    data(desc)      ""
    set    data(shortdesc) ""
    return
}

proc fmt_moddesc   {desc}   {global data ; set data(shortdesc) $desc}
proc fmt_titledesc {desc}   {global data ; set data(desc)      $desc}
proc fmt_require   {p vs} {global data ; lappend data(require) $p ; return}

################################################################
