From 88ea06e8737d28e212456d205e5c57aa7fc7f21d Mon Sep 17 00:00:00 2001 From: rillig Date: Sat, 5 Jan 2008 17:01:23 +0000 Subject: Instead of just recording whether a topic is relevant or not, collect all applicable keywords (like variable names, make targets or explicit keywords). This will help printing an index of all keywords. --- mk/help/help.awk | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'mk/help/help.awk') diff --git a/mk/help/help.awk b/mk/help/help.awk index 25f1ac12d48..ba20c582206 100644 --- a/mk/help/help.awk +++ b/mk/help/help.awk @@ -1,4 +1,4 @@ -# $NetBSD: help.awk,v 1.18 2007/12/13 11:48:38 rillig Exp $ +# $NetBSD: help.awk,v 1.19 2008/01/05 17:01:23 rillig Exp $ # # This program extracts the inline documentation from *.mk files. @@ -20,8 +20,8 @@ BEGIN { ignore_next_empty_line = no; delete lines; # the collected lines - relevant = no; # are the current lines relevant? nlines = 0; # the number of lines collected so far + delete keywords; # the keywords for this paragraph comment_lines = 0; # the number of comment lines so far print_noncomment_lines = yes; # for make targets, this isn't useful } @@ -30,12 +30,17 @@ BEGIN { # end of a file or by the end of all files. When there have been enough # comment lines, the topic is considered worth printing. # -function end_of_topic() { +function end_of_topic( kw, relevant) { + kw = ""; + for (i in keywords) { + kw = kw " " i; + } + relevant = (topic in keywords || lctopic in keywords || uctopic in keywords); if (relevant && comment_lines > 2) { if (found_anything) print ""; found_anything = yes; - print "===> "last_fname":"; + print "===> "last_fname " (keywords:" kw "):"; for (i = 0; i < nlines; i++) { if (print_noncomment_lines || (lines[i] ~ /^#/)) print lines[i]; @@ -44,8 +49,8 @@ function end_of_topic() { ignore_next_empty_line = yes; delete lines; - relevant = no; nlines = 0; + delete keywords; comment_lines = 0; print_noncomment_lines = yes; } @@ -70,9 +75,8 @@ always { ($1 == "#" && $2 == "Keywords:") { for (i = 3; i <= NF; i++) { w = ($i == toupper($i)) ? tolower($i) : $i; - if (w == lctopic || w == lctopic",") { - relevant = yes; - } + sub(/,$/, "", w); + keywords[w] = yes; } ignore_this_line = yes; ignore_next_empty_line = yes; @@ -116,7 +120,7 @@ NF >= 1 { (index(w1, "#"uctopic"?=") == 1) || (this_line_maybe_definition && (w == uctopic || w == uctopic":"))) { - relevant = yes; + keywords[w] = yes; } } -- cgit v1.2.3