public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
From: kentnl@gentoo.org
To: gentoo-dev@lists.gentoo.org
Cc: vapier@gentoo.org, tools-portage@gentoo.org,
	Kent Fredric <kentnl@gentoo.org>
Subject: [gentoo-dev] [PATCH] app-portage/eclass-manpages: Add support for @DEFAULT-ASSUMED
Date: Mon,  1 May 2017 09:38:01 +1200	[thread overview]
Message-ID: <20170430213801.21789-1-kentnl@gentoo.org> (raw)

From: Kent Fredric <kentnl@gentoo.org>

@DEFAULT-ASSUMED allows eclasses to document any implied value
that internal code will assume when the ENV var is undefined.

@DEFAULT-ASSUMED should typically be used in conjunction with
@DEFAULT-UNSET, but it can be used in conjunction with either
@DEFAULT-VALUE or normal value extraction.

For instance:

  @VARIABLE: DIST_TEST
  @DEFAULT-ASSUMED: "do parallel"

This inserts an additional suffix to the generated man page heading
line so it renders as follows:

  DIST_TEST     (UNSET -> "do parallel")

But indicates that the value itself is not explicitly set by the eclass
and ebuilds should not assume it to have a value.

For instance, upon seeing such an indication, ebuild authors should
be able to tell that doing

  DIST_TEST+=" network"

Would end up producing

  DIST_TEST=" network"

Not

  DIST_TEST="do parallel network"

This is primarily for usecases where the variable is not assigned
anywhere in the top level file, but consuming functions imply a value:

  has "parallel" ${DIST_TEST:-do parallel}
---
 app-portage/eclass-manpages/files/eclass-to-manpage.awk | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/app-portage/eclass-manpages/files/eclass-to-manpage.awk b/app-portage/eclass-manpages/files/eclass-to-manpage.awk
index d6ed59efd9..772ee867d8 100644
--- a/app-portage/eclass-manpages/files/eclass-to-manpage.awk
+++ b/app-portage/eclass-manpages/files/eclass-to-manpage.awk
@@ -40,6 +40,7 @@
 # [@DEFAULT_UNSET]
 # [@INTERNAL]
 # [@REQUIRED]
+# @DEFAULT-ASSUMED: <interpreted value when not set>
 # @DEFAULT-VALUE: <initial value>
 # @DESCRIPTION:
 # <required; blurb about this variable>
@@ -50,6 +51,7 @@
 # [@DEFAULT_UNSET]
 # [@INTERNAL]
 # [@REQUIRED]
+# @DEFAULT-ASSUMED: <interpreted value when not set>
 # @DEFAULT-VALUE: <initial value>
 # @DESCRIPTION:
 # <required; blurb about this variable>
@@ -285,6 +287,7 @@ function _handle_variable() {
 	default_unset = 0
 	internal = 0
 	required = 0
+	default_assumed = ""
 	default_value = ""
 
 	# make sure people haven't specified this before (copy & paste error)
@@ -302,8 +305,12 @@ function _handle_variable() {
 			internal = 1
 		else if ($2 == "@REQUIRED")
 			required = 1
+		else if ($2 == "@DEFAULT-ASSUMED:") {
+			sub(/^# @[A-Z-]*:[[:space:]]*/,"")
+			default_assumed = $0
+		}
 		else if ($2 == "@DEFAULT-VALUE:") {
-			sub(/^# @[A-Z_]*:[[:space:]]*/,"")
+			sub(/^# @[A-Z-]*:[[:space:]]*/,"")
 			default_value = $0
 		}
 		else
@@ -343,6 +350,10 @@ function _handle_variable() {
 	if (required == 1)
 		val = val " (REQUIRED)"
 
+	if ( default_assumed != "" ) {
+		val = val " (UNSET -> \\fI" default_assumed "\\fR)"
+	}
+
 	if (internal == 1)
 		return ""
 
-- 
2.12.2



             reply	other threads:[~2017-04-30 21:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-30 21:38 kentnl [this message]
2017-05-01 16:02 ` [gentoo-dev] [PATCH] app-portage/eclass-manpages: Add support for @DEFAULT-ASSUMED Michał Górny
2017-05-01 21:25   ` Kent Fredric
2017-05-01 21:54     ` Kent Fredric

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170430213801.21789-1-kentnl@gentoo.org \
    --to=kentnl@gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    --cc=tools-portage@gentoo.org \
    --cc=vapier@gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox