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

C-Parser: ignore duplicated constants/methods #811

Closed
Hanmac opened this issue Oct 19, 2014 · 1 comment
Closed

C-Parser: ignore duplicated constants/methods #811

Hanmac opened this issue Oct 19, 2014 · 1 comment
Labels

Comments

@Hanmac
Copy link
Contributor

Hanmac commented Oct 19, 2014

SampleCode:

void define_const()
{
    if(rb_const_defined(rb_cWXColor,rb_intern("BLACK")))
        return;

    rb_define_const(rb_cWXColor,"BLACK",wrap(wxBLACK));
    rb_define_const(rb_cWXColor,"BLUE",wrap(wxBLUE));
    rb_define_const(rb_cWXColor,"CYAN",wrap(wxCYAN));
    rb_define_const(rb_cWXColor,"GREEN",wrap(wxGREEN));
    rb_define_const(rb_cWXColor,"YELLOW",wrap(wxYELLOW));
    rb_define_const(rb_cWXColor,"LIGHT_GREY",wrap(wxLIGHT_GREY));
    rb_define_const(rb_cWXColor,"RED",wrap(wxRED));
    rb_define_const(rb_cWXColor,"WHITE",wrap(wxWHITE));
}

/*
 * Document-class: WX::Color
 *
 * This class represents an Color.
*/

/* Document-const: BLACK
 * predefined Color constant.
 */
/* Document-const: BLUE
 * predefined Color constant.
 */
/* Document-const: CYAN
 * predefined Color constant.
 */
/* Document-const: GREEN
 * predefined Color constant.
 */
/* Document-const: YELLOW
 * predefined Color constant.
 */
/* Document-const: LIGHT_GREY
 * predefined Color constant.
 */
/* Document-const: RED
 * predefined Color constant.
 */
/* Document-const: WHITE
 * predefined Color constant.
 */
void Init_WXColor(VALUE rb_mWX)
{
#if 0
    rb_mWX = rb_define_module("WX");
#endif
    rb_cWXColor = rb_define_class_under(rb_mWX,"Color",rb_cObject);

#if 0

    rb_define_const(rb_cWXColor,"BLACK",wrap(wxBLACK));
    rb_define_const(rb_cWXColor,"BLUE",wrap(wxBLUE));
    rb_define_const(rb_cWXColor,"CYAN",wrap(wxCYAN));
    rb_define_const(rb_cWXColor,"GREEN",wrap(wxGREEN));
    rb_define_const(rb_cWXColor,"YELLOW",wrap(wxYELLOW));
    rb_define_const(rb_cWXColor,"LIGHT_GREY",wrap(wxLIGHT_GREY));
    rb_define_const(rb_cWXColor,"RED",wrap(wxRED));
    rb_define_const(rb_cWXColor,"WHITE",wrap(wxWHITE));
#endif

}

result in

Files:           1
Modules:         1 (    1 undocumented)
Classes:         1 (    0 undocumented)
Constants:      16 (    8 undocumented)
Methods:         0 (    0 undocumented)
 50.00% documented

while the constants are documented they are counted twice.
imo it should be prevented that yard does count them more than once

and yes both are needed, because i cant define the constants at require time and without the #if 0 rdoc does not find the constants

hm that is low prioity because i found a way around it, until its fixed in yard

@lsegal lsegal added the Feature label Oct 26, 2014
@lsegal
Copy link
Owner

lsegal commented Jul 5, 2016

Your Document-const calls are documenting a non-existent const called WXColor::Black, not WX::Color::Black. This has to do the way YARD parses the full path out of unqualified const names. Note you can more easily workaround this with inline documentation, instead of Document-const:

void Init_WXColor(VALUE rb_mWX)
{
#if 0
    rb_mWX = rb_define_module("WX");
#endif
    rb_cWXColor = rb_define_class_under(rb_mWX,"Color",rb_cObject);

#if 0
    // Predefined color constant
    rb_define_const(rb_cWXColor,"BLACK",wrap(wxBLACK));
    // Predefined color constant
    rb_define_const(rb_cWXColor,"BLUE",wrap(wxBLUE));
    // Predefined color constant
    rb_define_const(rb_cWXColor,"CYAN",wrap(wxCYAN));
    // Predefined color constant
    rb_define_const(rb_cWXColor,"GREEN",wrap(wxGREEN));
    // Predefined color constant
    rb_define_const(rb_cWXColor,"YELLOW",wrap(wxYELLOW));
    // Predefined color constant
    rb_define_const(rb_cWXColor,"LIGHT_GREY",wrap(wxLIGHT_GREY));
    // Predefined color constant
    rb_define_const(rb_cWXColor,"RED",wrap(wxRED));
    // Predefined color constant
    rb_define_const(rb_cWXColor,"WHITE",wrap(wxWHITE));
#endif
}

Marking this as closed since YARD is technically doing what it is supposed to do here.

@lsegal lsegal closed this as completed Jul 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants