Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing constants possibly related to mixed c/rb and nested classes #399

Open
dsvensson opened this issue Mar 17, 2016 · 13 comments
Open

Missing constants possibly related to mixed c/rb and nested classes #399

dsvensson opened this issue Mar 17, 2016 · 13 comments
Labels

Comments

@dsvensson
Copy link

Minimal test case to reproduce:

Create two files,

async.rb:

class Xmms::Collection::Async
end

collection.c:

void
Init_Collection()
{
    mXmms = rb_define_module("Xmms");

    cColl = rb_define_class_under(mXmms, "Collection", rb_cObject);

    /* Document-const: Xmms::Collection::NS_ALL
     *
     * I am documentation */
    rb_define_const(cColl, "NS_ALL", rb_str_new2(XMMS_COLLECTION_NS_ALL));
}

Build with:
rdoc async.rb collection.c

And notice the lack of the NS_ALL constant.

drbrain added a commit that referenced this issue Mar 17, 2016
When an item is not in any section it ends up in the nil section.
Unfortunately RDoc creates a separate Section object between grouping
and display time which would cause items to disappear from a section at
HTML generation time.

Now that two Section objects with the same title map to the same Hash
key the constants will not disappear.

Fixes bug #399
@drbrain
Copy link
Member

drbrain commented Mar 17, 2016

Fixed!

@drbrain drbrain added the Bug label Mar 17, 2016
@dsvensson
Copy link
Author

Any plans for a new release any time soon?

@zzak
Copy link
Member

zzak commented Mar 19, 2016

I'll make a bug-fix release in the next day or two, thank you!

@dsvensson
Copy link
Author

Should this also cover refering to constants that were previously not emitted in the documentation due to this bug?

Here I access the constant via irb:

$ irb
irb(main):001:0> require "xmmsclient"
=> true
irb(main):002:0> Xmms::Collection::NS_ALL
=> "*"

If I however type Xmms::Collection::NS_ALL, defined in rb_collection.c, in the comment for a method in the file that declares Xmms::Client, rb_xmmsclient.c, I will not get a link for that constant. Nor will I if I type "Xmms::Collection::NS_ALL" in the comment of any method defined in the same file as NS_ALL. If I instead type "NS_ALL" in a comment of a method defined in the same file as NS_ALL, I will get a link, so maybe Xmms::Collection::NS_ALL is an invalid syntax in rdoc when it comes to constants? Anyways.. if I go back to refering to simply "NS_ALL" in another file rather than the same - I will not get any link.

The files in question for the whole of this issue are found at:
https://github.com/dsvensson/xmms2-devel/tree/master/src/clients/lib/ruby

@zzak
Copy link
Member

zzak commented Mar 21, 2016

@dsvensson Does it work (from another file than this constant is defined) if you use the entire name like Xmms::Collection::NS_ALL? For example, only "NS_ALL" isn't linking in another file?

@dsvensson
Copy link
Author

No. Full namespace+constant doesn't work in any file.

@zzak
Copy link
Member

zzak commented Mar 21, 2016

Ugh :(

@dsvensson are you testing with master?

@dsvensson
Copy link
Author

Not really. I tried "rake package" and installd the resulting gem file (name oddly contained "borked" or somesuch). "which rdoc" points to the binary under my user's home dir. When running rdoc it seems as if it still uses parts of my system wide version so I removed the gem again and applied the patch for this issue on the system wide one (Fedora 23). This makes the constant emitting work and my docs have all the methods/constant that should be there. The linking is however broken. I run "rdoc src/clients/lib/ruby/*.{c,rb}" on the repo mentioned above and under Xmms::Client there is a doc reference to Xmms::Collection::NS_ALL that will not become a link. Does that work for you? What am I missing with my gem installation of rdoc, it would obviously be better if I used master properly.

@zzak
Copy link
Member

zzak commented Mar 21, 2016

Hmm, you should be able to install the gem package and Ruby will pick the newest version.

You could try patching the install you have, but that seems problematic.

If you have a smaller reproduce, that would help! Can you reproduce it with the code you originally submitted in the issue description?

@dsvensson
Copy link
Author

Werid.. pulled again and now I got a rdoc-4.2.3.gem instead of rdoc-0.borked.gem, and rdoc --version now prints the correct version - 4.2.3, and after reinstalling my system wide rdoc such that it is no longer patched, the local user gem with rdoc from master now produces the correct output, except for the missing link when using Xmms::Collection::NS_ALL (defined in rb_collection.c) in the comment of c_coll_list function in rb_xmmsclient.c in the repository linked above. I'll have a look if the const links are broken in the example you talk about now.

@dsvensson
Copy link
Author

Yep, added a client.c together with the two files mentioned in the original description, it's broken.

/*
 * call-seq:
 * xc.coll_list([ns]) -> result
 *
 * Trying all permutations here that I can imagine, just to be sure, nothing works. 
 * Xmms::Collection::NS_ALL NS_ALL ::NS_ALL.
 */
static VALUE
c_coll_list (int argc, VALUE *argv, VALUE self)
{
    return NULL;
}

void
Init_Client()
{
    mXmms = rb_define_module("Xmms");
    c = rb_define_class_under(mXmms, "Client", rb_cObject);
    rb_define_method (c, "coll_list", c_coll_list, -1);
}

@zzak
Copy link
Member

zzak commented Mar 22, 2016

So after some poking, I was able to reproduce this only when trying to refer to the constant from another class. Within a different file is ok, as long as it's in the same class.

Here are the files I used to reproduce:

# ok.rb
module Zomg
  class Wtf
    # Check out Zomg::Wtf::BBQ
    # or BBQ
    # or maybe even ::BBQ
    # it should be there, i promise!
    def rly
      puts "i'm a method"
    end
  end
end
# rly.rb
class Rly
  # this is another method
  # perhaps we can reference Zomg::Wtf::BBQ from here?
  # well
  # how about at least the class? Zomg::Wtf
  def asdf
  end
end
// zomg.c
void
Init_Zomg()
{
    zomg = rb_define_module("Zomg");
    wtf = rb_define_class_under(zomg, "Wtf", rb_cObject);

    /* Document-const: Zomg::Wtf::BBQ
     *
     * zomgzomgozmg */
    rb_define_const(wtf, "BBQ", Qnil);
}

@zzak zzak closed this as completed in 86c8448 Mar 25, 2016
@zzak zzak reopened this Mar 25, 2016
@zzak
Copy link
Member

zzak commented Mar 25, 2016

After some debugging, I was able to fix a bug when using the full constant name within the same class/context wasn't linking.

I'm, however, stumped as to how to fix this for another class not in the current context.. /cc @drbrain

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

3 participants