Skip to content

Conversation

@djalmaaraujo
Copy link
Contributor

Related issue

Related to #334

Description

Add a new generator and stub infrastructure to support component documentation files in the gem.

Changes:

  • Docs Generator (ruby_ui:install:docs): Copies *_docs.rb files from the gem to app/views/docs/ in Rails
    apps, stripping the _docs suffix
  • Stub Classes (lib/ruby_ui/docs/): Minimal implementations of Views::Base, Docs::Header,
    Docs::VisualCodeExample, Docs::ComponentsTable, and Components::ComponentSetup::Tabs so docs files can load
    without errors. Rails apps can override these with full implementations
  • Button Documentation: First example docs file at lib/ruby_ui/button/button_docs.rb
  • Test Helper: Updated to exclude /docs/ and *_docs.rb from autoloading
  • CONTRIBUTING.md: Added installation instructions for docs

IMPORTANT: This is the first pull request with the generators. The following will contain a batch of components. At the end of this big migration.

Testing instructions

Execute the following tests with the web/ repo from this organization.

  1. Point a rails repo with ruby_ui installed to the source in Gemfile: gem "ruby_ui", path: "../ruby_ui"
  2. If you have a file in app/views/docs/button.docs, remove it
  3. Run bin/rails g ruby_ui:install:docs.
  4. The app/views/docs/button.rb should be there again.

Introduce a new generator (`ruby_ui:install:docs`) that copies component
documentation files from the gem to Rails applications. Documentation
files follow the naming convention `{component}_docs.rb` and are copied
to `app/views/docs/` with the `_docs` suffix removed.

Usage:
  bin/rails g ruby_ui:install:docs
  bin/rails g ruby_ui:install:docs --force

Include stub classes for docs dependencies (Views::Base, Docs::Header,
Docs::VisualCodeExample, etc.) so docs files can be loaded without errors.
Rails apps can override these with full implementations.

Includes button component documentation as the first example.
Add docs files for:
- accordion
- alert
- alert_dialog
- aspect_ratio
- avatar
- badge
- breadcrumb
- calendar
- card
@cirdes cirdes merged commit f9d703f into main Dec 11, 2025
2 checks passed
@cirdes cirdes deleted the docs-generator branch December 11, 2025 17:33
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.

3 participants