pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/mk A common documentation format is to have the variab...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/11d98b74da5f
branches:  trunk
changeset: 516963:11d98b74da5f
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Wed Aug 02 10:29:47 2006 +0000

description:
A common documentation format is to have the variable name as the first
word after the leading "#" for the comment. This format is also
recognized. The RCS Id of the current file is printed together with the
help text, so that the user can see which file defines the variable.

Removed the :M* operator for _HELP_AWK, since bmake has a bug when "" is
passed to the :M* operator. I've sent a bug report for this.

diffstat:

 mk/bsd.pkg.help.mk |  29 +++++++++++++++++++----------
 1 files changed, 19 insertions(+), 10 deletions(-)

diffs (72 lines):

diff -r 2c092de812d1 -r 11d98b74da5f mk/bsd.pkg.help.mk
--- a/mk/bsd.pkg.help.mk        Wed Aug 02 10:07:11 2006 +0000
+++ b/mk/bsd.pkg.help.mk        Wed Aug 02 10:29:47 2006 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.pkg.help.mk,v 1.1 2006/08/02 09:46:22 rillig Exp $
+# $NetBSD: bsd.pkg.help.mk,v 1.2 2006/08/02 10:29:47 rillig Exp $
 #
 
 # This is the integrated pkgsrc online help system. To query for the
@@ -13,30 +13,37 @@
 _HELP_FILES+=          mk/defaults/mk.conf
 _HELP_FILES+=          mk/bsd.prefs.mk
 _HELP_FILES+=          mk/bsd.pkg.mk
-_HELP_FILES+=          mk/*/*-vars.mk
+_HELP_FILES+=          mk/*/*.mk
 
 _HELP_AWK= \
        BEGIN {                                                         \
+               no = 0; yes = 1;                                        \
                hline = "===============";                              \
                hline = hline hline hline hline hline;                  \
-               found = 0;                                              \
-               var = 0; comment = 0; n = 0; lines[n++] = hline;        \
+               found = no; var = no; comment = no; n = 0;              \
+               rcsid = "";                                             \
        }                                                               \
        /./ {                                                           \
                lines[n++] = $$0;                                       \
        }                                                               \
-       ($$1 == VARNAME"?=") || ($$1 == "\#"VARNAME"=") {               \
+       /^\\#.*\$$.*\$$$$/ {                                            \
+               rcsid = $$0;                                            \
+       }                                                               \
+       ($$1 == VARNAME"?=") || ($$1 == "\#"VARNAME"=")                 \
+       || ($$1 == "\#" && $$2 == VARNAME) {                            \
                var = 1;                                                \
        }                                                               \
        /^\#/ {                                                         \
                comment = 1;                                            \
        }                                                               \
        /^$$/ {                                                         \
-               if (var == 1 && comment == 1) {                         \
-                       found = 1;                                      \
+               if (var && comment) {                                   \
+                       found = yes;                                    \
+                       print hline;                                    \
+                       if (rcsid != "") { print rcsid; print "\#"; }   \
                        for (i = 0; i < n; i++) { print lines[i]; }     \
                }                                                       \
-               var = 0; comment = 0; n = 0; lines[n++] = hline;        \
+               var = no; comment = no; n = 0;                          \
        }                                                               \
        END {                                                           \
                if (found) {                                            \
@@ -50,13 +57,15 @@
 TOPIC=         ${VARNAME}
 .endif
 
+.PHONY: help
 help:
 .if !defined(TOPIC)
        @${ECHO} "usage: "${MAKE:Q}" help TOPIC=<VARNAME>" 1>&2
 .else
-       @set -e; cd ${PKGSRCDIR};                                       \
+       ${_PKG_SILENT}${_PKG_DEBUG} set -e;                             \
+       cd ${PKGSRCDIR};                                                \
        { for i in ${_HELP_FILES}; do ${CAT} "$$i"; ${ECHO} ""; done; } \
-       | ${AWK} -v VARNAME=${TOPIC} '${_HELP_AWK:M*}'
+       | ${AWK} -v VARNAME=${TOPIC} '${_HELP_AWK}'
 .endif
 
 .endif



Home | Main Index | Thread Index | Old Index