#!/bin/awk -f
#
# SYNOPSIS
#
# make_html_refs DOC-FILE...
#
# DESCRIPTION
#
# Generate a file containing (HTML-specific) link definitions for each API
# entry found.  e.g. if foo.txt contains "# API: bar" then we generate:
#
#   [bar]: foo.html#bar
#

/^\#+ API: / {
    file = FILENAME
    sub(/^.*\//, "", file)
    sub(/\.[^.]+$/, ".html", file)

    # For C identifiers, this should be all the mangling we need.
    sec_id = tolower($3)

    printf "[%s]: %s#%s\n", $3, file, sec_id
}

# vim: set et:
