Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

C parser drops docs under namespace variables defined in another file

Đang mở
#1,744 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@sb123sb123 đang làm issue này rồi.

Từ ngày 24/9/2026.

  • #1831 của @sb123sb123 — đang mở

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
55/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
c, ruby
Lĩnh vực
documentation, tooling

Hướng nghiên cứu

Theo dõi cách C parser xử lý rb_define_const và các định nghĩa method, so sánh việc tra cứu @known_classes cục bộ của parser với việc tra cứu enclosure dựa trên store được rb_define_class_under và rb_define_module_under sử dụng. Xác minh hành vi bằng ví dụ mFoo gồm hai file: các constant và method được định nghĩa sau mFoo trong một file khác phải xuất hiện dưới Foo mà không cần một comment seed giả.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

bug

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.

Ngôn ngữ chính
Ruby
Star
927
Fork
467
Merge trung bình
23 giờ 47 phút
Pull request đã merge (30 ngày)
12

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của ruby/rdoc

Tất cả issue của ruby/rdoc

Issue tương tự

Thêm issue về Ruby

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.