Needs a parse tree for C files
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 30/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Cần làm rõ
- Mức độ hoạt động
- Đình trệ
- Lĩnh vực
- documentation, tooling
Hướng nghiên cứu
Bắt đầu bằng cách theo dõi cách RDoc xử lý rb_define_class, rb_define_method và rb_define_module_function dựa trên các ví dụ giữa các tệp trong globals.h, ooura_fft.c và fft.c. Được coi là hoàn thành khi RDoc nhận diện các lớp hoặc mô-đun được khởi tạo trong một tệp C và được sử dụng thông qua các khai báo extern trong một tệp khác, bao gồm cả các phương thức đã được ghi tài liệu.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
In the current version of RDoc, when searching for class definition APIs such as rb_define_class and rb_define_method in a C file, if a match is found in that file, it seems to only accept the class and method definitions in that file.
This means that no matter how the method is defined in other C files, it will be ignored.
A mechanism will needed that to first gather elements from the C file and determine whether they are properly defined as classes. In this case, the parse tree would be desirable.
rb_xYYY variables used as object entities are basically the global variables, so they must be declared as extern when defining classes at the C level. However, this way does not work in outer method definitions (#pack/#unpack, etc.) because these "global variables" are not defined as classes.
In C, global variables must be initialized. A popular solution is to do the initialization in a single C file.
// global.h
#ifdef GLOBAL_VARIABLE_DEFINE
#define GLOBAL
#define GLOBAL_VAL(v) = (v)
#else
#define GLOBAL extern
#define GLOBAL_VAL(v)
#endif
This allows you to initialize variables as needed.
#define GLOBAL_VARIABLE_DEFINE // without extern
#include "global.h"
In Ruby, C's global variables are definitions, which means they have a different meaning than initialization.
Now below, definition in single file, RDoc is well parse here:
/*
* call-seq:
* bar -> nil
*
* It is a test.
*/
static VALUE
foo_bar(VALUE self)
{
return Qnil;
}
void
Init_foo()
{
rb_cFoo = rb_define_class("Foo", rb_cObject);
rb_define_method(rb_cFoo, "bar", foo_bar, 0);
}
However, a library that could become a small framework (such as image processing) is unlikely to be a single C file.
That is, it needs to be improved.
Below is a typical way I write it, and it is an example of an extension library that uses Professor Oura's FFT in Ruby.
The compiler passes it, but RDoc doesn't.
// ---(ruby/ext_extern.h)
#ifndef RUBY_EXT_EXTERN_H_INCLUDED
#define RUBY_EXT_EXTERN_H_INCLUDED
#if defined(__cplusplus)
extern "C" {
#endif
#ifdef USE_GLOBAL_VARIABLE
# define RUBY_EXT_EXTERN
#else
# define RUBY_EXT_EXTERN extern
#endif
#if defined(__cplusplus)
}
#endif
#endif /* RUBY_EXT_EXTERN_H_INCLUDED */
// ---
// ---(ruby/ooura_fft/globals.h)
#ifndef RUBY_OOURAFFT_GLOBALS_H_INCLUDED
#define RUBY_OOURAFFT_GLOBALS_H_INCLUDED
#include <ruby/internal/value.h> // VALUE
#include "ruby/ext_extern.h"
RUBY_EXT_EXTERN VALUE rb_mOouraFFT;
#endif /* RUBY_OOURAFFT_GLOBALS_H_INCLUDED */
// ---
// --- (ooura_fft.c)
#include <ruby.h>
#define USE_GLOBAL_VARIABLE
#include "ruby/ooura_fft/globals.h"
void
Init_ooura_fft(void)
{
rb_mOouraFFT = rb_define_module("OouraFFT");
InitVM(FFT);
}
// ---
// --- (fft.c)
#include <ruby.h>
#include "ruby/ooura_fft/globals.h"
// :
// :
static void InitVM_FFTMain(void);
void
InitVM_FFT(void)
{
InitVM(FFTMain);
}
// :
// :
static void
InitVM_FFTMain(void)
{
rb_define_module_function(rb_mOouraFFT, "cdft", fft_cdft, -1);
rb_define_module_function(rb_mOouraFFT, "rdft", fft_rdft, -1);
rb_define_module_function(rb_mOouraFFT, "ddct", fft_ddct, -1);
rb_define_module_function(rb_mOouraFFT, "ddst", fft_ddst, -1);
rb_define_module_function(rb_mOouraFFT, "dfct", fft_dfct, -1);
rb_define_module_function(rb_mOouraFFT, "dfst", fft_dfst, -1);
rb_define_const(rb_mOouraFFT, "USING_THREAD", rb_str_new_cstr((const char *)USING_THREAD));
}
// ---
It is expected that more extension libraries with this syntax will be available in the future. You may want to reconsider RDoc as well.
- Ngôn ngữ chính
- Ruby
- Star
- 930
- Fork
- 472
- Merge trung bình
- 2 ngày 8 giờ
- Pull request đã merge (30 ngày)
- 12
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của ruby/rdoc
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
RDoc 8.0.0 gem omits `doc/rdoc/example.rb`, which is referenced by the packaged markup documentationCó thể đã có người làm @OskarEichler đã nhận 80 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
ruby/rdoc#1759 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
markdown html excerpt includes link partsCó thể đã có người làm @anyingiit đã nhận 26 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 66/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Regexp generated from unescaped input in #expand_classCó thể đã có người làm @jaynetics đã nhận 39 ngày trước. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 25/100
Maintainer thường phản hồi trong vòng 1 ngày
Issue tương tự
-
bug f:request-creation professional
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
mysociety/alaveteli#9733 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
needs verification
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
Maintainer thường phản hồi trong vòng 13 ngày
-
🐛 bug 👩💻 équipe CE 🧑🏭 entreprises
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
betagouv/conseillers-entreprises#4808 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100