Skip to content

Commit

Permalink
[ruby/etc] [DOC] Add minimal documents for constants
Browse files Browse the repository at this point in the history
  • Loading branch information
nobu authored and matzbot committed Dec 27, 2023
1 parent bc00297 commit c027dcf
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions ext/etc/.document
@@ -1 +1,2 @@
etc.c
constdefs.h
16 changes: 16 additions & 0 deletions ext/etc/mkconstants.rb
Expand Up @@ -35,6 +35,12 @@ def c_str(str)

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 = {}

Expand All @@ -49,6 +55,13 @@ def c_str(str)
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
Expand Down Expand Up @@ -123,6 +136,9 @@ def each_name(pat)
static void
init_constants(VALUE mod)
{
#if 0
mod = rb_define_module("Etc");
#endif
<%= gen_const_defs %>
}
EOS
Expand Down

0 comments on commit c027dcf

Please sign in to comment.