From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 5DF4F139694 for ; Mon, 1 May 2017 10:14:27 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 6367BE0DF3; Mon, 1 May 2017 10:14:18 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id F277AE0CF3 for ; Mon, 1 May 2017 10:14:17 +0000 (UTC) Received: from [10.99.183.21] (public-gprs384117.centertel.pl [37.47.131.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: mgorny) by smtp.gentoo.org (Postfix) with ESMTPSA id A86073416AB; Mon, 1 May 2017 10:14:13 +0000 (UTC) Date: Mon, 01 May 2017 12:14:01 +0200 User-Agent: K-9 Mail for Android In-Reply-To: <20170430213741.21740-1-kentnl@gentoo.org> References: <20170430213741.21740-1-kentnl@gentoo.org> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [gentoo-dev] [PATCH] app-portage/eclass-manpages: Add support for @DEFAULT-VALUE To: gentoo-dev@lists.gentoo.org,kentnl@gentoo.org CC: vapier@gentoo.org,tools-portage@gentoo.org,Kent Fredric From: =?UTF-8?Q?Micha=C5=82_G=C3=B3rny?= Message-ID: X-Archives-Salt: ac081ab1-0202-4f35-863b-130b71bec7c7 X-Archives-Hash: a71ef1498eb498f0f7507dede6bdad1e Dnia 30 kwietnia 2017 23:37:41 CEST, kentnl@gentoo=2Eorg napisa=C5=82(a): >From: Kent Fredric > >@DEFAULT-VALUE allows eclasses to document the default values they >will inject when eclass-to-manpage can't extract it=2E > >When eclass-to-manpage *can* extract it, it adds a warning when >the extracted value is different from that declared, (but the >declared value still takes precedence) > >Note: there is a pre-exisitng poorly documented hack where > > # FOO=3DVALUE > >In a comment serves as a fallback for literal value parsing, which >can supplement DEFAULT-VALUE in a less clear way=2E > >But due to the nature of this syntax, its not trivial to identify >which eclasses are, and aren't using it as variables are routinely >commented without intending them to be used as documentation=2E > >Some such commented assignments lurk in @CODE examples, which are >surely not intended to be extracted as their values > >Subsequently, if present, @DEFAULT-VALUE will also trump any such >commented assignments >--- >=2E=2E=2E/eclass-manpages/files/eclass-to-manpage=2Eawk | 21 >+++++++++++++++++---- > 1 file changed, 17 insertions(+), 4 deletions(-) > >diff --git a/app-portage/eclass-manpages/files/eclass-to-manpage=2Eawk >b/app-portage/eclass-manpages/files/eclass-to-manpage=2Eawk >index 0d41f96327=2E=2Ed6ed59efd9 100644 >--- a/app-portage/eclass-manpages/files/eclass-to-manpage=2Eawk >+++ b/app-portage/eclass-manpages/files/eclass-to-manpage=2Eawk >@@ -40,6 +40,7 @@ > # [@DEFAULT_UNSET] > # [@INTERNAL] > # [@REQUIRED] >+# @DEFAULT-VALUE: I think you meant to make it [optional]=2E > # @DESCRIPTION: > # > # foo=3D"" >@@ -49,6 +50,7 @@ > # [@DEFAULT_UNSET] > # [@INTERNAL] > # [@REQUIRED] >+# @DEFAULT-VALUE: > # @DESCRIPTION: > # > # foo=3D"" >@@ -283,6 +285,7 @@ function _handle_variable() { > default_unset =3D 0 > internal =3D 0 > required =3D 0 >+ default_value =3D "" >=20 > # make sure people haven't specified this before (copy & paste error) > if (all_vars[var_name]) >@@ -299,6 +302,10 @@ function _handle_variable() { > internal =3D 1 > else if ($2 =3D=3D "@REQUIRED") > required =3D 1 >+ else if ($2 =3D=3D "@DEFAULT-VALUE:") { >+ sub(/^# @[A-Z_]*:[[:space:]]*/,"") Any reason you can't just eat_line? >+ default_value =3D $0 >+ } > else > opts =3D 0 > } >@@ -315,15 +322,21 @@ function _handle_variable() { > op =3D "?=3D" > regex =3D "^[[:space:]]*:[[:space:]]*[$]{" var_name ":?=3D(=2E*)}" > val =3D gensub(regex, "\\1", 1, $0) >- if (val =3D=3D $0) { >- if (default_unset + required + internal =3D=3D 0) >+ } >+ if (default_value !=3D "") { >+ if ( val !=3D $0 && default_value !=3D val ) >+ warn( var_name ": extracted different from DEFAULT-VALUE: " >default_value " <=3D> " val ) >+ op =3D "=3D" >+ val =3D default_value >+ } >+ if ( val =3D=3D $0 ) { >+ if (default_unset + required + internal =3D=3D 0) > warn(var_name ": unable to extract default variable content: " $0) > val =3D "" >- } else if (val !~ /^["']/ && val ~ / /) { >+ } else if (val !~ /^["']/ && val ~ / /) { > if (default_unset =3D=3D 1) > warn(var_name ": marked as unset, but has value: " val) > val =3D "\"" val "\"" >- } > } > if (length(val)) > val =3D " " op " \\fI" val "\\fR" --=20 Best regards, Micha=C5=82 G=C3=B3rny (by phone)