|
|
||||||
|
#1
|
|
|
|
|
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 |
|
|
|
#2
|
|
|
|
|
On May 4, 2009, at 20:14, Daniel Berger wrote:
[..] > 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? I added support for "ghost" methods to the ruby parser in RDoc, the same would need to be added to support constants this way. you can search around the source for GhostMethod to get an idea, and I'll be on IRC later today to help you out (or whenever). It's not too difficult a feature to add, there's tests you can copy, too. |
|
|
| Similar Threads | |
| ri, rdoc, gems, and rails One great new feature of rubygems 0.9 is that we now have ri for installed gems as well. That's super! I'm not getting this for rails, even though I have the gems... |
|
| rake + gems + rdoc - broken? Gems which previously used to install with rdocs (available via the gems rdoc server) don't seem to do so any more. And "rake rdoc" dies. Anyone else having similar... |
|
| Generated rdoc documentation is incomplete. Hello. I download ruby to the ruby-build directory from cvs, install it and want to make a html documentation. yuray@keeper:/host/p3/b/ruby-build$ ruby --version ruby 1.9.0... |
|
| Problem generaing RDoc documentation for gems Hi, I hope this is the right place to ask, I know there's a rails list as well but this does seem to me to be a more general problem with my setup. I've been trying to... |
|
| rdoc: how to generate rdoc & ri documentation of standard library? Hi, how can I generate rdoc & ri documentation of the standard library? I tried "cd /usr/local/lib/ruby; rdoc", but had to cancel it because rdoc tried eating up all my RAM... |
|
|
All times are GMT. The time now is 08:58 AM. | Privacy Policy
|