Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .document
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
README.md
CONTRIBUTING.md
docs/*.md
lib/**/*.rb
ext/rubydex/*.c
49 changes: 49 additions & 0 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
@@ -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: "4.0.0"
bundler-cache: true

- name: Setup Pages
uses: actions/configure-pages@v6.0.0

- name: Build documentation
run: bundle exec rake rdoc

- name: Upload artifact
uses: actions/upload-pages-artifact@v5.0.0

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.0.0
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/.bundle/
/.yardoc
/_yardoc/
/_site/
/coverage/
/doc/
/pkg/
Expand Down
10 changes: 10 additions & 0 deletions .rdoc_options
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
op_dir: _site
title: Rubydex
main_page: README.md

footer_content:
DOCUMENTATION:
Home: index.html
RESOURCES:
GitHub Repository: https://github.com/Shopify/rubydex
Issue Tracker: https://github.com/Shopify/rubydex/issues
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
24 changes: 14 additions & 10 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -10,7 +21,6 @@ GEM
public_suffix (>= 2.0.2, < 8.0)
ast (2.4.3)
bigdecimal (4.1.2)
date (3.5.1)
drb (2.2.3)
erb (6.0.4)
extconf_compile_commands_json (0.0.7)
Expand Down Expand Up @@ -48,21 +58,15 @@ GEM
prettyprint
prettyprint (0.2.0)
prism (1.9.0)
psych (5.3.1)
date
stringio
public_suffix (7.0.5)
racc (1.8.1)
rainbow (3.1.1)
rake (13.3.1)
rake-compiler (1.3.1)
rake
rbs (3.10.3)
rbs (4.0.3)
logger
tsort
rdoc (7.2.0)
erb
psych (>= 4.0.0)
prism (>= 1.6.0)
tsort
regexp_parser (2.12.0)
reline (0.6.3)
Expand All @@ -87,7 +91,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)
Expand All @@ -105,6 +108,7 @@ DEPENDENCIES
rake (~> 13.3)
rake-compiler
rbs
rdoc!
rubocop
rubocop-shopify
ruby_memcheck
Expand Down
5 changes: 5 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand All @@ -28,6 +29,10 @@ end

RuboCop::RakeTask.new

RDoc::Task.new do |doc|
doc.rdoc_dir = "_site"
end

task :lint do
puts "******** Linting ********\n"
Rake::Task["rubocop"].invoke
Expand Down
115 changes: 93 additions & 22 deletions ext/rubydex/declaration.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#include "rustbindings.h"
#include "utils.h"

/* RDoc parses C files independently: mRubydex = rb_define_module("Rubydex") */

VALUE cDeclaration;
VALUE cNamespace;
VALUE cClass;
Expand Down Expand Up @@ -46,7 +48,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);
Expand All @@ -65,7 +72,12 @@ static VALUE rdxr_declaration_name(VALUE self) {
return str;
}

// Declaration#unqualified_name -> String
/*
* call-seq:
* unqualified_name -> String?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RDoc currently doesn't have a way to read RBS sigs from C files yet. So let's use call-seq for now.

*
* Returns the declaration name without namespace qualification.
*/

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RDoc's C parser only recognizes this style of C comments.

static VALUE rdxr_declaration_unqualified_name(VALUE self) {
HandleData *data;
TypedData_Get_Struct(self, HandleData, &handle_type, data);
Expand Down Expand Up @@ -126,8 +138,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);
Expand All @@ -146,8 +162,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);
Expand All @@ -171,8 +191,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);
Expand Down Expand Up @@ -207,7 +231,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);
Expand All @@ -227,7 +256,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);
Expand All @@ -247,7 +281,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);
Expand All @@ -270,7 +309,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);
Expand All @@ -293,7 +337,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);
Expand Down Expand Up @@ -334,8 +383,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,
Expand Down Expand Up @@ -377,8 +430,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,
Expand All @@ -402,7 +459,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();
}
Expand All @@ -420,7 +482,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);
Expand All @@ -439,9 +506,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);
Expand Down
Loading
Loading