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.
Files changed (131) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +28 -0
  3. data/README.md +13 -1
  4. data/app/assets/styles/primer_view_components.css +1 -1
  5. data/app/assets/styles/primer_view_components.css.map +1 -1
  6. data/app/components/primer/alpha/action_bar.rb +0 -7
  7. data/app/components/primer/alpha/action_list.css +1 -1
  8. data/app/components/primer/alpha/action_list.css.map +1 -1
  9. data/app/components/primer/alpha/action_menu.rb +0 -269
  10. data/app/components/primer/alpha/auto_complete/item.rb +0 -12
  11. data/app/components/primer/alpha/auto_complete.css +1 -1
  12. data/app/components/primer/alpha/auto_complete.css.map +1 -1
  13. data/app/components/primer/alpha/auto_complete.rb +0 -47
  14. data/app/components/primer/alpha/banner.css +1 -1
  15. data/app/components/primer/alpha/banner.css.map +1 -1
  16. data/app/components/primer/alpha/banner.rb +0 -31
  17. data/app/components/primer/alpha/button_marketing.rb +0 -12
  18. data/app/components/primer/alpha/dialog.css +1 -1
  19. data/app/components/primer/alpha/dialog.css.map +1 -1
  20. data/app/components/primer/alpha/dialog.rb +0 -17
  21. data/app/components/primer/alpha/dropdown.css +1 -1
  22. data/app/components/primer/alpha/dropdown.css.map +1 -1
  23. data/app/components/primer/alpha/dropdown.rb +0 -105
  24. data/app/components/primer/alpha/form_control.rb +0 -11
  25. data/app/components/primer/alpha/hellip_button.rb +0 -9
  26. data/app/components/primer/alpha/hidden_text_expander.rb +0 -9
  27. data/app/components/primer/alpha/image.rb +0 -16
  28. data/app/components/primer/alpha/image_crop.rb +0 -11
  29. data/app/components/primer/alpha/layout.css +1 -1
  30. data/app/components/primer/alpha/layout.css.map +1 -1
  31. data/app/components/primer/alpha/layout.pcss +1 -1
  32. data/app/components/primer/alpha/layout.rb +0 -118
  33. data/app/components/primer/alpha/menu.css +1 -1
  34. data/app/components/primer/alpha/menu.css.map +1 -1
  35. data/app/components/primer/alpha/menu.rb +0 -19
  36. data/app/components/primer/alpha/multi_input.rb +0 -33
  37. data/app/components/primer/alpha/nav_list.rb +0 -69
  38. data/app/components/primer/alpha/navigation/tab.rb +0 -35
  39. data/app/components/primer/alpha/octicon_symbols.rb +0 -6
  40. data/app/components/primer/alpha/overlay.rb +0 -14
  41. data/app/components/primer/alpha/segmented_control.css +1 -1
  42. data/app/components/primer/alpha/segmented_control.css.map +1 -1
  43. data/app/components/primer/alpha/segmented_control.rb +0 -61
  44. data/app/components/primer/alpha/tab_container.rb +0 -18
  45. data/app/components/primer/alpha/tab_nav.css +1 -1
  46. data/app/components/primer/alpha/tab_nav.css.map +1 -1
  47. data/app/components/primer/alpha/tab_nav.rb +0 -63
  48. data/app/components/primer/alpha/tab_panels.rb +0 -16
  49. data/app/components/primer/alpha/text_field.css +1 -1
  50. data/app/components/primer/alpha/text_field.css.map +1 -1
  51. data/app/components/primer/alpha/text_field.rb +0 -68
  52. data/app/components/primer/alpha/toggle_switch.css +1 -1
  53. data/app/components/primer/alpha/toggle_switch.css.map +1 -1
  54. data/app/components/primer/alpha/toggle_switch.rb +0 -18
  55. data/app/components/primer/alpha/tooltip.rb +1 -69
  56. data/app/components/primer/alpha/underline_nav.css +1 -1
  57. data/app/components/primer/alpha/underline_nav.css.map +1 -1
  58. data/app/components/primer/alpha/underline_nav.rb +0 -61
  59. data/app/components/primer/alpha/underline_panels.rb +0 -19
  60. data/app/components/primer/beta/auto_complete/item.rb +0 -8
  61. data/app/components/primer/beta/auto_complete.rb +0 -56
  62. data/app/components/primer/beta/avatar.css +1 -1
  63. data/app/components/primer/beta/avatar.css.map +1 -1
  64. data/app/components/primer/beta/avatar.rb +0 -18
  65. data/app/components/primer/beta/avatar_stack.css +1 -1
  66. data/app/components/primer/beta/avatar_stack.css.map +1 -1
  67. data/app/components/primer/beta/avatar_stack.rb +0 -21
  68. data/app/components/primer/beta/base_button.rb +0 -4
  69. data/app/components/primer/beta/blankslate.css +1 -1
  70. data/app/components/primer/beta/blankslate.css.map +1 -1
  71. data/app/components/primer/beta/blankslate.rb +0 -104
  72. data/app/components/primer/beta/border_box/header.rb +4 -11
  73. data/app/components/primer/beta/border_box.css +1 -1
  74. data/app/components/primer/beta/border_box.css.map +1 -1
  75. data/app/components/primer/beta/border_box.html.erb +2 -2
  76. data/app/components/primer/beta/border_box.rb +11 -55
  77. data/app/components/primer/beta/breadcrumbs.rb +0 -7
  78. data/app/components/primer/beta/button.css +1 -1
  79. data/app/components/primer/beta/button.css.map +1 -1
  80. data/app/components/primer/beta/button.pcss +2 -2
  81. data/app/components/primer/beta/button.rb +0 -42
  82. data/app/components/primer/beta/button_group.css +1 -1
  83. data/app/components/primer/beta/button_group.css.map +1 -1
  84. data/app/components/primer/beta/button_group.rb +0 -16
  85. data/app/components/primer/beta/clipboard_copy.rb +0 -12
  86. data/app/components/primer/beta/close_button.rb +0 -3
  87. data/app/components/primer/beta/counter.rb +0 -8
  88. data/app/components/primer/beta/details.rb +0 -11
  89. data/app/components/primer/beta/flash.css +1 -1
  90. data/app/components/primer/beta/flash.css.map +1 -1
  91. data/app/components/primer/beta/flash.rb +1 -23
  92. data/app/components/primer/beta/heading.rb +0 -8
  93. data/app/components/primer/beta/icon_button.rb +0 -21
  94. data/app/components/primer/beta/label.css +1 -1
  95. data/app/components/primer/beta/label.css.map +1 -1
  96. data/app/components/primer/beta/label.rb +0 -20
  97. data/app/components/primer/beta/link.rb +0 -22
  98. data/app/components/primer/beta/markdown.rb +1 -262
  99. data/app/components/primer/beta/octicon.rb +0 -10
  100. data/app/components/primer/beta/popover.css +1 -1
  101. data/app/components/primer/beta/popover.css.map +1 -1
  102. data/app/components/primer/beta/popover.rb +0 -43
  103. data/app/components/primer/beta/progress_bar.rb +1 -22
  104. data/app/components/primer/beta/relative_time.rb +0 -9
  105. data/app/components/primer/beta/spinner.rb +2 -10
  106. data/app/components/primer/beta/state.rb +0 -13
  107. data/app/components/primer/beta/subhead.rb +0 -55
  108. data/app/components/primer/beta/text.rb +0 -4
  109. data/app/components/primer/beta/timeline_item.css +1 -1
  110. data/app/components/primer/beta/timeline_item.css.map +1 -1
  111. data/app/components/primer/beta/timeline_item.rb +0 -9
  112. data/app/components/primer/beta/truncate.rb +0 -50
  113. data/app/components/primer/blankslate_component.rb +0 -76
  114. data/app/components/primer/box.rb +0 -6
  115. data/app/components/primer/button_component.rb +0 -49
  116. data/app/components/primer/conditional_wrapper.rb +2 -17
  117. data/app/components/primer/icon_button.rb +0 -30
  118. data/app/components/primer/layout_component.rb +0 -12
  119. data/app/components/primer/tooltip.rb +0 -27
  120. data/app/components/primer/truncate.rb +0 -19
  121. data/lib/primer/accessibility.rb +1 -1
  122. data/lib/primer/deprecations.yml +3 -3
  123. data/lib/primer/forms/dsl/input.rb +1 -0
  124. data/lib/primer/view_components/linters/migrations/truncate_component.rb +45 -0
  125. data/lib/primer/view_components/linters.rb +1 -0
  126. data/lib/primer/view_components/version.rb +2 -2
  127. data/lib/primer/yard.rb +8 -9
  128. data/static/arguments.json +12 -1
  129. data/static/info_arch.json +18 -1
  130. metadata +3 -3
  131. 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