ruby

package
v0.1.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 10, 2026 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package ruby provides a documentation source adapter that reads Ruby source code from a local checkout of a Ruby framework repository (Rails, RSpec, Sidekiq, etc.). It parses raw Ruby source via tree-sitter to extract classes, modules, methods, and YARD documentation without making any network calls during parsing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCampingFactory

func NewCampingFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewCampingFactory creates a Source for the Camping micro web framework.

func NewCubaFactory

func NewCubaFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewCubaFactory creates a Source for the Cuba micro framework.

func NewDeviseFactory

func NewDeviseFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewDeviseFactory creates a Source for Devise authentication.

func NewDryRbFactory

func NewDryRbFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewDryRbFactory creates a Source for Dry-rb.

func NewDrySystemFactory

func NewDrySystemFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewDrySystemFactory creates a Source for the dry-system application framework.

func NewFaradayFactory

func NewFaradayFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewFaradayFactory creates a Source for Faraday.

func NewGrapeFactory

func NewGrapeFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewGrapeFactory creates a Source for the Grape REST API framework.

func NewHanamiFactory

func NewHanamiFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewHanamiFactory creates a Source for the Hanami web framework.

func NewMinitestFactory

func NewMinitestFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewMinitestFactory creates a Source for Minitest.

func NewNokogiriFactory

func NewNokogiriFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewNokogiriFactory creates a Source for Nokogiri.

func NewPadrinoFactory

func NewPadrinoFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewPadrinoFactory creates a Source for the Padrino full-stack framework.

func NewPumaFactory

func NewPumaFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewPumaFactory creates a Source for Puma.

func NewRSpecFactory

func NewRSpecFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewRSpecFactory creates a Source for the RSpec testing framework.

func NewRackFactory

func NewRackFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewRackFactory creates a Source for Rack.

func NewRailsFactory

func NewRailsFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewRailsFactory creates a Source for Ruby on Rails.

func NewRamazeFactory

func NewRamazeFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewRamazeFactory creates a Source for the Ramaze modular web framework.

func NewRodaFactory

func NewRodaFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewRodaFactory creates a Source for the Roda routing tree web framework.

func NewSequelFactory

func NewSequelFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewSequelFactory creates a Source for the Sequel database toolkit. Replaces Lucky, which is written in Crystal and cannot be indexed by the Ruby adapter.

func NewSidekiqFactory

func NewSidekiqFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewSidekiqFactory creates a Source for Sidekiq.

func NewSinatraFactory

func NewSinatraFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewSinatraFactory creates a Source for Sinatra.

func NewStdlibFactory

func NewStdlibFactory(repoPath string, opts registry.FactoryOptions) (source.Source, error)

NewStdlibFactory creates a Source for the Ruby standard library.

Types

type Config

type Config struct {
	// LibraryID is the canonical identifier (e.g., "/ruby/rails").
	LibraryID string

	// Name is the display name for the library (e.g., "Rails Reference").
	Name string

	// Description is the library description.
	Description string

	// SourceURL is the GitHub URL for the framework (e.g., "https://github.com/rails/rails").
	SourceURL string

	// Version is the version string for the library.
	Version string

	// TrustScore is the relevance trust score (0-1).
	TrustScore float64

	// SourceRoots are the directory paths relative to the repo root that
	// contain the framework's source code (e.g., ["lib"] for gems,
	// ["activerecord/lib"] for Rails components).
	SourceRoots []string
}

Config holds the framework-specific configuration for a RubySource.

type Option

type Option func(*RubySource)

Option customises a RubySource at construction time.

func WithRef

func WithRef(ref string) Option

WithRef sets the git ref (tag or branch) for source-code links, e.g. WithRef("v7.1.2") produces links under .../blob/v7.1.2/.

type RubySource

type RubySource struct {
	// contains filtered or unexported fields
}

RubySource is a documentation source adapter that reads Ruby source code from a local repository checkout. It is configurable for any Ruby framework (Rails, RSpec, Sidekiq, etc.).

func New

func New(repoPath string, cfg Config, opts ...Option) *RubySource

New constructs a new RubySource for the given local repository path and framework configuration.

func (*RubySource) DetectWrapper

func (s *RubySource) DetectWrapper(method *source.Method) (bool, string, string)

DetectWrapper analyzes a method's source code for wrapper patterns.

func (*RubySource) DiscoverEntities

func (s *RubySource) DiscoverEntities(ctx context.Context, fetch source.FetchFunc) ([]string, error)

DiscoverEntities walks the local repository and returns a sorted list of entity identifiers in the form "filepath#Module::ClassName".

func (*RubySource) ID

func (s *RubySource) ID() string

ID returns the canonical library ID.

func (*RubySource) Meta

func (s *RubySource) Meta() source.LibraryMeta

Meta returns metadata for the library record.

func (*RubySource) ParseEntity

func (s *RubySource) ParseEntity(ctx context.Context, entityID string, content []byte) (*source.Entity, []string, error)

ParseEntity parses a single entity from file content, identified by entityID. The entityID is of the form "filepath#Module::ClassName".

func (*RubySource) ParseMethod

func (s *RubySource) ParseMethod(ctx context.Context, methodID string, content []byte) (*source.Method, error)

ParseMethod parses a single method from file content. The methodID is of the form "filepath#Module::ClassName#methodName" or "filepath#Module::ClassName.self.methodName" for singleton methods.

func (*RubySource) ParseSourceCode

func (s *RubySource) ParseSourceCode(entityID string, content []byte) (string, error)

ParseSourceCode extracts just the source code of a specific entity or method from file content, using the fragment in the identifier.

func (*RubySource) ResolveWrapperURL

func (s *RubySource) ResolveWrapperURL(targetName, targetKind, entitySlug string) string

ResolveWrapperURL constructs the identifier to fetch the wrapped target's source.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL