From 820631df04d06307f833ce08b40cb2ff316d505e Mon Sep 17 00:00:00 2001 From: Stan Lo Date: Wed, 24 Jun 2026 19:47:51 +0100 Subject: [PATCH 1/3] Add RDoc documentation site infrastructure --- .document | 14 +++++++++ .github/workflows/pages.yml | 49 ++++++++++++++++++++++++++++++ .gitignore | 1 + .rdoc_options | 16 ++++++++++ Gemfile | 1 + Gemfile.lock | 21 +++++++------ Rakefile | 60 +++++++++++++++++++++++++++++++++++++ docs/rdoc-extension-root.c | 11 +++++++ ext/rubydex/graph.c | 9 ++++-- 9 files changed, 170 insertions(+), 12 deletions(-) create mode 100644 .document create mode 100644 .github/workflows/pages.yml create mode 100644 .rdoc_options create mode 100644 docs/rdoc-extension-root.c diff --git a/.document b/.document new file mode 100644 index 000000000..d21baf90e --- /dev/null +++ b/.document @@ -0,0 +1,14 @@ +README.md +CONTRIBUTING.md +docs/*.md +docs/rdoc-extension-root.c +lib +ext/rubydex/rubydex.c +ext/rubydex/graph.c +ext/rubydex/declaration.c +ext/rubydex/definition.c +ext/rubydex/document.c +ext/rubydex/reference.c +ext/rubydex/signature.c +ext/rubydex/location.c +ext/rubydex/diagnostic.c diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml new file mode 100644 index 000000000..f21de9c63 --- /dev/null +++ b/.github/workflows/pages.yml @@ -0,0 +1,49 @@ +name: Deploy documentation to GitHub Pages + +on: + push: + branches: ["main"] + workflow_dispatch: + +permissions: + contents: read + pages: write + id-token: write + +concurrency: + group: pages + cancel-in-progress: true + +jobs: + build: + runs-on: ubuntu-latest + if: ${{ github.repository == 'Shopify/rubydex' }} + steps: + - name: Checkout + uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 + + - name: Set up Ruby + uses: ruby/setup-ruby@89f90524b88a01fe6e0b732220432cc6142926af # v1.313.0 + with: + ruby-version: "3.4" + bundler-cache: true + + - name: Setup Pages + uses: actions/configure-pages@v6 + + - name: Build and verify documentation + run: bundle exec rake rdoc:verify + + - name: Upload artifact + uses: actions/upload-pages-artifact@v5 + + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + needs: build + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v5 diff --git a/.gitignore b/.gitignore index db8bd90aa..d27ceb7c3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ /.bundle/ /.yardoc /_yardoc/ +/_site/ /coverage/ /doc/ /pkg/ diff --git a/.rdoc_options b/.rdoc_options new file mode 100644 index 000000000..1f9b43c76 --- /dev/null +++ b/.rdoc_options @@ -0,0 +1,16 @@ +op_dir: _site +title: Rubydex +main_page: README.md + +exclude: +- AGENTS.md +- CLAUDE.md +- tmp +- rust + +footer_content: + DOCUMENTATION: + Home: index.html + RESOURCES: + GitHub Repository: https://github.com/Shopify/rubydex + Issue Tracker: https://github.com/Shopify/rubydex/issues diff --git a/Gemfile b/Gemfile index 1c31710fc..793edf89f 100644 --- a/Gemfile +++ b/Gemfile @@ -8,6 +8,7 @@ gemspec gem "rake", "~> 13.3" gem "rake-compiler" gem "minitest" +gem "rdoc", git: "https://github.com/ruby/rdoc.git", ref: "daa7768b81c703b84c796bf60c27977c62cd4aa1" gem "rubocop" gem "rubocop-shopify" gem "extconf_compile_commands_json" diff --git a/Gemfile.lock b/Gemfile.lock index 7bf0cd5a7..31fa01eaf 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,3 +1,14 @@ +GIT + remote: https://github.com/ruby/rdoc.git + revision: daa7768b81c703b84c796bf60c27977c62cd4aa1 + ref: daa7768b81c703b84c796bf60c27977c62cd4aa1 + specs: + rdoc (7.2.0) + erb + prism (>= 1.6.0) + rbs (>= 4.0.0) + tsort + PATH remote: . specs: @@ -7,7 +18,6 @@ GEM remote: https://rubygems.org/ specs: ast (2.4.3) - date (3.5.1) drb (2.2.3) erb (6.0.4) extconf_compile_commands_json (0.0.7) @@ -40,9 +50,6 @@ GEM prettyprint prettyprint (0.2.0) prism (1.9.0) - psych (5.3.1) - date - stringio racc (1.8.1) rainbow (3.1.1) rake (13.3.1) @@ -52,10 +59,6 @@ GEM logger prism (>= 1.6.0) tsort - rdoc (7.2.0) - erb - psych (>= 4.0.0) - tsort regexp_parser (2.12.0) reline (0.6.3) io-console (~> 0.5) @@ -78,7 +81,6 @@ GEM ruby-progressbar (1.13.0) ruby_memcheck (3.0.1) nokogiri - stringio (3.2.0) tsort (0.2.0) unicode-display_width (3.2.0) unicode-emoji (~> 4.1) @@ -96,6 +98,7 @@ DEPENDENCIES rake (~> 13.3) rake-compiler rbs + rdoc! rubocop rubocop-shopify ruby_memcheck diff --git a/Rakefile b/Rakefile index e97a95f6e..71f8762e8 100644 --- a/Rakefile +++ b/Rakefile @@ -4,6 +4,7 @@ require "bundler/gem_tasks" require "rubocop/rake_task" require "rake/extensiontask" require "rake/testtask" +require "rdoc/task" GEMSPEC = Gem::Specification.load("rubydex.gemspec") @@ -28,6 +29,65 @@ end RuboCop::RakeTask.new +RDoc::Task.new do |doc| + doc.rdoc_dir = "_site" +end + +namespace :rdoc do + desc "Verify the generated RDoc site includes the public Ruby and native extension APIs" + task :verify do + Rake::Task["rdoc"].invoke + + html_files = FileList["_site/**/*.html"] + abort "Generated RDoc site is empty" if html_files.empty? + + expected_pages = { + "_site/Rubydex/Graph.html" => [ + 'id="class-rubydex-graph"', + 'id="method-i-index_workspace"', + 'id="method-i-workspace_paths"', + 'id="method-i-index_all"', + 'id="method-i-index_source"', + 'index_source(uri, source, language_id)', + 'id="method-i-keyword"', + 'id="method-i-exclude_paths"', + 'id="method-i-resolve_constant"', + ], + "_site/Rubydex/Declaration.html" => [ + 'id="class-rubydex-declaration"', + ], + "_site/Rubydex/Signature.html" => [ + 'id="class-rubydex-signature"', + ], + "_site/Rubydex/Document.html" => [ + 'id="class-rubydex-document"', + 'id="method-i-uri"', + 'id="method-i-definitions"', + ], + "_site/Rubydex/Definition.html" => [ + 'id="class-rubydex-definition"', + 'id="method-i-location"', + 'id="method-i-comments"', + ], + "_site/Rubydex/ResolvedConstantReference.html" => [ + 'id="class-rubydex-resolvedconstantreference"', + 'id="method-i-declaration"', + ], + } + + missing = expected_pages.flat_map do |file, entries| + unless File.exist?(file) + next ["#{file} was not generated"] + end + + content = File.read(file) + entries.reject { |entry| content.include?(entry) }.map { |entry| "#{file}: #{entry}" } + end + + abort "Generated RDoc site is missing expected API entries:\n - #{missing.join("\n - ")}" unless missing.empty? + end +end + task :lint do puts "******** Linting ********\n" Rake::Task["rubocop"].invoke diff --git a/docs/rdoc-extension-root.c b/docs/rdoc-extension-root.c new file mode 100644 index 000000000..63354deaf --- /dev/null +++ b/docs/rdoc-extension-root.c @@ -0,0 +1,11 @@ +void Init_rubydex_rdoc(void) { + /* + * Document-module: Rubydex + * + * Namespace for Rubydex's Ruby API. + * + * This RDoc-only file seeds the C parser with the root module variable + * before it scans the real extension sources under ext/rubydex. + */ + mRubydex = rb_define_module("Rubydex"); +} diff --git a/ext/rubydex/graph.c b/ext/rubydex/graph.c index 15912be63..320f9e56f 100644 --- a/ext/rubydex/graph.c +++ b/ext/rubydex/graph.c @@ -99,9 +99,12 @@ static VALUE rdxr_graph_index_all(VALUE self, VALUE file_paths) { return array; } -// Indexes a single source string in memory, dispatching to the appropriate indexer based on language_id -// -// Graph#index_source: (String uri, String source, String language_id) -> void +/* + * call-seq: + * index_source(uri, source, language_id) -> nil + * + * Indexes a single source string in memory, dispatching to the appropriate indexer based on language_id. + */ static VALUE rdxr_graph_index_source(VALUE self, VALUE uri, VALUE source, VALUE language_id) { Check_Type(uri, T_STRING); Check_Type(source, T_STRING); From 231d43a5eb73c649befe1293f4134acd7a82706e Mon Sep 17 00:00:00 2001 From: Stan Lo Date: Wed, 24 Jun 2026 20:02:25 +0100 Subject: [PATCH 2/3] Document C-backed Ruby APIs for RDoc --- ext/rubydex/declaration.c | 113 +++++++++++++++++---- ext/rubydex/definition.c | 102 +++++++++++++++---- ext/rubydex/document.c | 15 ++- ext/rubydex/graph.c | 205 +++++++++++++++++++++++++++----------- ext/rubydex/reference.c | 45 +++++++-- 5 files changed, 369 insertions(+), 111 deletions(-) diff --git a/ext/rubydex/declaration.c b/ext/rubydex/declaration.c index 475788072..a5e1cf0ff 100644 --- a/ext/rubydex/declaration.c +++ b/ext/rubydex/declaration.c @@ -46,7 +46,12 @@ VALUE rdxi_declaration_class_for_kind(CDeclarationKind kind) { } } -// Declaration#name -> String +/* + * call-seq: + * name -> String? + * + * Returns the fully qualified declaration name. + */ static VALUE rdxr_declaration_name(VALUE self) { HandleData *data; TypedData_Get_Struct(self, HandleData, &handle_type, data); @@ -65,7 +70,12 @@ static VALUE rdxr_declaration_name(VALUE self) { return str; } -// Declaration#unqualified_name -> String +/* + * call-seq: + * unqualified_name -> String? + * + * Returns the declaration name without namespace qualification. + */ static VALUE rdxr_declaration_unqualified_name(VALUE self) { HandleData *data; TypedData_Get_Struct(self, HandleData, &handle_type, data); @@ -126,8 +136,12 @@ static VALUE declaration_definitions_size(VALUE self, VALUE _args, VALUE _eobj) return SIZET2NUM(len); } -// Declaration#definitions: () -> Enumerator[Definition] -// Returns an enumerator that yields all definitions for this declaration lazily +/* + * call-seq: + * definitions -> Enumerator[Rubydex::Definition] + * + * Returns an enumerator that yields all definitions for this declaration lazily. + */ static VALUE rdxr_declaration_definitions(VALUE self) { if (!rb_block_given_p()) { 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) { return self; } -// Declaration#member: (String member) -> Declaration -// Returns a declaration handle for the given member +/* + * call-seq: + * member(name) -> Rubydex::Declaration? + * + * Returns a declaration handle for the named member, or nil if no member exists. + */ static VALUE rdxr_declaration_member(VALUE self, VALUE name) { HandleData *data; TypedData_Get_Struct(self, HandleData, &handle_type, data); @@ -171,8 +189,12 @@ static VALUE rdxr_declaration_member(VALUE self, VALUE name) { return rb_class_new_instance(2, argv, decl_class); } -// Namespace#find_member: (String member, only_inherited: false) -> Declaration? -// Searches for a member in the ancestor chain of the declaration +/* + * call-seq: + * find_member(name, only_inherited: false) -> Rubydex::Declaration? + * + * Searches for a member in the declaration's ancestor chain. + */ static VALUE rdxr_declaration_find_member(int argc, VALUE *argv, VALUE self) { VALUE member, opts; rb_scan_args(argc, argv, "1:", &member, &opts); @@ -207,7 +229,12 @@ static VALUE rdxr_declaration_find_member(int argc, VALUE *argv, VALUE self) { return rb_class_new_instance(2, result_argv, decl_class); } -// Declaration#singleton_class -> SingletonClass +/* + * call-seq: + * singleton_class -> Rubydex::SingletonClass? + * + * Returns the singleton class declaration, or nil if none exists. + */ static VALUE rdxr_declaration_singleton_class(VALUE self) { HandleData *data; TypedData_Get_Struct(self, HandleData, &handle_type, data); @@ -227,7 +254,12 @@ static VALUE rdxr_declaration_singleton_class(VALUE self) { return rb_class_new_instance(2, argv, decl_class); } -// Declaration#owner -> Declaration +/* + * call-seq: + * owner -> Rubydex::Declaration + * + * Returns the owner declaration. + */ static VALUE rdxr_declaration_owner(VALUE self) { HandleData *data; TypedData_Get_Struct(self, HandleData, &handle_type, data); @@ -247,7 +279,12 @@ static VALUE rdxr_declaration_owner(VALUE self) { return rb_class_new_instance(2, argv, decl_class); } -// Declaration#ancestors: () -> Enumerator[Declaration] +/* + * call-seq: + * ancestors -> Enumerator[Rubydex::Namespace] + * + * Returns an enumerator that yields ancestor namespaces. + */ static VALUE rdxr_declaration_ancestors(VALUE self) { if (!rb_block_given_p()) { return rb_enumeratorize(self, rb_str_new2("ancestors"), 0, NULL); @@ -270,7 +307,12 @@ static VALUE rdxr_declaration_ancestors(VALUE self) { return self; } -// Declaration#descendants: () -> Enumerator[Declaration] +/* + * call-seq: + * descendants -> Enumerator[Rubydex::Namespace] + * + * Returns an enumerator that yields descendant namespaces. + */ static VALUE rdxr_declaration_descendants(VALUE self) { if (!rb_block_given_p()) { return rb_enumeratorize(self, rb_str_new2("descendants"), 0, NULL); @@ -293,7 +335,12 @@ static VALUE rdxr_declaration_descendants(VALUE self) { return self; } -// Namespace#members: () -> Enumerator[Declaration] +/* + * call-seq: + * members -> Enumerator[Rubydex::Declaration] + * + * Returns an enumerator that yields member declarations. + */ static VALUE rdxr_declaration_members(VALUE self) { if (!rb_block_given_p()) { 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 return SIZET2NUM(len); } -// Namespace#references, Constant#references, ConstantAlias#references -// Returns an enumerator that yields constant references to this declaration +/* + * call-seq: + * references -> Enumerator[Rubydex::ConstantReference] + * + * Returns an enumerator that yields constant references to this declaration. + */ static VALUE rdxr_constant_declaration_references(VALUE self) { if (!rb_block_given_p()) { 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 _ return SIZET2NUM(len); } -// Method#references -// Returns an enumerator that yields method references to this declaration +/* + * call-seq: + * references -> Enumerator[Rubydex::MethodReference] + * + * Returns an enumerator that yields method references to this declaration. + */ static VALUE rdxr_method_declaration_references(VALUE self) { if (!rb_block_given_p()) { return rb_enumeratorize_with_size(self, rb_str_new2("references"), 0, NULL, @@ -402,7 +457,12 @@ static VALUE rdxr_method_declaration_references(VALUE self) { return self; } -// Placeholder for variable declarations that don't yet support references +/* + * call-seq: + * references -> Array[untyped] + * + * Returns an empty array because variable declarations do not yet support reference lookup. + */ static VALUE rdxr_variable_declaration_references(VALUE self) { return rb_ary_new(); } @@ -420,7 +480,12 @@ static VALUE rdxi_visibility_to_symbol(CVisibility visibility) { } } -// Declaration#visibility -> Symbol +/* + * call-seq: + * visibility -> Symbol + * + * Returns the declaration visibility. + */ static VALUE rdxr_declaration_visibility(VALUE self) { HandleData *data; TypedData_Get_Struct(self, HandleData, &handle_type, data); @@ -439,9 +504,13 @@ static VALUE rdxr_declaration_visibility(VALUE self) { return symbol; } -// ConstantAlias#target -> Declaration? -// Returns the first resolved target declaration for this constant alias, or nil if none of its definitions resolved to -// a target +/* + * call-seq: + * target -> Rubydex::Declaration? + * + * Returns the first resolved target declaration for this constant alias, or nil if none of its definitions resolved to + * a target. + */ static VALUE rdxr_constant_alias_target(VALUE self) { HandleData *data; TypedData_Get_Struct(self, HandleData, &handle_type, data); diff --git a/ext/rubydex/definition.c b/ext/rubydex/definition.c index 12938ecf8..30a0b8f8e 100644 --- a/ext/rubydex/definition.c +++ b/ext/rubydex/definition.c @@ -71,7 +71,12 @@ VALUE rdxi_definition_class_for_kind(DefinitionKind kind) { } } -// Definition#location -> Rubydex::Location +/* + * call-seq: + * location -> Rubydex::Location + * + * Returns the source location for this definition. + */ static VALUE rdxr_definition_location(VALUE self) { HandleData *data; TypedData_Get_Struct(self, HandleData, &handle_type, data); @@ -86,7 +91,12 @@ static VALUE rdxr_definition_location(VALUE self) { return location; } -// Definition#comments -> [Rubydex::Comment] +/* + * call-seq: + * comments -> Array[Rubydex::Comment] + * + * Returns the source comments associated with this definition. + */ static VALUE rdxr_definition_comments(VALUE self) { HandleData *data; TypedData_Get_Struct(self, HandleData, &handle_type, data); @@ -124,7 +134,12 @@ static VALUE rdxr_definition_comments(VALUE self) { return ary; } -// Definition#name -> String +/* + * call-seq: + * name -> String? + * + * Returns the definition name. + */ static VALUE rdxr_definition_name(VALUE self) { HandleData *data; TypedData_Get_Struct(self, HandleData, &handle_type, data); @@ -141,7 +156,12 @@ static VALUE rdxr_definition_name(VALUE self) { return str; } -// Definition#deprecated? -> bool +/* + * call-seq: + * deprecated? -> bool + * + * Returns whether this definition is marked as deprecated. + */ static VALUE rdxr_definition_deprecated(VALUE self) { HandleData *data; TypedData_Get_Struct(self, HandleData, &handle_type, data); @@ -153,9 +173,13 @@ static VALUE rdxr_definition_deprecated(VALUE self) { return deprecated ? Qtrue : Qfalse; } -// Definition#name_location -> Rubydex::Location or nil -// For class, module, singleton class, and method definitions, returns the location of just the name -// (e.g., "Bar" in "class Foo::Bar", or "foo" in "def foo"). For other definition types, returns nil. +/* + * call-seq: + * name_location -> Rubydex::Location? + * + * For class, module, singleton class, and method definitions, returns the location of just the name, such as "Bar" in + * "class Foo::Bar" or "foo" in "def foo". For other definition types, returns nil. + */ static VALUE rdxr_definition_name_location(VALUE self) { HandleData *data; TypedData_Get_Struct(self, HandleData, &handle_type, data); @@ -173,9 +197,12 @@ static VALUE rdxr_definition_name_location(VALUE self) { return location; } -// Definition#declaration -> Rubydex::Declaration? -// Returns the declaration this definition belongs to or nil when it cannot be located (for example, before -// `Graph#resolve` has run). +/* + * call-seq: + * declaration -> Rubydex::Declaration? + * + * Returns the declaration this definition belongs to or nil when it cannot be located. + */ static VALUE rdxr_definition_declaration(VALUE self) { HandleData *data; TypedData_Get_Struct(self, HandleData, &handle_type, data); @@ -203,8 +230,12 @@ static VALUE rdxi_build_definition(VALUE graph_obj, void *graph, uint64_t defini return rb_class_new_instance(2, argv, defn_class); } -// Definition#lexical_owner -> Rubydex::Definition? -// Returns the lexically enclosing definition, if any. +/* + * call-seq: + * lexical_owner -> Rubydex::Definition? + * + * Returns the lexically enclosing definition, if any. + */ static VALUE rdxr_definition_lexical_owner(VALUE self) { HandleData *data; TypedData_Get_Struct(self, HandleData, &handle_type, data); @@ -223,8 +254,12 @@ static VALUE rdxr_definition_lexical_owner(VALUE self) { return owner; } -// Definition#lexical_nesting -> Array -// Returns the lexical nesting from the direct owner up to the root. +/* + * call-seq: + * lexical_nesting -> Array[Rubydex::Definition] + * + * Returns the lexical nesting from the direct owner up to the root. + */ static VALUE rdxr_definition_lexical_nesting(VALUE self) { HandleData *data; TypedData_Get_Struct(self, HandleData, &handle_type, data); @@ -258,7 +293,12 @@ static VALUE rdxi_build_constant_reference(VALUE graph_obj, const CConstantRefer return rb_class_new_instance(2, argv, ref_class); } -// ClassDefinition#superclass -> ConstantReference? +/* + * call-seq: + * superclass -> Rubydex::ConstantReference? + * + * Returns the superclass constant reference, or nil if this class definition has no explicit superclass. + */ static VALUE rdxr_class_definition_superclass(VALUE self) { HandleData *data; TypedData_Get_Struct(self, HandleData, &handle_type, data); @@ -289,7 +329,12 @@ static VALUE rdxi_mixin_class_for_kind(MixinKind kind) { } } -// Definition#mixins -> [Rubydex::Mixin] +/* + * call-seq: + * mixins -> Array[Rubydex::Mixin] + * + * Returns mixins attached to this definition. + */ static VALUE rdxr_definition_mixins(VALUE self) { HandleData *data; TypedData_Get_Struct(self, HandleData, &handle_type, data); @@ -317,7 +362,12 @@ static VALUE rdxr_definition_mixins(VALUE self) { return ary; } -// MethodDefinition#signatures -> [Rubydex::Signature] +/* + * call-seq: + * signatures -> Array[Rubydex::Signature] + * + * Returns signatures for this method definition. + */ static VALUE rdxr_method_definition_signatures(VALUE self) { HandleData *data; TypedData_Get_Struct(self, HandleData, &handle_type, data); @@ -329,7 +379,12 @@ static VALUE rdxr_method_definition_signatures(VALUE self) { return rdxi_signatures_to_ruby(arr); } -// MethodAliasDefinition#signatures -> [Rubydex::Signature] +/* + * call-seq: + * signatures -> Array[Rubydex::Signature] + * + * Returns signatures for this method alias definition. + */ static VALUE rdxr_method_alias_definition_signatures(VALUE self) { HandleData *data; TypedData_Get_Struct(self, HandleData, &handle_type, data); @@ -341,10 +396,13 @@ static VALUE rdxr_method_alias_definition_signatures(VALUE self) { return rdxi_signatures_to_ruby(arr); } -// MethodAliasDefinition#target -> Rubydex::Method? -// Returns the resolved target method declaration by following the alias chain, or nil if the chain could not be -// resolved (the target name doesn't exist on the owner, or the owner itself never resolved). Raises -// Rubydex::AliasCycleError when the alias chain forms a cycle. +/* + * call-seq: + * target -> Rubydex::Method? + * + * Returns the resolved target method declaration by following the alias chain, or nil if the chain could not be + * resolved. Raises Rubydex::AliasCycleError when the alias chain forms a cycle. + */ static VALUE rdxr_method_alias_definition_target(VALUE self) { HandleData *data; TypedData_Get_Struct(self, HandleData, &handle_type, data); diff --git a/ext/rubydex/document.c b/ext/rubydex/document.c index 86397beac..d405a16a1 100644 --- a/ext/rubydex/document.c +++ b/ext/rubydex/document.c @@ -7,7 +7,12 @@ VALUE cDocument; -// Document#uri -> String +/* + * call-seq: + * uri -> String? + * + * Returns the document URI. + */ static VALUE rdxr_document_uri(VALUE self) { HandleData *data; TypedData_Get_Struct(self, HandleData, &handle_type, data); @@ -67,8 +72,12 @@ static VALUE document_definitions_size(VALUE self, VALUE _args, VALUE _eobj) { return SIZET2NUM(len); } -// Document#definitions: () -> Enumerator[Definition] -// Returns an enumerator that yields all definitions for this document lazily +/* + * call-seq: + * definitions -> Enumerator[Rubydex::Definition] + * + * Returns an enumerator that yields all definitions for this document lazily. + */ static VALUE rdxr_document_definitions(VALUE self) { if (!rb_block_given_p()) { return rb_enumeratorize_with_size(self, rb_str_new2("definitions"), 0, NULL, document_definitions_size); diff --git a/ext/rubydex/graph.c b/ext/rubydex/graph.c index 320f9e56f..e13117862 100644 --- a/ext/rubydex/graph.c +++ b/ext/rubydex/graph.c @@ -68,8 +68,12 @@ static VALUE rdxr_graph_alloc(VALUE klass) { return TypedData_Wrap_Struct(klass, &graph_type, graph); } -// Graph#index_all: (Array[String] file_paths) -> Array[String] -// Returns an array of IO error messages encountered during indexing +/* + * call-seq: + * index_all(file_paths) -> Array[String] + * + * Returns an array of I/O error messages encountered during indexing. + */ static VALUE rdxr_graph_index_all(VALUE self, VALUE file_paths) { rdxi_check_array_of_strings(file_paths); @@ -151,8 +155,12 @@ static VALUE graph_declarations_size(VALUE self, VALUE _args, VALUE _eobj) { return SIZET2NUM(len); } -// Graph#declarations: () -> Enumerator[Declaration] -// Returns an enumerator that yields all declarations lazily +/* + * call-seq: + * declarations -> Enumerator[Rubydex::Declaration] + * + * Returns an enumerator that yields all declarations lazily. + */ static VALUE rdxr_graph_declarations(VALUE self) { if (!rb_block_given_p()) { return rb_enumeratorize_with_size(self, rb_str_new2("declarations"), 0, NULL, graph_declarations_size); @@ -181,8 +189,12 @@ static VALUE rdxr_graph_yield_search_results(VALUE self, void *iter) { return self; } -// Graph#search: (String query) -> Enumerator[Declaration] -// Returns an enumerator that yields declarations matching the query exactly (substring match) +/* + * call-seq: + * search(query) -> Enumerator[Rubydex::Declaration] + * + * Returns an enumerator that yields declarations matching the query exactly by substring. + */ static VALUE rdxr_graph_search(VALUE self, VALUE query) { Check_Type(query, T_STRING); @@ -196,8 +208,12 @@ static VALUE rdxr_graph_search(VALUE self, VALUE query) { return rdxr_graph_yield_search_results(self, rdx_graph_declarations_search(graph, StringValueCStr(query))); } -// Graph#fuzzy_search: (String query) -> Enumerator[Declaration] -// Returns an enumerator that yields declarations matching the query fuzzily +/* + * call-seq: + * fuzzy_search(query) -> Enumerator[Rubydex::Declaration] + * + * Returns an enumerator that yields declarations matching the query fuzzily. + */ static VALUE rdxr_graph_fuzzy_search(VALUE self, VALUE query) { Check_Type(query, T_STRING); @@ -246,8 +262,12 @@ static VALUE graph_documents_size(VALUE self, VALUE _args, VALUE _eobj) { return SIZET2NUM(len); } -// Graph#documents: () -> Enumerator[Document] -// Returns an enumerator that yields all documents lazily +/* + * call-seq: + * documents -> Enumerator[Rubydex::Document] + * + * Returns an enumerator that yields all documents lazily. + */ static VALUE rdxr_graph_documents(VALUE self) { if (!rb_block_given_p()) { return rb_enumeratorize_with_size(self, rb_str_new2("documents"), 0, NULL, graph_documents_size); @@ -263,8 +283,12 @@ static VALUE rdxr_graph_documents(VALUE self) { return self; } -// Graph#[]: (String fully_qualified_name) -> Declaration -// Returns a declaration handle for the given ID +/* + * call-seq: + * graph[fully_qualified_name] -> Rubydex::Declaration? + * + * Returns the declaration for the fully qualified name, or nil when no declaration exists. + */ static VALUE rdxr_graph_aref(VALUE self, VALUE key) { void *graph; TypedData_Get_Struct(self, void *, &graph_type, graph); @@ -297,8 +321,12 @@ static VALUE graph_constant_references_size(VALUE self, VALUE _args, VALUE _eobj return SIZET2NUM(len); } -// Graph#constant_references: () -> Enumerator[ConstantReference] -// Returns an enumerator that yields constant references lazily +/* + * call-seq: + * constant_references -> Enumerator[Rubydex::ConstantReference] + * + * Returns an enumerator that yields constant references lazily. + */ static VALUE rdxr_graph_constant_references(VALUE self) { if (!rb_block_given_p()) { return rb_enumeratorize_with_size(self, rb_str_new2("constant_references"), 0, NULL, @@ -327,8 +355,12 @@ static VALUE graph_method_references_size(VALUE self, VALUE _args, VALUE _eobj) return SIZET2NUM(len); } -// Graph#method_references: () -> Enumerator[MethodReference] -// Returns an enumerator that yields method references lazily +/* + * call-seq: + * method_references -> Enumerator[Rubydex::MethodReference] + * + * Returns an enumerator that yields method references lazily. + */ static VALUE rdxr_graph_method_references(VALUE self) { if (!rb_block_given_p()) { return rb_enumeratorize_with_size(self, rb_str_new2("method_references"), 0, NULL, @@ -345,8 +377,12 @@ static VALUE rdxr_graph_method_references(VALUE self) { return self; } -// Graph#document: (String uri) -> Document? -// Returns the Document for the given URI, or nil if it doesn't exist. +/* + * call-seq: + * document(uri) -> Rubydex::Document? + * + * Returns the document for the URI, or nil if it does not exist. + */ static VALUE rdxr_graph_document(VALUE self, VALUE uri) { Check_Type(uri, T_STRING); @@ -363,9 +399,13 @@ static VALUE rdxr_graph_document(VALUE self, VALUE uri) { return rb_class_new_instance(2, argv, cDocument); } -// Graph#delete_document: (String uri) -> Document? -// Deletes a document and all of its definitions from the graph. -// Returns the removed Document or nil if it doesn't exist. +/* + * call-seq: + * delete_document(uri) -> Rubydex::Document? + * + * Deletes a document and all of its definitions from the graph. Returns the removed document, or nil if it does not + * exist. + */ static VALUE rdxr_graph_delete_document(VALUE self, VALUE uri) { Check_Type(uri, T_STRING); @@ -382,8 +422,12 @@ static VALUE rdxr_graph_delete_document(VALUE self, VALUE uri) { return rb_class_new_instance(2, argv, cDocument); } -// Graph#resolve: () -> self -// Runs the resolver to compute declarations and ownership +/* + * call-seq: + * resolve -> self + * + * Runs the resolver to compute declarations and ownership. + */ static VALUE rdxr_graph_resolve(VALUE self) { void *graph; TypedData_Get_Struct(self, void *, &graph_type, graph); @@ -391,8 +435,12 @@ static VALUE rdxr_graph_resolve(VALUE self) { return self; } -// Graph#encoding=: (String) -> void -// Sets the encoding used for transforming byte offsets into LSP code unit line/column positions +/* + * call-seq: + * encoding=(encoding) -> nil + * + * Sets the encoding used for transforming byte offsets into LSP code unit line and column positions. + */ static VALUE rdxr_graph_set_encoding(VALUE self, VALUE encoding) { Check_Type(encoding, T_STRING); @@ -407,8 +455,12 @@ static VALUE rdxr_graph_set_encoding(VALUE self, VALUE encoding) { return Qnil; } -// Graph#resolve_constant: (String, Array[String]) -> Declaration? -// Runs the resolver on a single constant reference to determine what it points to +/* + * call-seq: + * resolve_constant(name, nesting) -> Rubydex::Declaration? + * + * Runs the resolver on a single constant reference to determine what it points to. + */ static VALUE rdxr_graph_resolve_constant(VALUE self, VALUE const_name, VALUE nesting) { Check_Type(const_name, T_STRING); rdxi_check_array_of_strings(nesting); @@ -436,8 +488,12 @@ static VALUE rdxr_graph_resolve_constant(VALUE self, VALUE const_name, VALUE nes return rb_class_new_instance(2, argv, decl_class); } -// Graph#resolve_require_path: (String require_path, Array[String] load_paths) -> Document? -// Resolves a require path to its Document. +/* + * call-seq: + * resolve_require_path(require_path, load_paths) -> Rubydex::Document? + * + * Resolves a require path to its document. + */ static VALUE rdxr_graph_resolve_require_path(VALUE self, VALUE require_path, VALUE load_paths) { Check_Type(require_path, T_STRING); rdxi_check_array_of_strings(load_paths); @@ -462,8 +518,12 @@ static VALUE rdxr_graph_resolve_require_path(VALUE self, VALUE require_path, VAL return rb_class_new_instance(2, argv, cDocument); } -// Graph#require_paths: (Array[String] load_path) -> Array[String] -// Returns all require paths for completion. +/* + * call-seq: + * require_paths(load_paths) -> Array[String] + * + * Returns all require paths for completion. + */ static VALUE rdxr_graph_require_paths(VALUE self, VALUE load_path) { rdxi_check_array_of_strings(load_path); @@ -491,8 +551,12 @@ static VALUE rdxr_graph_require_paths(VALUE self, VALUE load_path) { return array; } -// Graph#check_integrity: () -> Array[Rubydex::IntegrityFailure] -// Returns an array of IntegrityFailure objects, empty if no issues found +/* + * call-seq: + * check_integrity -> Array[Rubydex::IntegrityFailure] + * + * Returns an array of integrity failures, or an empty array if no issues were found. + */ static VALUE rdxr_graph_check_integrity(VALUE self) { void *graph; TypedData_Get_Struct(self, void *, &graph_type, graph); @@ -517,7 +581,12 @@ static VALUE rdxr_graph_check_integrity(VALUE self) { return array; } -// Graph#diagnostics -> Array[Rubydex::Diagnostic] +/* + * call-seq: + * diagnostics -> Array[Rubydex::Diagnostic] + * + * Returns diagnostics emitted while indexing or resolving the graph. + */ static VALUE rdxr_graph_diagnostics(VALUE self) { void *graph; TypedData_Get_Struct(self, void *, &graph_type, graph); @@ -606,10 +675,13 @@ static VALUE completion_result_to_ruby_array(struct CompletionResult result, VAL return ruby_array; } -// Graph#complete_expression: (Array[String] nesting, self_receiver:) -> Array[Declaration | Keyword] -// Returns completion candidates for an expression context. -// The nesting array represents the lexical scope stack. The required self_receiver keyword argument overrides the -// self-type (e.g., "Foo::" for `def Foo.bar`); when nil, self is derived from the innermost nesting element. +/* + * call-seq: + * complete_expression(nesting, self_receiver:) -> Array[Rubydex::Declaration | Rubydex::Keyword] + * + * Returns completion candidates for an expression context. The nesting array represents the lexical scope stack. The + * required self_receiver keyword argument overrides the self type; pass nil when the self type is unknown. + */ static VALUE rdxr_graph_complete_expression(int argc, VALUE *argv, VALUE self) { VALUE nesting, opts; rb_scan_args(argc, argv, "1:", &nesting, &opts); @@ -630,11 +702,13 @@ static VALUE rdxr_graph_complete_expression(int argc, VALUE *argv, VALUE self) { return completion_result_to_ruby_array(result, self); } -// Graph#complete_namespace_access: (String name, self_receiver:) -> Array[Declaration] -// Returns completion candidates after a namespace access operator (e.g., `Foo::`). -// The required self_receiver kwarg is the caller's runtime self type, used to filter -// visibility-restricted singleton methods (e.g., `private_class_method`). Pass `nil` when there -// is no caller context. +/* + * call-seq: + * complete_namespace_access(name, self_receiver:) -> Array[Rubydex::Declaration] + * + * Returns completion candidates after a namespace access operator such as Foo::. The required self_receiver keyword + * argument is the caller's runtime self type; pass nil when there is no caller context. + */ static VALUE rdxr_graph_complete_namespace_access(int argc, VALUE *argv, VALUE self) { VALUE name, opts; rb_scan_args(argc, argv, "1:", &name, &opts); @@ -650,10 +724,13 @@ static VALUE rdxr_graph_complete_namespace_access(int argc, VALUE *argv, VALUE s return completion_result_to_ruby_array(result, self); } -// Graph#complete_method_call: (String name, self_receiver:) -> Array[Declaration] -// Returns completion candidates after a method call operator (e.g., `foo.`). -// The required self_receiver kwarg is the caller's runtime self type, used for visibility checks (private/protected). -// Pass `nil` when there is no caller context. +/* + * call-seq: + * complete_method_call(name, self_receiver:) -> Array[Rubydex::Method] + * + * Returns completion candidates after a method call operator such as foo. The required self_receiver keyword argument + * is the caller's runtime self type; pass nil when there is no caller context. + */ static VALUE rdxr_graph_complete_method_call(int argc, VALUE *argv, VALUE self) { VALUE name, opts; rb_scan_args(argc, argv, "1:", &name, &opts); @@ -669,9 +746,13 @@ static VALUE rdxr_graph_complete_method_call(int argc, VALUE *argv, VALUE self) return completion_result_to_ruby_array(result, self); } -// Graph#complete_method_argument: (String name, Array[String] nesting, self_receiver:) -> Array[Declaration | Keyword | KeywordParameter] -// Returns completion candidates inside a method call's argument list (e.g., `foo.bar(|)`). -// See complete_expression for semantics of self_receiver (required, may be nil). +/* + * call-seq: + * complete_method_argument(name, nesting, self_receiver:) -> Array[Rubydex::Declaration | Rubydex::Keyword | Rubydex::KeywordParameter] + * + * Returns completion candidates inside a method call's argument list. See complete_expression for self_receiver + * semantics. + */ static VALUE rdxr_graph_complete_method_argument(int argc, VALUE *argv, VALUE self) { VALUE name, nesting, opts; rb_scan_args(argc, argv, "2:", &name, &nesting, &opts); @@ -694,8 +775,12 @@ static VALUE rdxr_graph_complete_method_argument(int argc, VALUE *argv, VALUE se return completion_result_to_ruby_array(result, self); } -// Graph#exclude_paths: (Array[String] paths) -> void -// Excludes the given paths from file discovery during indexing. +/* + * call-seq: + * exclude_paths(paths) -> nil + * + * Excludes the paths from file discovery during indexing. + */ static VALUE rdxr_graph_exclude_paths(VALUE self, VALUE paths) { Check_Type(paths, T_ARRAY); rdxi_check_array_of_strings(paths); @@ -712,8 +797,12 @@ static VALUE rdxr_graph_exclude_paths(VALUE self, VALUE paths) { return Qnil; } -// Graph#excluded_paths: () -> Array[String] -// Returns the list of paths currently excluded from file discovery. +/* + * call-seq: + * excluded_paths -> Array[String] + * + * Returns the paths currently excluded from file discovery. + */ static VALUE rdxr_graph_excluded_paths(VALUE self) { void *graph; TypedData_Get_Struct(self, void*, &graph_type, graph); @@ -734,8 +823,12 @@ static VALUE rdxr_graph_excluded_paths(VALUE self) { return array; } -// Graph#keyword: (String name) -> Keyword? -// Returns a Keyword object for the given keyword name, or nil if it is not a keyword. +/* + * call-seq: + * keyword(name) -> Rubydex::Keyword? + * + * Returns the keyword object for the name, or nil if it is not a Ruby keyword. + */ static VALUE rdxr_graph_keyword(VALUE self, VALUE name) { Check_Type(name, T_STRING); diff --git a/ext/rubydex/reference.c b/ext/rubydex/reference.c index 504f375aa..25a9f9d2c 100644 --- a/ext/rubydex/reference.c +++ b/ext/rubydex/reference.c @@ -11,7 +11,12 @@ VALUE cUnresolvedConstantReference; VALUE cResolvedConstantReference; VALUE cMethodReference; -// ConstantReference#name -> String +/* + * call-seq: + * name -> String + * + * Returns the unresolved constant name. + */ static VALUE rdxr_constant_reference_name(VALUE self) { HandleData *data; TypedData_Get_Struct(self, HandleData, &handle_type, data); @@ -29,7 +34,12 @@ static VALUE rdxr_constant_reference_name(VALUE self) { return str; } -// ConstantReference#location -> Rubydex::Location +/* + * call-seq: + * location -> Rubydex::Location + * + * Returns the source location for this constant reference. + */ static VALUE rdxr_constant_reference_location(VALUE self) { HandleData *data; TypedData_Get_Struct(self, HandleData, &handle_type, data); @@ -43,7 +53,12 @@ static VALUE rdxr_constant_reference_location(VALUE self) { return location; } -// MethodReference#name -> String +/* + * call-seq: + * name -> String + * + * Returns the referenced method name. + */ static VALUE rdxr_method_reference_name(VALUE self) { HandleData *data; TypedData_Get_Struct(self, HandleData, &handle_type, data); @@ -61,7 +76,12 @@ static VALUE rdxr_method_reference_name(VALUE self) { return str; } -// MethodReference#location -> Rubydex::Location +/* + * call-seq: + * location -> Rubydex::Location + * + * Returns the source location for this method reference. + */ static VALUE rdxr_method_reference_location(VALUE self) { HandleData *data; TypedData_Get_Struct(self, HandleData, &handle_type, data); @@ -75,9 +95,13 @@ static VALUE rdxr_method_reference_location(VALUE self) { return location; } -// MethodReference#receiver -> Rubydex::Declaration? -// Returns the resolved declaration for the receiver of the method call. Returns nil when the receiver is not a -// tracked constant or cannot be resolved. +/* + * call-seq: + * receiver -> Rubydex::Declaration? + * + * Returns the resolved declaration for the receiver of the method call. Returns nil when the receiver is not a tracked + * constant or cannot be resolved. + */ static VALUE rdxr_method_reference_receiver(VALUE self) { HandleData *data; TypedData_Get_Struct(self, HandleData, &handle_type, data); @@ -97,7 +121,12 @@ static VALUE rdxr_method_reference_receiver(VALUE self) { return rb_class_new_instance(2, argv, decl_class); } -// ResolvedConstantReference#declaration -> Declaration +/* + * call-seq: + * declaration -> Rubydex::Declaration + * + * Returns the resolved declaration. + */ static VALUE rdxr_resolved_constant_reference_declaration(VALUE self) { HandleData *data; TypedData_Get_Struct(self, HandleData, &handle_type, data); From 98a2517d55d8c4d279f671de4f30032dc0d272db Mon Sep 17 00:00:00 2001 From: Stan Lo Date: Wed, 24 Jun 2026 20:25:35 +0100 Subject: [PATCH 3/3] Clean up RDoc Pages workflow --- .document | 13 ++------- .github/workflows/pages.yml | 14 ++++------ .rdoc_options | 6 ---- Gemfile | 1 + Rakefile | 55 ------------------------------------- docs/rdoc-extension-root.c | 11 -------- ext/rubydex/declaration.c | 5 ++++ ext/rubydex/definition.c | 5 ++++ ext/rubydex/diagnostic.c | 5 ++++ ext/rubydex/document.c | 5 ++++ ext/rubydex/graph.c | 5 ++++ ext/rubydex/location.c | 5 ++++ ext/rubydex/reference.c | 5 ++++ ext/rubydex/rubydex.c | 5 ++++ ext/rubydex/signature.c | 5 ++++ 15 files changed, 53 insertions(+), 92 deletions(-) delete mode 100644 docs/rdoc-extension-root.c diff --git a/.document b/.document index d21baf90e..7fab714e0 100644 --- a/.document +++ b/.document @@ -1,14 +1,5 @@ README.md CONTRIBUTING.md docs/*.md -docs/rdoc-extension-root.c -lib -ext/rubydex/rubydex.c -ext/rubydex/graph.c -ext/rubydex/declaration.c -ext/rubydex/definition.c -ext/rubydex/document.c -ext/rubydex/reference.c -ext/rubydex/signature.c -ext/rubydex/location.c -ext/rubydex/diagnostic.c +lib/**/*.rb +ext/rubydex/*.c diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index f21de9c63..5180678df 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -23,19 +23,15 @@ jobs: uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 - name: Set up Ruby - uses: ruby/setup-ruby@89f90524b88a01fe6e0b732220432cc6142926af # v1.313.0 + uses: ruby/setup-ruby@9eb537ca036ebaed86729dcb9309076e4c5c3b74 # v1.314.0 with: - ruby-version: "3.4" bundler-cache: true - - name: Setup Pages - uses: actions/configure-pages@v6 - - - name: Build and verify documentation - run: bundle exec rake rdoc:verify + - name: Build documentation + run: bundle exec rake rdoc - name: Upload artifact - uses: actions/upload-pages-artifact@v5 + uses: actions/upload-pages-artifact@v5.0.0 deploy: environment: @@ -46,4 +42,4 @@ jobs: steps: - name: Deploy to GitHub Pages id: deployment - uses: actions/deploy-pages@v5 + uses: actions/deploy-pages@v5.0.0 diff --git a/.rdoc_options b/.rdoc_options index 1f9b43c76..a31520f1e 100644 --- a/.rdoc_options +++ b/.rdoc_options @@ -2,12 +2,6 @@ op_dir: _site title: Rubydex main_page: README.md -exclude: -- AGENTS.md -- CLAUDE.md -- tmp -- rust - footer_content: DOCUMENTATION: Home: index.html diff --git a/Gemfile b/Gemfile index 793edf89f..c206a2099 100644 --- a/Gemfile +++ b/Gemfile @@ -8,6 +8,7 @@ gemspec gem "rake", "~> 13.3" gem "rake-compiler" gem "minitest" +# TODO: Use stable release after 8.0 is out gem "rdoc", git: "https://github.com/ruby/rdoc.git", ref: "daa7768b81c703b84c796bf60c27977c62cd4aa1" gem "rubocop" gem "rubocop-shopify" diff --git a/Rakefile b/Rakefile index 71f8762e8..d4c0a3faa 100644 --- a/Rakefile +++ b/Rakefile @@ -33,61 +33,6 @@ RDoc::Task.new do |doc| doc.rdoc_dir = "_site" end -namespace :rdoc do - desc "Verify the generated RDoc site includes the public Ruby and native extension APIs" - task :verify do - Rake::Task["rdoc"].invoke - - html_files = FileList["_site/**/*.html"] - abort "Generated RDoc site is empty" if html_files.empty? - - expected_pages = { - "_site/Rubydex/Graph.html" => [ - 'id="class-rubydex-graph"', - 'id="method-i-index_workspace"', - 'id="method-i-workspace_paths"', - 'id="method-i-index_all"', - 'id="method-i-index_source"', - 'index_source(uri, source, language_id)', - 'id="method-i-keyword"', - 'id="method-i-exclude_paths"', - 'id="method-i-resolve_constant"', - ], - "_site/Rubydex/Declaration.html" => [ - 'id="class-rubydex-declaration"', - ], - "_site/Rubydex/Signature.html" => [ - 'id="class-rubydex-signature"', - ], - "_site/Rubydex/Document.html" => [ - 'id="class-rubydex-document"', - 'id="method-i-uri"', - 'id="method-i-definitions"', - ], - "_site/Rubydex/Definition.html" => [ - 'id="class-rubydex-definition"', - 'id="method-i-location"', - 'id="method-i-comments"', - ], - "_site/Rubydex/ResolvedConstantReference.html" => [ - 'id="class-rubydex-resolvedconstantreference"', - 'id="method-i-declaration"', - ], - } - - missing = expected_pages.flat_map do |file, entries| - unless File.exist?(file) - next ["#{file} was not generated"] - end - - content = File.read(file) - entries.reject { |entry| content.include?(entry) }.map { |entry| "#{file}: #{entry}" } - end - - abort "Generated RDoc site is missing expected API entries:\n - #{missing.join("\n - ")}" unless missing.empty? - end -end - task :lint do puts "******** Linting ********\n" Rake::Task["rubocop"].invoke diff --git a/docs/rdoc-extension-root.c b/docs/rdoc-extension-root.c deleted file mode 100644 index 63354deaf..000000000 --- a/docs/rdoc-extension-root.c +++ /dev/null @@ -1,11 +0,0 @@ -void Init_rubydex_rdoc(void) { - /* - * Document-module: Rubydex - * - * Namespace for Rubydex's Ruby API. - * - * This RDoc-only file seeds the C parser with the root module variable - * before it scans the real extension sources under ext/rubydex. - */ - mRubydex = rb_define_module("Rubydex"); -} diff --git a/ext/rubydex/declaration.c b/ext/rubydex/declaration.c index a5e1cf0ff..3f8366fee 100644 --- a/ext/rubydex/declaration.c +++ b/ext/rubydex/declaration.c @@ -5,6 +5,11 @@ #include "rustbindings.h" #include "utils.h" +/* + * RDoc parser workaround for https://github.com/ruby/rdoc/issues/1744: + * mRubydex = rb_define_module("Rubydex") + */ + VALUE cDeclaration; VALUE cNamespace; VALUE cClass; diff --git a/ext/rubydex/definition.c b/ext/rubydex/definition.c index 30a0b8f8e..58bd4ac71 100644 --- a/ext/rubydex/definition.c +++ b/ext/rubydex/definition.c @@ -8,6 +8,11 @@ #include "ruby/internal/scan_args.h" #include "rustbindings.h" +/* + * RDoc parser workaround for https://github.com/ruby/rdoc/issues/1744: + * mRubydex = rb_define_module("Rubydex") + */ + static VALUE mRubydex; static VALUE cInclude; static VALUE cPrepend; diff --git a/ext/rubydex/diagnostic.c b/ext/rubydex/diagnostic.c index a18af90ec..78ecdd751 100644 --- a/ext/rubydex/diagnostic.c +++ b/ext/rubydex/diagnostic.c @@ -1,6 +1,11 @@ #include "diagnostic.h" #include "rustbindings.h" +/* + * RDoc parser workaround for https://github.com/ruby/rdoc/issues/1744: + * mRubydex = rb_define_module("Rubydex") + */ + VALUE cDiagnostic; void rdxi_initialize_diagnostic(VALUE mRubydex) { cDiagnostic = rb_define_class_under(mRubydex, "Diagnostic", rb_cObject); } diff --git a/ext/rubydex/document.c b/ext/rubydex/document.c index d405a16a1..615463c15 100644 --- a/ext/rubydex/document.c +++ b/ext/rubydex/document.c @@ -5,6 +5,11 @@ #include "rustbindings.h" #include "utils.h" +/* + * RDoc parser workaround for https://github.com/ruby/rdoc/issues/1744: + * mRubydex = rb_define_module("Rubydex") + */ + VALUE cDocument; /* diff --git a/ext/rubydex/graph.c b/ext/rubydex/graph.c index e13117862..1ee808f27 100644 --- a/ext/rubydex/graph.c +++ b/ext/rubydex/graph.c @@ -8,6 +8,11 @@ #include "rustbindings.h" #include "utils.h" +/* + * RDoc parser workaround for https://github.com/ruby/rdoc/issues/1744: + * mRubydex = rb_define_module("Rubydex") + */ + static VALUE cGraph; static VALUE mRubydex; static VALUE cKeyword; diff --git a/ext/rubydex/location.c b/ext/rubydex/location.c index 7fbfb5489..a00a21119 100644 --- a/ext/rubydex/location.c +++ b/ext/rubydex/location.c @@ -1,5 +1,10 @@ #include "location.h" +/* + * RDoc parser workaround for https://github.com/ruby/rdoc/issues/1744: + * mRubydex = rb_define_module("Rubydex") + */ + VALUE cLocation; VALUE rdxi_build_location_value(Location *loc) { diff --git a/ext/rubydex/reference.c b/ext/rubydex/reference.c index 25a9f9d2c..bf0a656af 100644 --- a/ext/rubydex/reference.c +++ b/ext/rubydex/reference.c @@ -5,6 +5,11 @@ #include "location.h" #include "rustbindings.h" +/* + * RDoc parser workaround for https://github.com/ruby/rdoc/issues/1744: + * mRubydex = rb_define_module("Rubydex") + */ + VALUE cReference; VALUE cConstantReference; VALUE cUnresolvedConstantReference; diff --git a/ext/rubydex/rubydex.c b/ext/rubydex/rubydex.c index ea6b7d3d5..121bba6cd 100644 --- a/ext/rubydex/rubydex.c +++ b/ext/rubydex/rubydex.c @@ -12,6 +12,11 @@ VALUE mRubydex; void Init_rubydex(void) { rb_ext_ractor_safe(true); + /* + * Document-module: Rubydex + * + * Namespace for Rubydex's Ruby API. + */ mRubydex = rb_define_module("Rubydex"); rdxi_initialize_graph(mRubydex); rdxi_initialize_declaration(mRubydex); diff --git a/ext/rubydex/signature.c b/ext/rubydex/signature.c index 95db75542..8feec23f3 100644 --- a/ext/rubydex/signature.c +++ b/ext/rubydex/signature.c @@ -1,6 +1,11 @@ #include "signature.h" #include "location.h" +/* + * RDoc parser workaround for https://github.com/ruby/rdoc/issues/1744: + * mRubydex = rb_define_module("Rubydex") + */ + static VALUE empty_params = Qundef; VALUE cSignature;