Skip to content

Commit fefe729

Browse files
authored
[Documentation] Add documentation for batch 4 components (#339)
* Add documentation for batch 4 components * Add missing stub classes and methods for documentation - Update VisualCodeExample to accept description and src parameters - Add InlineLink, Text, Alert, AlertTitle, AlertDescription helpers - Add route helper stubs (docs_*_path methods) - Add sidebar example constants * Add documentation for batch 5 components (#340) Add documentation files for skeleton, switch, table, tabs, textarea, theme_toggle, tooltip, and typography components. Also adds missing stub methods for typography docs (Components.Heading, Components.TypographyList, InlineCode, docs_installation_path).
1 parent 7bd455f commit fefe729

File tree

19 files changed

+2271
-1
lines changed

19 files changed

+2271
-1
lines changed

lib/ruby_ui/docs/base.rb

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,81 @@ def Heading(level:, &)
1010
def component_files(component_name)
1111
[]
1212
end
13+
14+
# Text helper for wrapping paragraphs
15+
def Text(&)
16+
p(&)
17+
end
18+
19+
# InlineLink helper for documentation links
20+
def InlineLink(href:, target: nil, class: nil, &)
21+
a(href: href, target: target, class: binding.local_variable_get(:class), &)
22+
end
23+
24+
# Alert component helpers
25+
def Alert(&)
26+
div(&)
27+
end
28+
29+
def AlertTitle(&)
30+
h4(&)
31+
end
32+
33+
def AlertDescription(&)
34+
p(&)
35+
end
36+
37+
# Route helper stubs - return "#" as placeholder
38+
def docs_sheet_path
39+
"#"
40+
end
41+
42+
def docs_separator_path
43+
"#"
44+
end
45+
46+
def docs_accordion_path
47+
"#"
48+
end
49+
50+
def docs_alert_path
51+
"#"
52+
end
53+
54+
def docs_alert_dialog_path
55+
"#"
56+
end
57+
58+
def docs_aspect_ratio_path
59+
"#"
60+
end
61+
62+
def docs_avatar_path
63+
"#"
64+
end
65+
66+
def docs_badge_path
67+
"#"
68+
end
69+
70+
def docs_installation_path
71+
"#"
72+
end
73+
74+
# InlineCode helper for typography examples
75+
def InlineCode(&)
76+
code(&)
77+
end
78+
end
79+
end
80+
81+
# Module-level components stub
82+
module Components
83+
def self.Heading(level:, &block)
84+
# Stub for module-level Heading calls
85+
end
86+
87+
def self.TypographyList(items:, numbered: false)
88+
# Stub for TypographyList component
1389
end
1490
end
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# frozen_string_literal: true
2+
3+
# Stub constants for sidebar documentation examples
4+
# These are replaced with actual implementations in the web app
5+
6+
module Views
7+
module Docs
8+
class Sidebar < Views::Base
9+
class Example
10+
CODE = <<~RUBY
11+
# Sidebar example code placeholder
12+
RUBY
13+
end
14+
15+
class InsetExample
16+
CODE = <<~RUBY
17+
# Sidebar inset example code placeholder
18+
RUBY
19+
end
20+
end
21+
end
22+
end

lib/ruby_ui/docs/visual_code_example.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,18 @@
22

33
module Docs
44
class VisualCodeExample < Phlex::HTML
5-
def initialize(title:, context:)
5+
def initialize(title:, context:, description: nil, src: nil)
66
@title = title
77
@context = context
8+
@description = description
9+
@src = src
810
end
911

1012
def view_template(&block)
1113
code = block.call
1214
div do
1315
h3 { @title }
16+
p { @description } if @description
1417
pre { code }
1518
@context.instance_eval(code)
1619
end

0 commit comments

Comments
 (0)