[ruby/etc] [DOC] Add minimal documents for constants

https://github.com/ruby/etc/commit/97a4f798d4
This commit is contained in:
Nobuyoshi Nakada 2023-12-27 18:04:04 +09:00 committed by git
parent bc002971b6
commit c027dcfde2
2 changed files with 17 additions and 0 deletions

View File

@ -1 +1,2 @@
etc.c
constdefs.h

View File

@ -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