summaryrefslogtreecommitdiff
path: root/ext/etc/mkconstants.rb
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2023-12-27 18:04:04 +0900
committergit <svn-admin@ruby-lang.org>2023-12-27 10:09:24 +0000
commitc027dcfde2bf40c45dfb0fe1b79f97b8827d89f3 (patch)
treecf05e72ceb8948cd80df79ada91306b6ed234f7f /ext/etc/mkconstants.rb
parentbc002971b6ad483dbf69b8a275c44412bb6ab954 (diff)
[ruby/etc] [DOC] Add minimal documents for constants
https://github.com/ruby/etc/commit/97a4f798d4
Diffstat (limited to 'ext/etc/mkconstants.rb')
-rw-r--r--ext/etc/mkconstants.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/ext/etc/mkconstants.rb b/ext/etc/mkconstants.rb
index a752d64519..c8ebb67767 100644
--- a/ext/etc/mkconstants.rb
+++ b/ext/etc/mkconstants.rb
@@ -35,6 +35,12 @@ opt.def_option('-H FILE', 'specify output header file') {|filename|
opt.parse!
+CONST_PREFIXES = {
+ 'SC' => 'for Etc.sysconf; See <tt>man sysconf</tt>',
+ 'CS' => 'for Etc.confstr; See <tt>man constr</tt>',
+ 'PC' => 'for IO#pathconf; See <tt>man fpathconf</tt>',
+}
+
h = {}
COMMENTS = {}
@@ -49,6 +55,13 @@ DATA.each_line {|s|
next
end
h[name] = default_value
+ if additional = CONST_PREFIXES[name[/\A_([A-Z]+)_/, 1]]
+ if comment&.match(/\w\z/)
+ comment << " " << additional
+ else
+ (comment ||= String.new) << " " << additional.sub(/\A\w/) {$&.upcase}
+ end
+ end
COMMENTS[name] = comment if comment
}
DEFS = h.to_a
@@ -123,6 +136,9 @@ result = erb_new.call(<<'EOS', nil, '%').result(binding)
static void
init_constants(VALUE mod)
{
+#if 0
+ mod = rb_define_module("Etc");
+#endif
<%= gen_const_defs %>
}
EOS