Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a custom YARD plugin to enable structured documentation of ViewComponent slots using the @viewcomponent_slot tag. The implementation follows YARD's conventions for custom tags and provides rendering in the documentation viewer.
Changes:
- Added a YARD plugin that defines the
@viewcomponent_slottag with type, name, and description support - Updated the documentation view template to render slot documentation in a "Slots" section
- Added
@viewcomponent_slotdocumentation to three existing components (Card, Breadcrumb, and InputField) - Modified the Rakefile to load the custom YARD plugin during documentation generation
- Regenerated YARD registry files to include the new slot documentation
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/yard/flowbite_viewcomponent.rb | New YARD plugin defining the @viewcomponent_slot tag for documenting ViewComponent slots |
| demo/app/views/docs/components/show.html.erb | Added rendering logic for the "Slots" section displaying documented slots with types and descriptions |
| Rakefile | Updated the docs:refresh_registry task to load the custom YARD plugin with the -e flag |
| app/components/flowbite/card.rb | Added @viewcomponent_slot documentation for the title slot |
| app/components/flowbite/breadcrumb.rb | Added @viewcomponent_slot documentation for the items slot |
| app/components/flowbite/input_field.rb | Added @viewcomponent_slot documentation for hint, input, and label slots |
| demo/.yardoc/objects/root.dat | Regenerated YARD registry file with the new slot documentation |
| demo/.yardoc/checksums | Updated checksums for files with new slot documentation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| <li> | ||
| <span class="name"><%= slot_tag.name %></span> | ||
| <% if slot_tag.types&.any? %> | ||
| <span class="type">(<%= slot_tag.types.map { |t| link_to(t, "#") }.join(", ").html_safe %>)</span> |
There was a problem hiding this comment.
Using html_safe on user-provided content from link_to can introduce XSS vulnerabilities. The slot_tag.types values come from YARD documentation tags, but treating them as safe HTML without proper sanitization is risky. Consider using safe_join instead to properly escape each type before joining them, or ensure that the types are already properly escaped by the link_to helper before joining.
| <span class="type">(<%= slot_tag.types.map { |t| link_to(t, "#") }.join(", ").html_safe %>)</span> | |
| <span class="type">(<%= safe_join(slot_tag.types.map { |t| link_to(t, "#") }, ", ") %>)</span> |
| <li> | ||
| <span class="name"><%= slot_tag.name %></span> | ||
| <% if slot_tag.types&.any? %> | ||
| <span class="type">(<%= slot_tag.types.map { |t| link_to(t, "#") }.join(", ").html_safe %>)</span> |
There was a problem hiding this comment.
The links generated for slot types point to "#" which doesn't navigate anywhere useful. Consider implementing proper links to the actual type documentation, or if the links aren't functional yet, use a <span> or <code> tag instead of generating non-functional anchor tags.
| <span class="type">(<%= slot_tag.types.map { |t| link_to(t, "#") }.join(", ").html_safe %>)</span> | |
| <span class="type">(<%= slot_tag.types.join(", ") %>)</span> |
Summary
Adds a custom YARD plugin that defines the
@viewcomponent_slottag for documenting ViewComponent slots. This allows developers to document slots in a structured way, similar to how@paramworks for method parameters.The tag accepts types (optional), a slot name, and a description, and is rendered in the generated documentation as a styled list section.
Test plan
bundle exec rake docs:refresh_registryto generate docs with the new plugin🤖 Generated with Claude Code