From: Daniel Berger Date: 2009-05-05T12:14:51+09:00 Subject: RDoc, gems, and documentation for dynamically generated constants Hi, I've got a library that dynamically generates constants the moment it's loaded. It looks something like this at the top of the file: ['ALPHA', 'BETA', 'GAMMA'].each{ |name| Dir.const_set(name, 1) } The problem is that the constants aren't documented at all when the gem is installed. I'd like to be able to document those constants for rubygems so that, when the library is installed I can attach a comment to each constant. I tried something like this: require 'rdoc/constant' ['ALPHA', 'BETA', 'GAMMA'].each{ |name| Dir.const_set(name, 1) RDoc::Constant.new(name, 1, "Dynamically generated constant # {name}") } But that doesn't work because rubygems doesn't actually require the file, it just parses it, so the RDoc::Constant objects are never generated (I think). What's the best way to handle this, assuming it's possible? Regards, Dan