Skip to content

Commit caef2cb

Browse files
committed
Document C-backed Ruby APIs for RDoc
1 parent 52c5273 commit caef2cb

5 files changed

Lines changed: 369 additions & 111 deletions

File tree

ext/rubydex/declaration.c

Lines changed: 91 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,12 @@ VALUE rdxi_declaration_class_for_kind(CDeclarationKind kind) {
4646
}
4747
}
4848

49-
// Declaration#name -> String
49+
/*
50+
* call-seq:
51+
* name -> String?
52+
*
53+
* Returns the fully qualified declaration name.
54+
*/
5055
static VALUE rdxr_declaration_name(VALUE self) {
5156
HandleData *data;
5257
TypedData_Get_Struct(self, HandleData, &handle_type, data);
@@ -65,7 +70,12 @@ static VALUE rdxr_declaration_name(VALUE self) {
6570
return str;
6671
}
6772

68-
// Declaration#unqualified_name -> String
73+
/*
74+
* call-seq:
75+
* unqualified_name -> String?
76+
*
77+
* Returns the declaration name without namespace qualification.
78+
*/
6979
static VALUE rdxr_declaration_unqualified_name(VALUE self) {
7080
HandleData *data;
7181
TypedData_Get_Struct(self, HandleData, &handle_type, data);
@@ -126,8 +136,12 @@ static VALUE declaration_definitions_size(VALUE self, VALUE _args, VALUE _eobj)
126136
return SIZET2NUM(len);
127137
}
128138

129-
// Declaration#definitions: () -> Enumerator[Definition]
130-
// Returns an enumerator that yields all definitions for this declaration lazily
139+
/*
140+
* call-seq:
141+
* definitions -> Enumerator[Rubydex::Definition]
142+
*
143+
* Returns an enumerator that yields all definitions for this declaration lazily.
144+
*/
131145
static VALUE rdxr_declaration_definitions(VALUE self) {
132146
if (!rb_block_given_p()) {
133147
return rb_enumeratorize_with_size(self, rb_str_new2("definitions"), 0, NULL, declaration_definitions_size);
@@ -146,8 +160,12 @@ static VALUE rdxr_declaration_definitions(VALUE self) {
146160
return self;
147161
}
148162

149-
// Declaration#member: (String member) -> Declaration
150-
// Returns a declaration handle for the given member
163+
/*
164+
* call-seq:
165+
* member(name) -> Rubydex::Declaration?
166+
*
167+
* Returns a declaration handle for the named member, or nil if no member exists.
168+
*/
151169
static VALUE rdxr_declaration_member(VALUE self, VALUE name) {
152170
HandleData *data;
153171
TypedData_Get_Struct(self, HandleData, &handle_type, data);
@@ -171,8 +189,12 @@ static VALUE rdxr_declaration_member(VALUE self, VALUE name) {
171189
return rb_class_new_instance(2, argv, decl_class);
172190
}
173191

174-
// Namespace#find_member: (String member, only_inherited: false) -> Declaration?
175-
// Searches for a member in the ancestor chain of the declaration
192+
/*
193+
* call-seq:
194+
* find_member(name, only_inherited: false) -> Rubydex::Declaration?
195+
*
196+
* Searches for a member in the declaration's ancestor chain.
197+
*/
176198
static VALUE rdxr_declaration_find_member(int argc, VALUE *argv, VALUE self) {
177199
VALUE member, opts;
178200
rb_scan_args(argc, argv, "1:", &member, &opts);
@@ -207,7 +229,12 @@ static VALUE rdxr_declaration_find_member(int argc, VALUE *argv, VALUE self) {
207229
return rb_class_new_instance(2, result_argv, decl_class);
208230
}
209231

210-
// Declaration#singleton_class -> SingletonClass
232+
/*
233+
* call-seq:
234+
* singleton_class -> Rubydex::SingletonClass?
235+
*
236+
* Returns the singleton class declaration, or nil if none exists.
237+
*/
211238
static VALUE rdxr_declaration_singleton_class(VALUE self) {
212239
HandleData *data;
213240
TypedData_Get_Struct(self, HandleData, &handle_type, data);
@@ -227,7 +254,12 @@ static VALUE rdxr_declaration_singleton_class(VALUE self) {
227254
return rb_class_new_instance(2, argv, decl_class);
228255
}
229256

230-
// Declaration#owner -> Declaration
257+
/*
258+
* call-seq:
259+
* owner -> Rubydex::Declaration
260+
*
261+
* Returns the owner declaration.
262+
*/
231263
static VALUE rdxr_declaration_owner(VALUE self) {
232264
HandleData *data;
233265
TypedData_Get_Struct(self, HandleData, &handle_type, data);
@@ -247,7 +279,12 @@ static VALUE rdxr_declaration_owner(VALUE self) {
247279
return rb_class_new_instance(2, argv, decl_class);
248280
}
249281

250-
// Declaration#ancestors: () -> Enumerator[Declaration]
282+
/*
283+
* call-seq:
284+
* ancestors -> Enumerator[Rubydex::Namespace]
285+
*
286+
* Returns an enumerator that yields ancestor namespaces.
287+
*/
251288
static VALUE rdxr_declaration_ancestors(VALUE self) {
252289
if (!rb_block_given_p()) {
253290
return rb_enumeratorize(self, rb_str_new2("ancestors"), 0, NULL);
@@ -270,7 +307,12 @@ static VALUE rdxr_declaration_ancestors(VALUE self) {
270307
return self;
271308
}
272309

273-
// Declaration#descendants: () -> Enumerator[Declaration]
310+
/*
311+
* call-seq:
312+
* descendants -> Enumerator[Rubydex::Namespace]
313+
*
314+
* Returns an enumerator that yields descendant namespaces.
315+
*/
274316
static VALUE rdxr_declaration_descendants(VALUE self) {
275317
if (!rb_block_given_p()) {
276318
return rb_enumeratorize(self, rb_str_new2("descendants"), 0, NULL);
@@ -293,7 +335,12 @@ static VALUE rdxr_declaration_descendants(VALUE self) {
293335
return self;
294336
}
295337

296-
// Namespace#members: () -> Enumerator[Declaration]
338+
/*
339+
* call-seq:
340+
* members -> Enumerator[Rubydex::Declaration]
341+
*
342+
* Returns an enumerator that yields member declarations.
343+
*/
297344
static VALUE rdxr_declaration_members(VALUE self) {
298345
if (!rb_block_given_p()) {
299346
return rb_enumeratorize(self, rb_str_new2("members"), 0, NULL);
@@ -334,8 +381,12 @@ static VALUE constant_declaration_references_size(VALUE self, VALUE _args, VALUE
334381
return SIZET2NUM(len);
335382
}
336383

337-
// Namespace#references, Constant#references, ConstantAlias#references
338-
// Returns an enumerator that yields constant references to this declaration
384+
/*
385+
* call-seq:
386+
* references -> Enumerator[Rubydex::ConstantReference]
387+
*
388+
* Returns an enumerator that yields constant references to this declaration.
389+
*/
339390
static VALUE rdxr_constant_declaration_references(VALUE self) {
340391
if (!rb_block_given_p()) {
341392
return rb_enumeratorize_with_size(self, rb_str_new2("references"), 0, NULL,
@@ -377,8 +428,12 @@ static VALUE method_declaration_references_size(VALUE self, VALUE _args, VALUE _
377428
return SIZET2NUM(len);
378429
}
379430

380-
// Method#references
381-
// Returns an enumerator that yields method references to this declaration
431+
/*
432+
* call-seq:
433+
* references -> Enumerator[Rubydex::MethodReference]
434+
*
435+
* Returns an enumerator that yields method references to this declaration.
436+
*/
382437
static VALUE rdxr_method_declaration_references(VALUE self) {
383438
if (!rb_block_given_p()) {
384439
return rb_enumeratorize_with_size(self, rb_str_new2("references"), 0, NULL,
@@ -402,7 +457,12 @@ static VALUE rdxr_method_declaration_references(VALUE self) {
402457
return self;
403458
}
404459

405-
// Placeholder for variable declarations that don't yet support references
460+
/*
461+
* call-seq:
462+
* references -> Array[untyped]
463+
*
464+
* Returns an empty array because variable declarations do not yet support reference lookup.
465+
*/
406466
static VALUE rdxr_variable_declaration_references(VALUE self) {
407467
return rb_ary_new();
408468
}
@@ -420,7 +480,12 @@ static VALUE rdxi_visibility_to_symbol(CVisibility visibility) {
420480
}
421481
}
422482

423-
// Declaration#visibility -> Symbol
483+
/*
484+
* call-seq:
485+
* visibility -> Symbol
486+
*
487+
* Returns the declaration visibility.
488+
*/
424489
static VALUE rdxr_declaration_visibility(VALUE self) {
425490
HandleData *data;
426491
TypedData_Get_Struct(self, HandleData, &handle_type, data);
@@ -439,9 +504,13 @@ static VALUE rdxr_declaration_visibility(VALUE self) {
439504
return symbol;
440505
}
441506

442-
// ConstantAlias#target -> Declaration?
443-
// Returns the first resolved target declaration for this constant alias, or nil if none of its definitions resolved to
444-
// a target
507+
/*
508+
* call-seq:
509+
* target -> Rubydex::Declaration?
510+
*
511+
* Returns the first resolved target declaration for this constant alias, or nil if none of its definitions resolved to
512+
* a target.
513+
*/
445514
static VALUE rdxr_constant_alias_target(VALUE self) {
446515
HandleData *data;
447516
TypedData_Get_Struct(self, HandleData, &handle_type, data);

0 commit comments

Comments
 (0)