C parser drops docs under namespace variables defined in another file
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 930
- Forks
- 465
- Avg merge
- 3d 10h
- Merged PRs (30d)
- 27
Description
C parser drops docs for entries under a namespace variable defined in another file
RDoc's C parser appears unable to resolve extension namespace variables across C files for constants and methods.
Example:
/* foo.c */
VALUE mFoo;
void Init_foo(void) {
mFoo = rb_define_module("Foo");
}
/* constants.c */
rb_define_const(mFoo, "VERSION", rb_str_new_cstr("1.0.0"));
In this shape, RDoc does not know what mFoo means while parsing constants.c, so Foo::VERSION is not documented.
There is partial cross-file support for _under definitions, such as:
/* bar.c */
VALUE cBar = rb_define_class_under(mFoo, "Bar", rb_cObject);
That can work because rb_define_class_under / rb_define_module_under goes through a store-backed enclosure lookup. In other words, when RDoc is creating a class or module, it has a special path that can sometimes find the enclosing C variable from another parsed file or cache.
Constants and methods do not appear to use the same path. They only check the parser-local @known_classes map, and if mFoo is missing, the entry is silently skipped.
A workaround is to add a fake seed comment in each C file:
/* RDoc parses C files independently: mFoo = rb_define_module("Foo") */
Because RDoc scans block comments for rb_define_* patterns, this seeds mFoo => Foo for that file and documentation is generated.
Expected behavior: once mFoo is defined in one parsed C file, later C files should be able to document constants and methods under Foo, or RDoc should provide a documented way to seed cross-file C namespace variables.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Trace the C parser's handling of rb_define_const and method definitions, comparing their parser-local @known_classes lookup with the store-backed enclosure lookup used by rb_define_class_under and rb_define_module_under. Verify the behavior with the two-file mFoo example: constants and methods defined after mFoo in another file should appear under Foo, without requiring a fake seed comment.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, ruby
- Domain
- documentation, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100