openproject-primer_view_components 0.6.3 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +28 -0
- data/README.md +13 -1
- data/app/assets/styles/primer_view_components.css +1 -1
- data/app/assets/styles/primer_view_components.css.map +1 -1
- data/app/components/primer/alpha/action_bar.rb +0 -7
- data/app/components/primer/alpha/action_list.css +1 -1
- data/app/components/primer/alpha/action_list.css.map +1 -1
- data/app/components/primer/alpha/action_menu.rb +0 -269
- data/app/components/primer/alpha/auto_complete/item.rb +0 -12
- data/app/components/primer/alpha/auto_complete.css +1 -1
- data/app/components/primer/alpha/auto_complete.css.map +1 -1
- data/app/components/primer/alpha/auto_complete.rb +0 -47
- data/app/components/primer/alpha/banner.css +1 -1
- data/app/components/primer/alpha/banner.css.map +1 -1
- data/app/components/primer/alpha/banner.rb +0 -31
- data/app/components/primer/alpha/button_marketing.rb +0 -12
- data/app/components/primer/alpha/dialog.css +1 -1
- data/app/components/primer/alpha/dialog.css.map +1 -1
- data/app/components/primer/alpha/dialog.rb +0 -17
- data/app/components/primer/alpha/dropdown.css +1 -1
- data/app/components/primer/alpha/dropdown.css.map +1 -1
- data/app/components/primer/alpha/dropdown.rb +0 -105
- data/app/components/primer/alpha/form_control.rb +0 -11
- data/app/components/primer/alpha/hellip_button.rb +0 -9
- data/app/components/primer/alpha/hidden_text_expander.rb +0 -9
- data/app/components/primer/alpha/image.rb +0 -16
- data/app/components/primer/alpha/image_crop.rb +0 -11
- data/app/components/primer/alpha/layout.css +1 -1
- data/app/components/primer/alpha/layout.css.map +1 -1
- data/app/components/primer/alpha/layout.pcss +1 -1
- data/app/components/primer/alpha/layout.rb +0 -118
- data/app/components/primer/alpha/menu.css +1 -1
- data/app/components/primer/alpha/menu.css.map +1 -1
- data/app/components/primer/alpha/menu.rb +0 -19
- data/app/components/primer/alpha/multi_input.rb +0 -33
- data/app/components/primer/alpha/nav_list.rb +0 -69
- data/app/components/primer/alpha/navigation/tab.rb +0 -35
- data/app/components/primer/alpha/octicon_symbols.rb +0 -6
- data/app/components/primer/alpha/overlay.rb +0 -14
- data/app/components/primer/alpha/segmented_control.css +1 -1
- data/app/components/primer/alpha/segmented_control.css.map +1 -1
- data/app/components/primer/alpha/segmented_control.rb +0 -61
- data/app/components/primer/alpha/tab_container.rb +0 -18
- data/app/components/primer/alpha/tab_nav.css +1 -1
- data/app/components/primer/alpha/tab_nav.css.map +1 -1
- data/app/components/primer/alpha/tab_nav.rb +0 -63
- data/app/components/primer/alpha/tab_panels.rb +0 -16
- data/app/components/primer/alpha/text_field.css +1 -1
- data/app/components/primer/alpha/text_field.css.map +1 -1
- data/app/components/primer/alpha/text_field.rb +0 -68
- data/app/components/primer/alpha/toggle_switch.css +1 -1
- data/app/components/primer/alpha/toggle_switch.css.map +1 -1
- data/app/components/primer/alpha/toggle_switch.rb +0 -18
- data/app/components/primer/alpha/tooltip.rb +1 -69
- data/app/components/primer/alpha/underline_nav.css +1 -1
- data/app/components/primer/alpha/underline_nav.css.map +1 -1
- data/app/components/primer/alpha/underline_nav.rb +0 -61
- data/app/components/primer/alpha/underline_panels.rb +0 -19
- data/app/components/primer/beta/auto_complete/item.rb +0 -8
- data/app/components/primer/beta/auto_complete.rb +0 -56
- data/app/components/primer/beta/avatar.css +1 -1
- data/app/components/primer/beta/avatar.css.map +1 -1
- data/app/components/primer/beta/avatar.rb +0 -18
- data/app/components/primer/beta/avatar_stack.css +1 -1
- data/app/components/primer/beta/avatar_stack.css.map +1 -1
- data/app/components/primer/beta/avatar_stack.rb +0 -21
- data/app/components/primer/beta/base_button.rb +0 -4
- data/app/components/primer/beta/blankslate.css +1 -1
- data/app/components/primer/beta/blankslate.css.map +1 -1
- data/app/components/primer/beta/blankslate.rb +0 -104
- data/app/components/primer/beta/border_box/header.rb +4 -11
- data/app/components/primer/beta/border_box.css +1 -1
- data/app/components/primer/beta/border_box.css.map +1 -1
- data/app/components/primer/beta/border_box.html.erb +2 -2
- data/app/components/primer/beta/border_box.rb +11 -55
- data/app/components/primer/beta/breadcrumbs.rb +0 -7
- data/app/components/primer/beta/button.css +1 -1
- data/app/components/primer/beta/button.css.map +1 -1
- data/app/components/primer/beta/button.pcss +2 -2
- data/app/components/primer/beta/button.rb +0 -42
- data/app/components/primer/beta/button_group.css +1 -1
- data/app/components/primer/beta/button_group.css.map +1 -1
- data/app/components/primer/beta/button_group.rb +0 -16
- data/app/components/primer/beta/clipboard_copy.rb +0 -12
- data/app/components/primer/beta/close_button.rb +0 -3
- data/app/components/primer/beta/counter.rb +0 -8
- data/app/components/primer/beta/details.rb +0 -11
- data/app/components/primer/beta/flash.css +1 -1
- data/app/components/primer/beta/flash.css.map +1 -1
- data/app/components/primer/beta/flash.rb +1 -23
- data/app/components/primer/beta/heading.rb +0 -8
- data/app/components/primer/beta/icon_button.rb +0 -21
- data/app/components/primer/beta/label.css +1 -1
- data/app/components/primer/beta/label.css.map +1 -1
- data/app/components/primer/beta/label.rb +0 -20
- data/app/components/primer/beta/link.rb +0 -22
- data/app/components/primer/beta/markdown.rb +1 -262
- data/app/components/primer/beta/octicon.rb +0 -10
- data/app/components/primer/beta/popover.css +1 -1
- data/app/components/primer/beta/popover.css.map +1 -1
- data/app/components/primer/beta/popover.rb +0 -43
- data/app/components/primer/beta/progress_bar.rb +1 -22
- data/app/components/primer/beta/relative_time.rb +0 -9
- data/app/components/primer/beta/spinner.rb +2 -10
- data/app/components/primer/beta/state.rb +0 -13
- data/app/components/primer/beta/subhead.rb +0 -55
- data/app/components/primer/beta/text.rb +0 -4
- data/app/components/primer/beta/timeline_item.css +1 -1
- data/app/components/primer/beta/timeline_item.css.map +1 -1
- data/app/components/primer/beta/timeline_item.rb +0 -9
- data/app/components/primer/beta/truncate.rb +0 -50
- data/app/components/primer/blankslate_component.rb +0 -76
- data/app/components/primer/box.rb +0 -6
- data/app/components/primer/button_component.rb +0 -49
- data/app/components/primer/conditional_wrapper.rb +2 -17
- data/app/components/primer/icon_button.rb +0 -30
- data/app/components/primer/layout_component.rb +0 -12
- data/app/components/primer/tooltip.rb +0 -27
- data/app/components/primer/truncate.rb +0 -19
- data/lib/primer/accessibility.rb +1 -1
- data/lib/primer/deprecations.yml +3 -3
- data/lib/primer/forms/dsl/input.rb +1 -0
- data/lib/primer/view_components/linters/migrations/truncate_component.rb +45 -0
- data/lib/primer/view_components/linters.rb +1 -0
- data/lib/primer/view_components/version.rb +2 -2
- data/lib/primer/yard.rb +8 -9
- data/static/arguments.json +12 -1
- data/static/info_arch.json +18 -1
- metadata +3 -3
- data/lib/primer/yard/legacy_gatsby_backend.rb +0 -233
@@ -1,233 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# rubocop:disable Naming/MethodParameterName
|
4
|
-
|
5
|
-
# :nocov:
|
6
|
-
module Primer
|
7
|
-
module Yard
|
8
|
-
# Backend that generates documentation for the legacy, Gatsby-powered PVC docsite.
|
9
|
-
class LegacyGatsbyBackend < Backend
|
10
|
-
class << self
|
11
|
-
def parse_example_tag(tag)
|
12
|
-
name = tag.name
|
13
|
-
description = nil
|
14
|
-
code = nil
|
15
|
-
|
16
|
-
if tag.text.include?("@description")
|
17
|
-
splitted = tag.text.split(/@description|@code/)
|
18
|
-
description = splitted.second.gsub(/^[ \t]{2}/, "").strip
|
19
|
-
code = splitted.last.gsub(/^[ \t]{2}/, "").strip
|
20
|
-
else
|
21
|
-
code = tag.text
|
22
|
-
end
|
23
|
-
|
24
|
-
[name, description, code]
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
attr_reader :registry, :manifest
|
29
|
-
|
30
|
-
def initialize(registry, manifest)
|
31
|
-
@registry = registry
|
32
|
-
@manifest = manifest
|
33
|
-
end
|
34
|
-
|
35
|
-
def generate
|
36
|
-
errors = []
|
37
|
-
|
38
|
-
each_component do |component_ref|
|
39
|
-
component = component_ref.klass
|
40
|
-
docs = registry.find(component)
|
41
|
-
status_path = docs.status_module.nil? ? "" : "#{docs.status_module}/"
|
42
|
-
|
43
|
-
metadata = docs.metadata.merge(
|
44
|
-
source: component_ref.source_url,
|
45
|
-
lookbook: component_ref.lookbook_url,
|
46
|
-
path: "docs/content/components/#{status_path}#{docs.short_name.downcase}.md",
|
47
|
-
example_path: example_path(component),
|
48
|
-
require_js_path: require_js_path(component)
|
49
|
-
)
|
50
|
-
|
51
|
-
path = Pathname.new(metadata[:path])
|
52
|
-
path.dirname.mkpath unless path.dirname.exist?
|
53
|
-
|
54
|
-
File.open(path, "w") do |f|
|
55
|
-
f.puts("---")
|
56
|
-
f.puts("title: #{metadata[:title]}")
|
57
|
-
f.puts("componentId: #{metadata[:component_id]}")
|
58
|
-
f.puts("status: #{metadata[:status]}")
|
59
|
-
f.puts("source: #{metadata[:source]}")
|
60
|
-
f.puts("a11yReviewed: #{metadata[:a11y_reviewed]}")
|
61
|
-
f.puts("lookbook: #{metadata[:lookbook]}") if preview_exists?(component)
|
62
|
-
f.puts("---")
|
63
|
-
f.puts
|
64
|
-
f.puts("import Example from '#{metadata[:example_path]}'")
|
65
|
-
|
66
|
-
if component_ref.requires_js?
|
67
|
-
f.puts("import RequiresJSFlash from '#{metadata[:require_js_path]}'")
|
68
|
-
f.puts
|
69
|
-
f.puts("<RequiresJSFlash />")
|
70
|
-
end
|
71
|
-
|
72
|
-
f.puts
|
73
|
-
f.puts("<!-- Warning: AUTO-GENERATED file, do not edit. Add code comments to your Ruby instead <3 -->")
|
74
|
-
f.puts
|
75
|
-
f.puts(view_context.render(inline: docs.base_docstring))
|
76
|
-
|
77
|
-
if docs.tags(:deprecated).any?
|
78
|
-
f.puts
|
79
|
-
f.puts("## Deprecation")
|
80
|
-
docs.tags(:deprecated).each do |tag|
|
81
|
-
f.puts
|
82
|
-
f.puts view_context.render(inline: tag.text)
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
if docs.tags(:accessibility).any?
|
87
|
-
f.puts
|
88
|
-
f.puts("## Accessibility")
|
89
|
-
docs.tags(:accessibility).each do |tag|
|
90
|
-
f.puts
|
91
|
-
f.puts view_context.render(inline: tag.text)
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
errors << { component.name => { arguments: "No argument documentation found" } } unless docs.params.any?
|
96
|
-
|
97
|
-
f.puts
|
98
|
-
f.puts("## Arguments")
|
99
|
-
f.puts
|
100
|
-
f.puts("| Name | Type | Default | Description |")
|
101
|
-
f.puts("| :- | :- | :- | :- |")
|
102
|
-
|
103
|
-
documented_params = docs.params.map(&:name)
|
104
|
-
component_params = component.instance_method(:initialize).parameters.map { |p| p.last.to_s }
|
105
|
-
|
106
|
-
if (documented_params & component_params).size != component_params.size
|
107
|
-
err = { arguments: {} }
|
108
|
-
(component_params - documented_params).each do |arg|
|
109
|
-
err[:arguments][arg] = "Not documented"
|
110
|
-
end
|
111
|
-
|
112
|
-
errors << { component.name => err }
|
113
|
-
end
|
114
|
-
|
115
|
-
docs.params.each do |tag|
|
116
|
-
default_value = pretty_default_value(tag, component)
|
117
|
-
f.puts("| `#{tag.name}` | `#{tag.types.join(', ')}` | #{default_value} | #{view_context.render(inline: tag.text.squish)} |")
|
118
|
-
end
|
119
|
-
|
120
|
-
if docs.slot_methods.any?
|
121
|
-
f.puts
|
122
|
-
f.puts("## Slots")
|
123
|
-
|
124
|
-
docs.slot_methods.each do |slot_docs|
|
125
|
-
emit_method(slot_docs, component, f)
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
example_tags = docs.constructor.tags(:example)
|
130
|
-
|
131
|
-
if example_tags.any?
|
132
|
-
f.puts
|
133
|
-
f.puts("## Examples")
|
134
|
-
|
135
|
-
example_tags.each do |tag|
|
136
|
-
name, description, code = parse_example_tag(tag)
|
137
|
-
f.puts
|
138
|
-
f.puts("### #{name}")
|
139
|
-
if description
|
140
|
-
f.puts
|
141
|
-
f.puts(view_context.render(inline: description.squish))
|
142
|
-
end
|
143
|
-
f.puts
|
144
|
-
html = view_context.render(inline: code)
|
145
|
-
f.puts("<Example src=\"#{html.tr('"', "\'").delete("\n")}\" />")
|
146
|
-
f.puts
|
147
|
-
f.puts("```erb")
|
148
|
-
f.puts(code.to_s)
|
149
|
-
f.puts("```")
|
150
|
-
end
|
151
|
-
elsif component_ref.should_have_examples?
|
152
|
-
errors << { component.name => { example: "No examples found" } }
|
153
|
-
end
|
154
|
-
end
|
155
|
-
end
|
156
|
-
|
157
|
-
# Build system arguments docs from BaseComponent
|
158
|
-
system_args_docs = registry.find(Primer::BaseComponent)
|
159
|
-
|
160
|
-
File.open("docs/content/system-arguments.md", "w") do |f|
|
161
|
-
f.puts("---")
|
162
|
-
f.puts("title: System arguments")
|
163
|
-
f.puts("---")
|
164
|
-
f.puts
|
165
|
-
f.puts("<!-- Warning: AUTO-GENERATED file, do not edit. Add code comments to your Ruby instead <3 -->")
|
166
|
-
f.puts
|
167
|
-
f.puts(system_args_docs.base_docstring)
|
168
|
-
f.puts
|
169
|
-
|
170
|
-
f.puts(view_context.render(inline: system_args_docs.constructor.base_docstring))
|
171
|
-
end
|
172
|
-
|
173
|
-
errors
|
174
|
-
end
|
175
|
-
|
176
|
-
private
|
177
|
-
|
178
|
-
def emit_method(method_docs, component, f)
|
179
|
-
f.puts
|
180
|
-
f.puts("### `#{method_docs.name}`")
|
181
|
-
|
182
|
-
if method_docs.base_docstring.to_s.present?
|
183
|
-
f.puts
|
184
|
-
f.puts(view_context.render(inline: method_docs.base_docstring))
|
185
|
-
end
|
186
|
-
|
187
|
-
param_tags = method_docs.tags(:param)
|
188
|
-
if param_tags.any?
|
189
|
-
f.puts
|
190
|
-
f.puts("| Name | Type | Default | Description |")
|
191
|
-
f.puts("| :- | :- | :- | :- |")
|
192
|
-
end
|
193
|
-
|
194
|
-
param_tags.each do |tag|
|
195
|
-
f.puts("| `#{tag.name}` | `#{tag.types.join(', ')}` | #{pretty_default_value(tag, component)} | #{view_context.render(inline: tag.text)} |")
|
196
|
-
end
|
197
|
-
end
|
198
|
-
|
199
|
-
def each_component(&block)
|
200
|
-
manifest.each(&block)
|
201
|
-
end
|
202
|
-
|
203
|
-
def example_path(component)
|
204
|
-
example_path = "../../src/@primer/gatsby-theme-doctocat/components/example"
|
205
|
-
example_path = "../#{example_path}" if status_module?(component)
|
206
|
-
example_path
|
207
|
-
end
|
208
|
-
|
209
|
-
def require_js_path(component)
|
210
|
-
require_js_path = "../../src/@primer/gatsby-theme-doctocat/components/requires-js-flash"
|
211
|
-
require_js_path = "../#{require_js_path}" if status_module?(component)
|
212
|
-
require_js_path
|
213
|
-
end
|
214
|
-
|
215
|
-
def preview_exists?(component)
|
216
|
-
path = component.name.underscore
|
217
|
-
|
218
|
-
File.exist?("previews/#{path}_preview.rb")
|
219
|
-
end
|
220
|
-
|
221
|
-
def status_module?(component)
|
222
|
-
(%w[Alpha Beta] & component.name.split("::")).any?
|
223
|
-
end
|
224
|
-
|
225
|
-
def parse_example_tag(tag)
|
226
|
-
self.class.parse_example_tag(tag)
|
227
|
-
end
|
228
|
-
end
|
229
|
-
end
|
230
|
-
end
|
231
|
-
# :nocov:
|
232
|
-
|
233
|
-
# rubocop:enable Naming/MethodParameterName
|