1 |
vapier 10/08/21 19:25:57 |
2 |
|
3 |
Modified: eclass-to-manpage.awk |
4 |
Log: |
5 |
add @DEFAULT_UNSET, @REQUIRED, and @INTERNAL for variables |
6 |
|
7 |
Revision Changes Path |
8 |
1.16 app-portage/eclass-manpages/files/eclass-to-manpage.awk |
9 |
|
10 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-portage/eclass-manpages/files/eclass-to-manpage.awk?rev=1.16&view=markup |
11 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-portage/eclass-manpages/files/eclass-to-manpage.awk?rev=1.16&content-type=text/plain |
12 |
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/app-portage/eclass-manpages/files/eclass-to-manpage.awk?r1=1.15&r2=1.16 |
13 |
|
14 |
Index: eclass-to-manpage.awk |
15 |
=================================================================== |
16 |
RCS file: /var/cvsroot/gentoo-x86/app-portage/eclass-manpages/files/eclass-to-manpage.awk,v |
17 |
retrieving revision 1.15 |
18 |
retrieving revision 1.16 |
19 |
diff -u -r1.15 -r1.16 |
20 |
--- eclass-to-manpage.awk 9 Dec 2009 10:15:57 -0000 1.15 |
21 |
+++ eclass-to-manpage.awk 21 Aug 2010 19:25:57 -0000 1.16 |
22 |
@@ -1,6 +1,6 @@ |
23 |
# Copyright 1999-2007 Gentoo Foundation |
24 |
# Distributed under the terms of the GNU General Public License v2 |
25 |
-# $Header: /var/cvsroot/gentoo-x86/app-portage/eclass-manpages/files/eclass-to-manpage.awk,v 1.15 2009/12/09 10:15:57 vapier Exp $ |
26 |
+# $Header: /var/cvsroot/gentoo-x86/app-portage/eclass-manpages/files/eclass-to-manpage.awk,v 1.16 2010/08/21 19:25:57 vapier Exp $ |
27 |
|
28 |
# This awk converts the comment documentation found in eclasses |
29 |
# into man pages for easier/nicer reading. |
30 |
@@ -30,12 +30,18 @@ |
31 |
|
32 |
# The format of function-specific variables: |
33 |
# @VARIABLE: foo |
34 |
+# [@DEFAULT_UNSET] |
35 |
+# [@INTERNAL] |
36 |
+# [@REQUIRED] |
37 |
# @DESCRIPTION: |
38 |
# <required; blurb about this variable> |
39 |
# foo="<default value>" |
40 |
|
41 |
# The format of eclass variables: |
42 |
# @ECLASS-VARIABLE: foo |
43 |
+# [@DEFAULT_UNSET] |
44 |
+# [@INTERNAL] |
45 |
+# [@REQUIRED] |
46 |
# @DESCRIPTION: |
47 |
# <required; blurb about this variable> |
48 |
# foo="<default value>" |
49 |
@@ -46,8 +52,14 @@ |
50 |
# code by using this marker at the start and end. |
51 |
# @CODE |
52 |
|
53 |
-function _stderr_msg(text, type) { |
54 |
- print FILENAME ":" NR ":" type ": " text > "/dev/stderr" |
55 |
+function _stderr_msg(text, type, file, cnt) { |
56 |
+ if (_stderr_header_done != 1) { |
57 |
+ cnt = split(FILENAME, file, /\//) |
58 |
+ print "\n" file[cnt] ":" > "/dev/stderr" |
59 |
+ _stderr_header_done = 1 |
60 |
+ } |
61 |
+ |
62 |
+ print " " type ":" NR ": " text > "/dev/stderr" |
63 |
} |
64 |
function warn(text) { |
65 |
_stderr_msg(text, "warning") |
66 |
@@ -185,9 +197,23 @@ |
67 |
var_name = $3 |
68 |
desc = "" |
69 |
val = "" |
70 |
- |
71 |
- # grab the docs |
72 |
- getline |
73 |
+ default_unset = 0 |
74 |
+ internal = 0 |
75 |
+ required = 0 |
76 |
+ |
77 |
+ # grab the optional attributes |
78 |
+ opts = 1 |
79 |
+ while (opts) { |
80 |
+ getline |
81 |
+ if ($2 == "@DEFAULT_UNSET") |
82 |
+ default_unset = 1 |
83 |
+ else if ($2 == "@INTERNAL") |
84 |
+ internal = 1 |
85 |
+ else if ($2 == "@REQUIRED") |
86 |
+ required = 1 |
87 |
+ else |
88 |
+ opts = 0 |
89 |
+ } |
90 |
if ($2 == "@DESCRIPTION:") |
91 |
desc = eat_paragraph() |
92 |
|
93 |
@@ -202,13 +228,22 @@ |
94 |
regex = "^[[:space:]]*:[[:space:]]*[$]{" var_name ":?=(.*)}" |
95 |
val = gensub(regex, "\\1", "", $0) |
96 |
if (val == $0) { |
97 |
- warn(var_name ": unable to extract default variable content: " $0) |
98 |
+ if (default_unset + required + internal == 0) |
99 |
+ warn(var_name ": unable to extract default variable content: " $0) |
100 |
val = "" |
101 |
- } else if (val !~ /^["']/ && val ~ / /) |
102 |
+ } else if (val !~ /^["']/ && val ~ / /) { |
103 |
+ if (default_unset == 1) |
104 |
+ warn(var_name ": marked as unset, but has value: " val) |
105 |
val = "\"" val "\"" |
106 |
+ } |
107 |
} |
108 |
if (length(val)) |
109 |
val = " " op " \\fI" val "\\fR" |
110 |
+ if (required == 1) |
111 |
+ val = val " (REQUIRED)" |
112 |
+ |
113 |
+ if (internal == 1) |
114 |
+ return "" |
115 |
|
116 |
# now accumulate the stuff |
117 |
ret = \ |
118 |
@@ -222,12 +257,18 @@ |
119 |
return ret |
120 |
} |
121 |
function handle_variable() { |
122 |
- print _handle_variable() |
123 |
+ ret = _handle_variable() |
124 |
+ if (ret == "") |
125 |
+ return |
126 |
+ print ret |
127 |
} |
128 |
function handle_eclass_variable() { |
129 |
+ ret = _handle_variable() |
130 |
+ if (ret == "") |
131 |
+ return |
132 |
if (eclass_variables != "") |
133 |
eclass_variables = eclass_variables "\n" |
134 |
- eclass_variables = eclass_variables _handle_variable() |
135 |
+ eclass_variables = eclass_variables ret |
136 |
} |
137 |
|
138 |
# |