Skip to content

Compact YARD docs and add RBS support#22

Merged
bdurand merged 9 commits intomainfrom
compress-yard-docs
May 9, 2026
Merged

Compact YARD docs and add RBS support#22
bdurand merged 9 commits intomainfrom
compress-yard-docs

Conversation

@bdurand
Copy link
Copy Markdown
Owner

@bdurand bdurand commented May 8, 2026

  • Each model can now choose how its YARD docs are generated by setting self.support_table_yard_docs to :full (the default — verbose comment block per method), :compact (shared @!macro definitions plus a short @!method/@!macro pair per method, dramatically reducing comment-block size on tables with many named instances), or :none (skip generation entirely; previously generated docs are stripped on the next run). IDEs and yard doc resolve the compact form into the same per-method documentation as the verbose form.

  • Attribute helper return types in the generated YARD and RBS docs are now inferred per method by inspecting the value the helper actually returns (String, Integer, Boolean, etc.) instead of the generic Object/untyped. Because the helpers return frozen literals from the parsed data file, the documentation tasks no longer require a database connection.

  • Added opt-in RBS signature generation. The new tasks support_table_data:rbs, support_table_data:rbs:verify, and support_table_data:rbs:remove write/check/delete sig/<model_path>.rbs files so the named instance helpers are visible to Ruby LSP, Steep, RubyMine, and other RBS-aware tools without polluting the model source files. The output directory can be overridden with SupportTableData.rbs_signatures_path.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR enhances SupportTableData’s generated developer tooling artifacts by (1) making YARD output more scalable/readable via macros, (2) improving documentation/RBS type accuracy via ActiveRecord column type inference with a clearer failure mode, and (3) adding opt-in per-model RBS signature generation and tasks, alongside an autoload-based loading strategy.

Changes:

  • Generate compact @!macro-based YARD docs above a configurable named-instance threshold; infer attribute helper return types from AR column types.
  • Add RBS signature generation (sig/.../*.rbs) via new documentation classes and rake tasks (add/verify/remove), plus supporting utilities.
  • Refactor loading to use autoload; update tests, README/CHANGELOG, and bump version to 1.6.0.

Reviewed changes

Copilot reviewed 22 out of 22 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
VERSION Bumps gem version to 1.6.0.
test_app/app/models/status.rb Updates generated YARD return types from Object to String.
support_table_data.gemspec Excludes test_app/ from packaged gem files.
spec/tasks_spec.rb Updates task specs and adds coverage for new RBS tasks.
spec/support_table_data/documentation/yard_doc_spec.rb Adds tests for type inference and compact macro YARD output.
spec/support_table_data/documentation/type_inference_spec.rb Adds unit tests for column type inference and mappings.
spec/support_table_data/documentation/rbs_file_spec.rb Adds tests for writing/removing/up-to-date checks for RBS files.
spec/support_table_data/documentation/rbs_doc_spec.rb Adds tests for generated per-model RBS signature content.
spec/support_table_data_spec.rb Switches to require "spec_helper".
spec/spec_helper.rb Relies on autoload (removes explicit documentation require).
README.md Documents compact YARD output, type inference behavior, and RBS generation tasks.
lib/tasks/support_table_data.rake Removes explicit requires; adds RBS rake tasks and task alias.
lib/support_table_data/tasks/utils.rb Adds helper to enumerate per-model RBS file handlers.
lib/support_table_data/tasks.rb Introduces SupportTableData::Tasks autoload shim.
lib/support_table_data/documentation/yard_doc.rb Implements compact macro YARD generation + typed attribute helper docs.
lib/support_table_data/documentation/type_inference.rb Adds type inference and YARD/RBS type mapping utilities.
lib/support_table_data/documentation/rbs_file.rb Adds per-model RBS file pathing and read/write/remove logic.
lib/support_table_data/documentation/rbs_doc.rb Generates RBS signatures for named instance helpers.
lib/support_table_data/documentation.rb Switches documentation components to autoload.
lib/support_table_data/documentation_connection_error.rb Adds a clearer error for type-inference DB failures.
lib/support_table_data.rb Adds config accessors/defaults + autoload for new components.
CHANGELOG.md Documents the 1.6.0 changes.
Comments suppressed due to low confidence (1)

lib/support_table_data/tasks/utils.rb:62

  • support_table_rbs_files forwards file_path to support_table_sources, which currently does require_relative file_path when a path is provided. If callers pass a project-relative path like app/models/feature.rb (as shown in the README), require_relative will resolve it relative to lib/support_table_data/tasks/utils.rb and likely raise LoadError. Consider changing support_table_sources to require the expanded path (or skip requiring entirely since eager_load! should already load models).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/support_table_data.rb Outdated
Comment thread lib/tasks/support_table_data.rake
Comment thread README.md Outdated
Comment thread lib/tasks/support_table_data.rake Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 24 out of 24 changed files in this pull request and generated 1 comment.

Comment thread spec/support_table_data/documentation/rbs_file_spec.rb
@bdurand bdurand changed the title Compact YARD docs; add RBS support; use autoload Compact YARD docs and add RBS support May 8, 2026
@bdurand bdurand merged commit ac1bb75 into main May 9, 2026
7 checks passed
@bdurand bdurand deleted the compress-yard-docs branch May 9, 2026 01:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants