1 |
Dnia 30 kwietnia 2017 23:37:41 CEST, kentnl@g.o napisał(a): |
2 |
>From: Kent Fredric <kentnl@g.o> |
3 |
> |
4 |
>@DEFAULT-VALUE allows eclasses to document the default values they |
5 |
>will inject when eclass-to-manpage can't extract it. |
6 |
> |
7 |
>When eclass-to-manpage *can* extract it, it adds a warning when |
8 |
>the extracted value is different from that declared, (but the |
9 |
>declared value still takes precedence) |
10 |
> |
11 |
>Note: there is a pre-exisitng poorly documented hack where |
12 |
> |
13 |
> # FOO=VALUE |
14 |
> |
15 |
>In a comment serves as a fallback for literal value parsing, which |
16 |
>can supplement DEFAULT-VALUE in a less clear way. |
17 |
> |
18 |
>But due to the nature of this syntax, its not trivial to identify |
19 |
>which eclasses are, and aren't using it as variables are routinely |
20 |
>commented without intending them to be used as documentation. |
21 |
> |
22 |
>Some such commented assignments lurk in @CODE examples, which are |
23 |
>surely not intended to be extracted as their values |
24 |
> |
25 |
>Subsequently, if present, @DEFAULT-VALUE will also trump any such |
26 |
>commented assignments |
27 |
>--- |
28 |
>.../eclass-manpages/files/eclass-to-manpage.awk | 21 |
29 |
>+++++++++++++++++---- |
30 |
> 1 file changed, 17 insertions(+), 4 deletions(-) |
31 |
> |
32 |
>diff --git a/app-portage/eclass-manpages/files/eclass-to-manpage.awk |
33 |
>b/app-portage/eclass-manpages/files/eclass-to-manpage.awk |
34 |
>index 0d41f96327..d6ed59efd9 100644 |
35 |
>--- a/app-portage/eclass-manpages/files/eclass-to-manpage.awk |
36 |
>+++ b/app-portage/eclass-manpages/files/eclass-to-manpage.awk |
37 |
>@@ -40,6 +40,7 @@ |
38 |
> # [@DEFAULT_UNSET] |
39 |
> # [@INTERNAL] |
40 |
> # [@REQUIRED] |
41 |
>+# @DEFAULT-VALUE: <initial value> |
42 |
|
43 |
I think you meant to make it [optional]. |
44 |
|
45 |
> # @DESCRIPTION: |
46 |
> # <required; blurb about this variable> |
47 |
> # foo="<default value>" |
48 |
>@@ -49,6 +50,7 @@ |
49 |
> # [@DEFAULT_UNSET] |
50 |
> # [@INTERNAL] |
51 |
> # [@REQUIRED] |
52 |
>+# @DEFAULT-VALUE: <initial value> |
53 |
> # @DESCRIPTION: |
54 |
> # <required; blurb about this variable> |
55 |
> # foo="<default value>" |
56 |
>@@ -283,6 +285,7 @@ function _handle_variable() { |
57 |
> default_unset = 0 |
58 |
> internal = 0 |
59 |
> required = 0 |
60 |
>+ default_value = "" |
61 |
> |
62 |
> # make sure people haven't specified this before (copy & paste error) |
63 |
> if (all_vars[var_name]) |
64 |
>@@ -299,6 +302,10 @@ function _handle_variable() { |
65 |
> internal = 1 |
66 |
> else if ($2 == "@REQUIRED") |
67 |
> required = 1 |
68 |
>+ else if ($2 == "@DEFAULT-VALUE:") { |
69 |
>+ sub(/^# @[A-Z_]*:[[:space:]]*/,"") |
70 |
|
71 |
Any reason you can't just eat_line? |
72 |
|
73 |
>+ default_value = $0 |
74 |
>+ } |
75 |
> else |
76 |
> opts = 0 |
77 |
> } |
78 |
>@@ -315,15 +322,21 @@ function _handle_variable() { |
79 |
> op = "?=" |
80 |
> regex = "^[[:space:]]*:[[:space:]]*[$]{" var_name ":?=(.*)}" |
81 |
> val = gensub(regex, "\\1", 1, $0) |
82 |
>- if (val == $0) { |
83 |
>- if (default_unset + required + internal == 0) |
84 |
>+ } |
85 |
>+ if (default_value != "") { |
86 |
>+ if ( val != $0 && default_value != val ) |
87 |
>+ warn( var_name ": extracted different from DEFAULT-VALUE: " |
88 |
>default_value " <=> " val ) |
89 |
>+ op = "=" |
90 |
>+ val = default_value |
91 |
>+ } |
92 |
>+ if ( val == $0 ) { |
93 |
>+ if (default_unset + required + internal == 0) |
94 |
> warn(var_name ": unable to extract default variable content: " $0) |
95 |
> val = "" |
96 |
>- } else if (val !~ /^["']/ && val ~ / /) { |
97 |
>+ } else if (val !~ /^["']/ && val ~ / /) { |
98 |
> if (default_unset == 1) |
99 |
> warn(var_name ": marked as unset, but has value: " val) |
100 |
> val = "\"" val "\"" |
101 |
>- } |
102 |
> } |
103 |
> if (length(val)) |
104 |
> val = " " op " \\fI" val "\\fR" |
105 |
|
106 |
|
107 |
-- |
108 |
Best regards, |
109 |
Michał Górny (by phone) |