55#include "rustbindings.h"
66#include "utils.h"
77
8+ /*
9+ * RDoc parser workaround for https://github.com/ruby/rdoc/issues/1744:
10+ * mRubydex = rb_define_module("Rubydex")
11+ */
12+
813VALUE cDeclaration ;
914VALUE cNamespace ;
1015VALUE cClass ;
@@ -46,7 +51,12 @@ VALUE rdxi_declaration_class_for_kind(CDeclarationKind kind) {
4651 }
4752}
4853
49- // Declaration#name -> String
54+ /*
55+ * call-seq:
56+ * name -> String?
57+ *
58+ * Returns the fully qualified declaration name.
59+ */
5060static VALUE rdxr_declaration_name (VALUE self ) {
5161 HandleData * data ;
5262 TypedData_Get_Struct (self , HandleData , & handle_type , data );
@@ -65,7 +75,12 @@ static VALUE rdxr_declaration_name(VALUE self) {
6575 return str ;
6676}
6777
68- // Declaration#unqualified_name -> String
78+ /*
79+ * call-seq:
80+ * unqualified_name -> String?
81+ *
82+ * Returns the declaration name without namespace qualification.
83+ */
6984static VALUE rdxr_declaration_unqualified_name (VALUE self ) {
7085 HandleData * data ;
7186 TypedData_Get_Struct (self , HandleData , & handle_type , data );
@@ -126,8 +141,12 @@ static VALUE declaration_definitions_size(VALUE self, VALUE _args, VALUE _eobj)
126141 return SIZET2NUM (len );
127142}
128143
129- // Declaration#definitions: () -> Enumerator[Definition]
130- // Returns an enumerator that yields all definitions for this declaration lazily
144+ /*
145+ * call-seq:
146+ * definitions -> Enumerator[Rubydex::Definition]
147+ *
148+ * Returns an enumerator that yields all definitions for this declaration lazily.
149+ */
131150static VALUE rdxr_declaration_definitions (VALUE self ) {
132151 if (!rb_block_given_p ()) {
133152 return rb_enumeratorize_with_size (self , rb_str_new2 ("definitions" ), 0 , NULL , declaration_definitions_size );
@@ -146,8 +165,12 @@ static VALUE rdxr_declaration_definitions(VALUE self) {
146165 return self ;
147166}
148167
149- // Declaration#member: (String member) -> Declaration
150- // Returns a declaration handle for the given member
168+ /*
169+ * call-seq:
170+ * member(name) -> Rubydex::Declaration?
171+ *
172+ * Returns a declaration handle for the named member, or nil if no member exists.
173+ */
151174static VALUE rdxr_declaration_member (VALUE self , VALUE name ) {
152175 HandleData * data ;
153176 TypedData_Get_Struct (self , HandleData , & handle_type , data );
@@ -171,8 +194,12 @@ static VALUE rdxr_declaration_member(VALUE self, VALUE name) {
171194 return rb_class_new_instance (2 , argv , decl_class );
172195}
173196
174- // Namespace#find_member: (String member, only_inherited: false) -> Declaration?
175- // Searches for a member in the ancestor chain of the declaration
197+ /*
198+ * call-seq:
199+ * find_member(name, only_inherited: false) -> Rubydex::Declaration?
200+ *
201+ * Searches for a member in the declaration's ancestor chain.
202+ */
176203static VALUE rdxr_declaration_find_member (int argc , VALUE * argv , VALUE self ) {
177204 VALUE member , opts ;
178205 rb_scan_args (argc , argv , "1:" , & member , & opts );
@@ -207,7 +234,12 @@ static VALUE rdxr_declaration_find_member(int argc, VALUE *argv, VALUE self) {
207234 return rb_class_new_instance (2 , result_argv , decl_class );
208235}
209236
210- // Declaration#singleton_class -> SingletonClass
237+ /*
238+ * call-seq:
239+ * singleton_class -> Rubydex::SingletonClass?
240+ *
241+ * Returns the singleton class declaration, or nil if none exists.
242+ */
211243static VALUE rdxr_declaration_singleton_class (VALUE self ) {
212244 HandleData * data ;
213245 TypedData_Get_Struct (self , HandleData , & handle_type , data );
@@ -227,7 +259,12 @@ static VALUE rdxr_declaration_singleton_class(VALUE self) {
227259 return rb_class_new_instance (2 , argv , decl_class );
228260}
229261
230- // Declaration#owner -> Declaration
262+ /*
263+ * call-seq:
264+ * owner -> Rubydex::Declaration
265+ *
266+ * Returns the owner declaration.
267+ */
231268static VALUE rdxr_declaration_owner (VALUE self ) {
232269 HandleData * data ;
233270 TypedData_Get_Struct (self , HandleData , & handle_type , data );
@@ -247,7 +284,12 @@ static VALUE rdxr_declaration_owner(VALUE self) {
247284 return rb_class_new_instance (2 , argv , decl_class );
248285}
249286
250- // Declaration#ancestors: () -> Enumerator[Declaration]
287+ /*
288+ * call-seq:
289+ * ancestors -> Enumerator[Rubydex::Namespace]
290+ *
291+ * Returns an enumerator that yields ancestor namespaces.
292+ */
251293static VALUE rdxr_declaration_ancestors (VALUE self ) {
252294 if (!rb_block_given_p ()) {
253295 return rb_enumeratorize (self , rb_str_new2 ("ancestors" ), 0 , NULL );
@@ -270,7 +312,12 @@ static VALUE rdxr_declaration_ancestors(VALUE self) {
270312 return self ;
271313}
272314
273- // Declaration#descendants: () -> Enumerator[Declaration]
315+ /*
316+ * call-seq:
317+ * descendants -> Enumerator[Rubydex::Namespace]
318+ *
319+ * Returns an enumerator that yields descendant namespaces.
320+ */
274321static VALUE rdxr_declaration_descendants (VALUE self ) {
275322 if (!rb_block_given_p ()) {
276323 return rb_enumeratorize (self , rb_str_new2 ("descendants" ), 0 , NULL );
@@ -293,7 +340,12 @@ static VALUE rdxr_declaration_descendants(VALUE self) {
293340 return self ;
294341}
295342
296- // Namespace#members: () -> Enumerator[Declaration]
343+ /*
344+ * call-seq:
345+ * members -> Enumerator[Rubydex::Declaration]
346+ *
347+ * Returns an enumerator that yields member declarations.
348+ */
297349static VALUE rdxr_declaration_members (VALUE self ) {
298350 if (!rb_block_given_p ()) {
299351 return rb_enumeratorize (self , rb_str_new2 ("members" ), 0 , NULL );
@@ -334,8 +386,12 @@ static VALUE constant_declaration_references_size(VALUE self, VALUE _args, VALUE
334386 return SIZET2NUM (len );
335387}
336388
337- // Namespace#references, Constant#references, ConstantAlias#references
338- // Returns an enumerator that yields constant references to this declaration
389+ /*
390+ * call-seq:
391+ * references -> Enumerator[Rubydex::ConstantReference]
392+ *
393+ * Returns an enumerator that yields constant references to this declaration.
394+ */
339395static VALUE rdxr_constant_declaration_references (VALUE self ) {
340396 if (!rb_block_given_p ()) {
341397 return rb_enumeratorize_with_size (self , rb_str_new2 ("references" ), 0 , NULL ,
@@ -377,8 +433,12 @@ static VALUE method_declaration_references_size(VALUE self, VALUE _args, VALUE _
377433 return SIZET2NUM (len );
378434}
379435
380- // Method#references
381- // Returns an enumerator that yields method references to this declaration
436+ /*
437+ * call-seq:
438+ * references -> Enumerator[Rubydex::MethodReference]
439+ *
440+ * Returns an enumerator that yields method references to this declaration.
441+ */
382442static VALUE rdxr_method_declaration_references (VALUE self ) {
383443 if (!rb_block_given_p ()) {
384444 return rb_enumeratorize_with_size (self , rb_str_new2 ("references" ), 0 , NULL ,
@@ -402,7 +462,12 @@ static VALUE rdxr_method_declaration_references(VALUE self) {
402462 return self ;
403463}
404464
405- // Placeholder for variable declarations that don't yet support references
465+ /*
466+ * call-seq:
467+ * references -> Array[untyped]
468+ *
469+ * Returns an empty array because variable declarations do not yet support reference lookup.
470+ */
406471static VALUE rdxr_variable_declaration_references (VALUE self ) {
407472 return rb_ary_new ();
408473}
@@ -420,7 +485,12 @@ static VALUE rdxi_visibility_to_symbol(CVisibility visibility) {
420485 }
421486}
422487
423- // Declaration#visibility -> Symbol
488+ /*
489+ * call-seq:
490+ * visibility -> Symbol
491+ *
492+ * Returns the declaration visibility.
493+ */
424494static VALUE rdxr_declaration_visibility (VALUE self ) {
425495 HandleData * data ;
426496 TypedData_Get_Struct (self , HandleData , & handle_type , data );
@@ -439,9 +509,13 @@ static VALUE rdxr_declaration_visibility(VALUE self) {
439509 return symbol ;
440510}
441511
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
512+ /*
513+ * call-seq:
514+ * target -> Rubydex::Declaration?
515+ *
516+ * Returns the first resolved target declaration for this constant alias, or nil if none of its definitions resolved to
517+ * a target.
518+ */
445519static VALUE rdxr_constant_alias_target (VALUE self ) {
446520 HandleData * data ;
447521 TypedData_Get_Struct (self , HandleData , & handle_type , data );
0 commit comments