docks_app 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (313) hide show
  1. data/.editorconfig +8 -0
  2. data/.gitignore +22 -0
  3. data/.rubocop.yml +20 -0
  4. data/.travis.yml +10 -0
  5. data/Gemfile +4 -0
  6. data/LICENSE.txt +22 -0
  7. data/README.md +35 -0
  8. data/Rakefile +3 -0
  9. data/bin/docks +5 -0
  10. data/config/json/docks_config.json +71 -0
  11. data/config/ruby/docks_config.rb +127 -0
  12. data/config/yaml/docks_config.yml +70 -0
  13. data/docks.gemspec +38 -0
  14. data/lib/docks/build.rb +300 -0
  15. data/lib/docks/cache.rb +143 -0
  16. data/lib/docks/command_line.rb +65 -0
  17. data/lib/docks/configuration.rb +217 -0
  18. data/lib/docks/containers/base_container.rb +103 -0
  19. data/lib/docks/containers/class_container.rb +39 -0
  20. data/lib/docks/containers/component_container.rb +92 -0
  21. data/lib/docks/containers/demo_container.rb +105 -0
  22. data/lib/docks/containers/factory_container.rb +12 -0
  23. data/lib/docks/containers/function_container.rb +46 -0
  24. data/lib/docks/containers/mixin_container.rb +19 -0
  25. data/lib/docks/containers/pattern_container.rb +168 -0
  26. data/lib/docks/containers/pattern_library_container.rb +77 -0
  27. data/lib/docks/containers/state_container.rb +9 -0
  28. data/lib/docks/containers/symbol_container.rb +77 -0
  29. data/lib/docks/containers/variable_container.rb +47 -0
  30. data/lib/docks/containers/variant_container.rb +9 -0
  31. data/lib/docks/containers/variation_container.rb +38 -0
  32. data/lib/docks/containers.rb +25 -0
  33. data/lib/docks/descriptor.rb +60 -0
  34. data/lib/docks/errors.rb +5 -0
  35. data/lib/docks/group.rb +66 -0
  36. data/lib/docks/helpers/github_helper.rb +29 -0
  37. data/lib/docks/helpers/path_helper.rb +94 -0
  38. data/lib/docks/helpers/render_helper.rb +87 -0
  39. data/lib/docks/helpers.rb +19 -0
  40. data/lib/docks/languages/base_language.rb +17 -0
  41. data/lib/docks/languages/coffeescript_language.rb +30 -0
  42. data/lib/docks/languages/common_types/markup_language.rb +71 -0
  43. data/lib/docks/languages/css_language.rb +13 -0
  44. data/lib/docks/languages/erb_language.rb +21 -0
  45. data/lib/docks/languages/haml_language.rb +21 -0
  46. data/lib/docks/languages/html_language.rb +10 -0
  47. data/lib/docks/languages/javascript_language.rb +42 -0
  48. data/lib/docks/languages/json_language.rb +18 -0
  49. data/lib/docks/languages/less_language.rb +33 -0
  50. data/lib/docks/languages/markdown_language.rb +10 -0
  51. data/lib/docks/languages/sass_language.rb +36 -0
  52. data/lib/docks/languages/slim_language.rb +21 -0
  53. data/lib/docks/languages/stylus_language.rb +26 -0
  54. data/lib/docks/languages/yaml_language.rb +18 -0
  55. data/lib/docks/languages.rb +103 -0
  56. data/lib/docks/markdown.rb +18 -0
  57. data/lib/docks/messenger.rb +69 -0
  58. data/lib/docks/naming_conventions/base_naming_convention.rb +9 -0
  59. data/lib/docks/naming_conventions/bem_naming_convention.rb +45 -0
  60. data/lib/docks/naming_conventions/suit_naming_convention.rb +45 -0
  61. data/lib/docks/naming_conventions.rb +21 -0
  62. data/lib/docks/ostruct.rb +17 -0
  63. data/lib/docks/parser.rb +86 -0
  64. data/lib/docks/parsers/base_parser.rb +128 -0
  65. data/lib/docks/parsers/coffeescript_parser.rb +30 -0
  66. data/lib/docks/parsers/css_parser.rb +27 -0
  67. data/lib/docks/parsers/javascript_parser.rb +30 -0
  68. data/lib/docks/parsers/less_parser.rb +22 -0
  69. data/lib/docks/parsers/sass_parser.rb +31 -0
  70. data/lib/docks/parsers/stylus_parser.rb +28 -0
  71. data/lib/docks/process.rb +60 -0
  72. data/lib/docks/processors.rb +416 -0
  73. data/lib/docks/renderers/base_renderer.rb +64 -0
  74. data/lib/docks/renderers/common_features/capturable.rb +69 -0
  75. data/lib/docks/renderers/common_features/helperable.rb +23 -0
  76. data/lib/docks/renderers/erb_renderer.rb +68 -0
  77. data/lib/docks/renderers/haml_renderer.rb +37 -0
  78. data/lib/docks/renderers/slim_renderer.rb +33 -0
  79. data/lib/docks/symbol_sources/base_symbol_source.rb +12 -0
  80. data/lib/docks/symbol_sources/jquery_symbol_source.rb +17 -0
  81. data/lib/docks/symbol_sources/mdn_symbol_source.rb +35 -0
  82. data/lib/docks/symbol_sources/sass_symbol_source.rb +27 -0
  83. data/lib/docks/symbol_sources.rb +28 -0
  84. data/lib/docks/tags/access_tag.rb +27 -0
  85. data/lib/docks/tags/activate_with_tag.rb +17 -0
  86. data/lib/docks/tags/active_tag.rb +14 -0
  87. data/lib/docks/tags/alias_tag.rb +17 -0
  88. data/lib/docks/tags/author_tag.rb +19 -0
  89. data/lib/docks/tags/base_tag.rb +52 -0
  90. data/lib/docks/tags/beta_tag.rb +26 -0
  91. data/lib/docks/tags/class_tag.rb +16 -0
  92. data/lib/docks/tags/compatibility_tag.rb +19 -0
  93. data/lib/docks/tags/demo_type_tag.rb +14 -0
  94. data/lib/docks/tags/deprecated_tag.rb +26 -0
  95. data/lib/docks/tags/description_tag.rb +99 -0
  96. data/lib/docks/tags/example_tag.rb +20 -0
  97. data/lib/docks/tags/factory_tag.rb +16 -0
  98. data/lib/docks/tags/for_tag.rb +23 -0
  99. data/lib/docks/tags/group_tag.rb +10 -0
  100. data/lib/docks/tags/helper_tag.rb +13 -0
  101. data/lib/docks/tags/include_with_tag.rb +57 -0
  102. data/lib/docks/tags/javascript_action_tag.rb +10 -0
  103. data/lib/docks/tags/link_tag.rb +18 -0
  104. data/lib/docks/tags/markup_tag.rb +106 -0
  105. data/lib/docks/tags/member_tag.rb +37 -0
  106. data/lib/docks/tags/method_tag.rb +18 -0
  107. data/lib/docks/tags/name_tag.rb +10 -0
  108. data/lib/docks/tags/object_tag.rb +15 -0
  109. data/lib/docks/tags/param_tag.rb +94 -0
  110. data/lib/docks/tags/pattern_tag.rb +21 -0
  111. data/lib/docks/tags/preclude_tag.rb +17 -0
  112. data/lib/docks/tags/private_tag.rb +15 -0
  113. data/lib/docks/tags/property_tag.rb +18 -0
  114. data/lib/docks/tags/public_tag.rb +15 -0
  115. data/lib/docks/tags/require_tag.rb +47 -0
  116. data/lib/docks/tags/returns_tag.rb +31 -0
  117. data/lib/docks/tags/set_by_tag.rb +18 -0
  118. data/lib/docks/tags/signature_tag.rb +35 -0
  119. data/lib/docks/tags/since_tag.rb +26 -0
  120. data/lib/docks/tags/source_tag.rb +12 -0
  121. data/lib/docks/tags/state_tag.rb +21 -0
  122. data/lib/docks/tags/static_tag.rb +14 -0
  123. data/lib/docks/tags/subcomponent_tag.rb +68 -0
  124. data/lib/docks/tags/subtitle_tag.rb +11 -0
  125. data/lib/docks/tags/symbol_type_tag.rb +10 -0
  126. data/lib/docks/tags/throws_tag.rb +30 -0
  127. data/lib/docks/tags/title_tag.rb +10 -0
  128. data/lib/docks/tags/type_tag.rb +10 -0
  129. data/lib/docks/tags/value_tag.rb +10 -0
  130. data/lib/docks/tags/variant_tag.rb +21 -0
  131. data/lib/docks/tags/variation_tag.rb +136 -0
  132. data/lib/docks/tags.rb +103 -0
  133. data/lib/docks/templates.rb +122 -0
  134. data/lib/docks/themes.rb +19 -0
  135. data/lib/docks/types.rb +26 -0
  136. data/lib/docks/version.rb +3 -0
  137. data/lib/docks.rb +37 -0
  138. data/spec/fixtures/build/scripts/bar/bar_2.js +1 -0
  139. data/spec/fixtures/build/scripts/bar.js +1 -0
  140. data/spec/fixtures/build/styles/foo/foo-2.css +1 -0
  141. data/spec/fixtures/build/styles/foo.css +1 -0
  142. data/spec/fixtures/build/templates/baz/baz_2.erb +1 -0
  143. data/spec/fixtures/build/templates/baz.erb +1 -0
  144. data/spec/fixtures/grouper/components/button/button.coffee +0 -0
  145. data/spec/fixtures/grouper/components/button/button.haml +0 -0
  146. data/spec/fixtures/grouper/components/button/button.scss +0 -0
  147. data/spec/fixtures/grouper/components/checkbox/_checkbox.haml +0 -0
  148. data/spec/fixtures/grouper/components/checkbox/_checkbox.scss +0 -0
  149. data/spec/fixtures/grouper/components/checkbox/checkbox.coffee +0 -0
  150. data/spec/fixtures/grouper/components/form/form.coffee +0 -0
  151. data/spec/fixtures/grouper/components/form/form.m +0 -0
  152. data/spec/fixtures/grouper/components/form/form.scss +0 -0
  153. data/spec/fixtures/grouper/components/next-expanding-textarea/_next-expanding-textarea.scss +0 -0
  154. data/spec/fixtures/grouper/components/next-expanding-textarea/_next_expanding_textarea.coffee +0 -0
  155. data/spec/fixtures/grouper/components/next-expanding-textarea/next-expanding-textarea.haml +0 -0
  156. data/spec/fixtures/grouper/components/next-tab/next-tab.coffee +0 -0
  157. data/spec/fixtures/grouper/components/next-tab/next-tab.haml +0 -0
  158. data/spec/fixtures/grouper/components/next-tab/next-tab.scss +0 -0
  159. data/spec/fixtures/grouper/components/segmented control/segmented control.coffee +0 -0
  160. data/spec/fixtures/grouper/components/segmented control/segmented control.haml +0 -0
  161. data/spec/fixtures/grouper/components/segmented control/segmented control.min.html +0 -0
  162. data/spec/fixtures/grouper/components/segmented control/segmented control.scss +0 -0
  163. data/spec/fixtures/grouper/markup/list-view.haml +0 -0
  164. data/spec/fixtures/grouper/markup/resizable/resizable.haml +0 -0
  165. data/spec/fixtures/grouper/markup/toggle.haml +0 -0
  166. data/spec/fixtures/grouper/scripts/resizable/resizable.coffee +0 -0
  167. data/spec/fixtures/grouper/scripts/toggle.coffee +0 -0
  168. data/spec/fixtures/grouper/style/_list-view.scss +0 -0
  169. data/spec/fixtures/grouper/style/_toggle.scss +0 -0
  170. data/spec/fixtures/languages/stub.json +3 -0
  171. data/spec/fixtures/languages/stub.yml +2 -0
  172. data/spec/fixtures/parsers/coffeescript_parser_fixture_basic.coffee +20 -0
  173. data/spec/fixtures/parsers/coffeescript_parser_fixture_complex.coffee +80 -0
  174. data/spec/fixtures/parsers/css_parser_fixture_basic.css +44 -0
  175. data/spec/fixtures/parsers/css_parser_fixture_complex.css +120 -0
  176. data/spec/fixtures/parsers/javascript_parser_fixture_basic.js +27 -0
  177. data/spec/fixtures/parsers/javascript_parser_fixture_complex.js +85 -0
  178. data/spec/fixtures/parsers/sass_parser_fixture_basic.scss +39 -0
  179. data/spec/fixtures/parsers/sass_parser_fixture_complex.scss +149 -0
  180. data/spec/fixtures/parsers/stylus_parser_fixture_basic.styl +34 -0
  181. data/spec/fixtures/parsers/stylus_parser_fixture_complex.styl +113 -0
  182. data/spec/fixtures/processors/join_with_smart_line_breaks/code_blocks.txt +10 -0
  183. data/spec/fixtures/processors/join_with_smart_line_breaks/headings.txt +15 -0
  184. data/spec/fixtures/processors/join_with_smart_line_breaks/lists.txt +21 -0
  185. data/spec/fixtures/processors/join_with_smart_line_breaks/lists_with_nesting.txt +13 -0
  186. data/spec/fixtures/processors/join_with_smart_line_breaks/multiple_paragraphs.txt +11 -0
  187. data/spec/fixtures/renderers/helpers.rb +37 -0
  188. data/spec/fixtures/renderers/html_output.html +7 -0
  189. data/spec/fixtures/renderers/templates/layouts/application.html.erb +0 -0
  190. data/spec/fixtures/renderers/templates/layouts/more/subdirectory.html.erb +0 -0
  191. data/spec/fixtures/renderers/templates/partials/_leading_underscore.html.erb +1 -0
  192. data/spec/fixtures/renderers/templates/partials/more/_subdirectory.html.erb +1 -0
  193. data/spec/fixtures/renderers/templates/partials/partial.html.erb +0 -0
  194. data/spec/fixtures/renderers/templates/partials/template.html.erb +1 -0
  195. data/spec/fixtures/renderers/templates/template.html.erb +1 -0
  196. data/spec/fixtures/tags/description/button.md +24 -0
  197. data/spec/fixtures/tags/description/class.md +27 -0
  198. data/spec/fixtures/tags/description/component.md +23 -0
  199. data/spec/fixtures/tags/description/function.md +30 -0
  200. data/spec/lib/build_spec.rb +467 -0
  201. data/spec/lib/cache_spec.rb +175 -0
  202. data/spec/lib/command_line_spec.rb +77 -0
  203. data/spec/lib/configuration_spec.rb +180 -0
  204. data/spec/lib/containers/base_container_spec.rb +214 -0
  205. data/spec/lib/containers/class_container_spec.rb +209 -0
  206. data/spec/lib/containers/component_container_spec.rb +158 -0
  207. data/spec/lib/containers/demo_container_spec.rb +113 -0
  208. data/spec/lib/containers/function_container_spec.rb +116 -0
  209. data/spec/lib/containers/mixin_container_spec.rb +4 -0
  210. data/spec/lib/containers/pattern_container_spec.rb +291 -0
  211. data/spec/lib/containers/pattern_library_container_spec.rb +130 -0
  212. data/spec/lib/containers/symbol_container_spec.rb +216 -0
  213. data/spec/lib/containers/variable_container_spec.rb +116 -0
  214. data/spec/lib/containers/variation_container_spec.rb +52 -0
  215. data/spec/lib/containers_spec.rb +22 -0
  216. data/spec/lib/descriptor_spec.rb +73 -0
  217. data/spec/lib/group_spec.rb +151 -0
  218. data/spec/lib/helpers/path_helper_spec.rb +202 -0
  219. data/spec/lib/helpers/render_helper_spec.rb +159 -0
  220. data/spec/lib/helpers_spec.rb +35 -0
  221. data/spec/lib/languages/base_language_spec.rb +32 -0
  222. data/spec/lib/languages/coffeescript_language_spec.rb +52 -0
  223. data/spec/lib/languages/css_language_spec.rb +13 -0
  224. data/spec/lib/languages/erb_language_spec.rb +33 -0
  225. data/spec/lib/languages/haml_language_spec.rb +32 -0
  226. data/spec/lib/languages/javascript_language_spec.rb +54 -0
  227. data/spec/lib/languages/json_language_spec.rb +24 -0
  228. data/spec/lib/languages/less_language_spec.rb +39 -0
  229. data/spec/lib/languages/markup_language_spec.rb +95 -0
  230. data/spec/lib/languages/sass_language_spec.rb +53 -0
  231. data/spec/lib/languages/slim_language_spec.rb +32 -0
  232. data/spec/lib/languages/stylus_language_spec.rb +34 -0
  233. data/spec/lib/languages/yaml_language_spec.rb +24 -0
  234. data/spec/lib/languages_spec.rb +127 -0
  235. data/spec/lib/markdown_spec.rb +63 -0
  236. data/spec/lib/messenger_spec.rb +1 -0
  237. data/spec/lib/naming_conventions/bem_naming_convention_spec.rb +112 -0
  238. data/spec/lib/naming_conventions/suit_naming_convention_spec.rb +107 -0
  239. data/spec/lib/naming_conventions_spec.rb +28 -0
  240. data/spec/lib/ostruct_spec.rb +15 -0
  241. data/spec/lib/parser_spec.rb +93 -0
  242. data/spec/lib/parsers/base_parser_spec.rb +128 -0
  243. data/spec/lib/parsers/coffeescript_parser_spec.rb +184 -0
  244. data/spec/lib/parsers/css_parser_spec.rb +136 -0
  245. data/spec/lib/parsers/javascript_parser_spec.rb +216 -0
  246. data/spec/lib/parsers/less_parser_spec.rb +111 -0
  247. data/spec/lib/parsers/sass_parser_spec.rb +233 -0
  248. data/spec/lib/parsers/stylus_parser_spec.rb +212 -0
  249. data/spec/lib/process_spec.rb +96 -0
  250. data/spec/lib/processors_spec.rb +555 -0
  251. data/spec/lib/renderers/base_renderer_spec.rb +122 -0
  252. data/spec/lib/renderers/common_features/helperable_spec.rb +30 -0
  253. data/spec/lib/renderers/erb_renderer_spec.rb +119 -0
  254. data/spec/lib/renderers/haml_renderer_spec.rb +103 -0
  255. data/spec/lib/renderers/slim_renderer_spec.rb +103 -0
  256. data/spec/lib/symbol_sources/jquery_symbol_source_spec.rb +25 -0
  257. data/spec/lib/symbol_sources/mdn_symbol_source_spec.rb +40 -0
  258. data/spec/lib/symbol_sources/sass_symbol_source_spec.rb +39 -0
  259. data/spec/lib/symbol_sources_spec.rb +19 -0
  260. data/spec/lib/tags/access_tag_spec.rb +32 -0
  261. data/spec/lib/tags/activate_with_tag_spec.rb +31 -0
  262. data/spec/lib/tags/active_tag_spec.rb +24 -0
  263. data/spec/lib/tags/alias_tag_spec.rb +31 -0
  264. data/spec/lib/tags/author_tag_spec.rb +172 -0
  265. data/spec/lib/tags/base_tag_spec.rb +21 -0
  266. data/spec/lib/tags/beta_tag_spec.rb +52 -0
  267. data/spec/lib/tags/class_tag_spec.rb +29 -0
  268. data/spec/lib/tags/compatibility_tag_spec.rb +159 -0
  269. data/spec/lib/tags/demo_type_tag_spec.rb +24 -0
  270. data/spec/lib/tags/deprecated_tag_spec.rb +50 -0
  271. data/spec/lib/tags/description_tag_spec.rb +242 -0
  272. data/spec/lib/tags/example_tag_spec.rb +37 -0
  273. data/spec/lib/tags/factory_tag_spec.rb +29 -0
  274. data/spec/lib/tags/for_tag_spec.rb +45 -0
  275. data/spec/lib/tags/group_tag_spec.rb +20 -0
  276. data/spec/lib/tags/helper_tag_spec.rb +22 -0
  277. data/spec/lib/tags/include_with_tag_spec.rb +74 -0
  278. data/spec/lib/tags/javascript_action_tag_spec.rb +20 -0
  279. data/spec/lib/tags/link_tag_spec.rb +49 -0
  280. data/spec/lib/tags/markup_tag_spec.rb +255 -0
  281. data/spec/lib/tags/member_tag_spec.rb +167 -0
  282. data/spec/lib/tags/method_tag_spec.rb +27 -0
  283. data/spec/lib/tags/name_tag_spec.rb +20 -0
  284. data/spec/lib/tags/object_tag_spec.rb +24 -0
  285. data/spec/lib/tags/param_tag_spec.rb +261 -0
  286. data/spec/lib/tags/pattern_tag_spec.rb +49 -0
  287. data/spec/lib/tags/preclude_tag_spec.rb +31 -0
  288. data/spec/lib/tags/private_tag_spec.rb +31 -0
  289. data/spec/lib/tags/property_tag_spec.rb +27 -0
  290. data/spec/lib/tags/public_tag_spec.rb +29 -0
  291. data/spec/lib/tags/require_tag_spec.rb +133 -0
  292. data/spec/lib/tags/returns_tag_spec.rb +85 -0
  293. data/spec/lib/tags/set_by_tag_spec.rb +92 -0
  294. data/spec/lib/tags/signature_tag_spec.rb +125 -0
  295. data/spec/lib/tags/since_tag_spec.rb +48 -0
  296. data/spec/lib/tags/state_tag_spec.rb +199 -0
  297. data/spec/lib/tags/static_tag_spec.rb +27 -0
  298. data/spec/lib/tags/subcomponent_tag_spec.rb +78 -0
  299. data/spec/lib/tags/subtitle_tag_spec.rb +13 -0
  300. data/spec/lib/tags/symbol_type_tag_spec.rb +20 -0
  301. data/spec/lib/tags/throws_tag_spec.rb +49 -0
  302. data/spec/lib/tags/title_tag_spec.rb +20 -0
  303. data/spec/lib/tags/type_tag_spec.rb +20 -0
  304. data/spec/lib/tags/value_tag_spec.rb +20 -0
  305. data/spec/lib/tags/variant_tag_spec.rb +13 -0
  306. data/spec/lib/tags/variation_tag_spec.rb +154 -0
  307. data/spec/lib/tags_spec.rb +264 -0
  308. data/spec/lib/templates_spec.rb +185 -0
  309. data/spec/lib/themes_spec.rb +32 -0
  310. data/spec/spec_helper.rb +34 -0
  311. data/tasks/rspec.rake +7 -0
  312. data/tasks/rubocop.rake +8 -0
  313. metadata +740 -0
@@ -0,0 +1,242 @@
1
+ require "spec_helper"
2
+
3
+ describe Docks::Tags::Description do
4
+ subject { Docks::Tags::Description.instance }
5
+
6
+ it "allows multiline content" do
7
+ expect(subject.multiline?).to be true
8
+ end
9
+
10
+ it "only allows one description per block" do
11
+ expect(subject.multiple_allowed?).to be false
12
+ end
13
+
14
+ describe "#process" do
15
+ it "connects multiline content with smart line breaks" do
16
+ description = ["foo", "bar"]
17
+ symbol = Docks::Containers::Symbol.new(description: description.dup)
18
+ expect(subject.process(symbol).description).to eq Docks::Processors.join_with_smart_line_breaks(description)
19
+ end
20
+ end
21
+
22
+ describe "post process" do
23
+ before(:each) do
24
+ Docks::Languages.register_bundled_languages
25
+ end
26
+
27
+ describe "associating external description files" do
28
+ let(:name) { "button" }
29
+ let(:pattern) { Docks::Containers::Pattern.new(name: name) }
30
+ let(:component) { Docks::Containers::Component.new(name: name) }
31
+ let(:second_component) { Docks::Containers::Component.new(name: "segmented-button") }
32
+
33
+ before(:each) do
34
+ allow_any_instance_of(Redcarpet::Markdown).to receive(:render) { |renderer, code| code }
35
+ end
36
+
37
+ context "when there is only a pattern symbol" do
38
+ let(:description_file) { "pattern-lab/descriptions/_#{name}.md" }
39
+ let(:description) { "Foo\n\nBar." }
40
+
41
+ before(:each) { pattern.files = [description_file] }
42
+
43
+ it "associates a description file matching a pattern with the description for that pattern" do
44
+ expect(File).to receive(:read).with(description_file).and_return description
45
+ process_pattern
46
+ expect(pattern.description).to eq description
47
+ end
48
+
49
+ it "does not associate a description file when the pattern already has a description" do
50
+ pattern.description = "foo"
51
+ expect(File).to receive(:read).with(description_file).and_return description
52
+ expect { process_pattern }.not_to change { pattern }
53
+ end
54
+ end
55
+
56
+ context "when there are other symbols" do
57
+ let(:description_file) { File.expand_path("../../../fixtures/tags/description/button.md", __FILE__) }
58
+ let(:description_file_contents) { File.read(description_file) }
59
+
60
+ before(:each) do
61
+ pattern.add(:style, [component, second_component])
62
+ pattern.files = [description_file]
63
+ end
64
+
65
+ it "associates the description with components based on headings and removes these from the pattern's description" do
66
+ process_pattern
67
+ expect(component.description).to eq Regexp.new("^# #{component.name}\\n(.*?)^# ", Regexp::MULTILINE).match(description_file_contents).captures.first.strip
68
+ expect(second_component.description).to eq Regexp.new("^## #{second_component.name}\\n(.*)", Regexp::MULTILINE).match(description_file_contents).captures.first.strip
69
+ expect(pattern.description).to eq description_file_contents.sub(/#.*/m, "").strip
70
+ end
71
+
72
+ it "doesn't associate a description with a component with no matching heading" do
73
+ component.name = "foo"
74
+ process_pattern
75
+ expect(component.description).to be nil
76
+ end
77
+
78
+ it "doesn't blow up when there is no pattern to take the rest of the description" do
79
+ expect { process_pattern }.not_to raise_error
80
+ expect(component.description).to eq Regexp.new("^# #{component.name}\\n(.*?)^# ", Regexp::MULTILINE).match(description_file_contents).captures.first.strip
81
+ end
82
+ end
83
+
84
+ context "when there are components" do
85
+ let(:description_file) { File.expand_path("../../../fixtures/tags/description/component.md", __FILE__) }
86
+ let(:description_file_contents) { File.read(description_file) }
87
+
88
+ before(:each) do
89
+ pattern.files = [description_file]
90
+ pattern.add(:style, component)
91
+ end
92
+
93
+ let(:state) { Docks::Containers::State.new(name: "#{name}--is-active") }
94
+ let(:variant) { Docks::Containers::State.new(name: "#{name}--large") }
95
+
96
+ it "does the description association for states" do
97
+ component.states << state
98
+ process_pattern
99
+
100
+ expect(state.description).to eq Regexp.new("^## #{state.name}\\n(.*?)^## ", Regexp::MULTILINE).match(description_file_contents).captures.first.strip
101
+ expect(component.description).to eq description_file_contents.sub(/[^#]*#.*/, "").sub(/##.*/m, "").strip
102
+ end
103
+
104
+ it "does the description association for variants" do
105
+ component.variants << variant
106
+ process_pattern
107
+
108
+ expect(variant.description).to eq Regexp.new("^## #{variant.name}\\n(.*?)^# ", Regexp::MULTILINE).match(description_file_contents).captures.first.strip
109
+ expect(component.description).to eq description_file_contents.sub(/[^#]*#.*/, "").sub(Regexp.new("## #{variant.name}.*", Regexp::MULTILINE), "").strip
110
+ end
111
+
112
+ it "doesn't do a description association for a state with an existing description" do
113
+ state.description = "foo"
114
+ component.states << state
115
+ process_pattern
116
+
117
+ expect(state.description).to eq "foo"
118
+ expect(component.description).to eq description_file_contents.sub(/.*?^# [^\n]*\n\n/m, "").sub(/^# .*/m, "").strip
119
+ end
120
+ end
121
+
122
+ context "when there are classes and factories" do
123
+ let(:description_file) { File.expand_path("../../../fixtures/tags/description/class.md", __FILE__) }
124
+ let(:description_file_contents) { File.read(description_file) }
125
+
126
+ let(:method) { Docks::Containers::Function.new(name: "toggle") }
127
+ let(:property) { Docks::Containers::Variable.new(name: "is_active") }
128
+ let(:klass) do
129
+ klass = Docks::Containers::Klass.new(name: name.capitalize)
130
+ klass.add_members(method, property)
131
+ klass
132
+ end
133
+
134
+ before(:each) do
135
+ pattern.files = [description_file]
136
+ pattern.add(:script, klass)
137
+ end
138
+
139
+ it "does the description association for methods" do
140
+ process_pattern
141
+
142
+ expect(method.description).to eq Regexp.new("^## #{method.name}\\n(.*?)^# ", Regexp::MULTILINE).match(description_file_contents).captures.first.strip
143
+ expect(klass.description).to eq description_file_contents.sub(/[^#]*#[^#]*#.*?$/m, "").sub(/##.*/m, "").strip
144
+ end
145
+
146
+ it "does the description association for properties" do
147
+ process_pattern
148
+
149
+ expect(property.description).to eq Regexp.new("^## #{property.name}\\n(.*?)^## ", Regexp::MULTILINE).match(description_file_contents).captures.first.strip
150
+ expect(klass.description).to eq description_file_contents.sub(/[^#]*#[^#]*#.*?$/m, "").sub(Regexp.new("## #{property.name}.*", Regexp::MULTILINE), "").strip
151
+ end
152
+
153
+ it "doesn't do a description association for a method with an existing description" do
154
+ method.description = "foo"
155
+ process_pattern
156
+
157
+ expect(method.description).to eq "foo"
158
+ expect(klass.description).to eq description_file_contents.sub(/(.*?^# [^\n]*\n\n){2}/m, "").sub(/^## .*/m, "").strip
159
+ end
160
+ end
161
+
162
+ context "when there are functions" do
163
+ let(:description_file) { File.expand_path("../../../fixtures/tags/description/function.md", __FILE__) }
164
+ let(:description_file_contents) { File.read(description_file) }
165
+
166
+ let(:param) { OpenStruct.new(name: "options") }
167
+ let(:function) { Docks::Containers::Function.new(name: "toggle", params: [param]) }
168
+
169
+ before(:each) do
170
+ pattern.files = [description_file]
171
+ pattern.add(:script, function)
172
+ end
173
+
174
+ it "does the description association for parameters" do
175
+ process_pattern
176
+
177
+ expect(param.description).to eq Regexp.new("^### #{param.name}\\n(.*?)^# ", Regexp::MULTILINE).match(description_file_contents).captures.first.strip
178
+ expect(function.description).to eq description_file_contents.sub(/(.*?^## [^\n]*\n\n){2}/m, "").sub(/^### .*/m, "").strip
179
+ end
180
+
181
+ it "doesn't do a description association for a parameter with an existing description" do
182
+ param.description = "foo"
183
+ process_pattern
184
+
185
+ expect(param.description).to eq "foo"
186
+ expect(function.description).to eq description_file_contents.sub(/(.*?^## [^\n]*\n\n){2}/m, "").sub(/^# .*/m, "").strip
187
+ end
188
+ end
189
+
190
+ private
191
+
192
+ def process_pattern
193
+ Docks::Process.process(pattern)
194
+ end
195
+ end
196
+
197
+ describe "rendering markdown descriptions" do
198
+ let(:param) { OpenStruct.new(name: "options", description: nil) }
199
+ let(:method) { Docks::Containers::Function.new(name: "toggle", static: true, params: [param]) }
200
+ let(:factory) { Docks::Containers::Factory.new(name: "Foo", methods: [method]) }
201
+ let(:pattern) do
202
+ pattern = Docks::Containers::Pattern.new(name: "foo")
203
+ pattern.add(:script, factory)
204
+ pattern
205
+ end
206
+
207
+ it "uses the custom markdown renderer" do
208
+ expect(subject.instance_variable_get(:@markdown).renderer).to be_an_instance_of Docks::Markdown::Renderer
209
+ end
210
+
211
+ it "nils out empty, all-whitespace, and nil descriptions" do
212
+ param.description = " \n "
213
+ method.description = ""
214
+ factory.description = " "
215
+ process_pattern
216
+
217
+ expect(param.description).to be nil
218
+ expect(method.description).to be nil
219
+ expect(factory.description).to be nil
220
+ expect(pattern.description).to be nil
221
+ end
222
+
223
+ it "calls the markdown renderer recursively for all items that need descriptions" do
224
+ factory_description = "This is a pattern"
225
+ factory.description = factory_description
226
+ param_description = "This is a parameter"
227
+ param.description = param_description
228
+
229
+ expect_any_instance_of(Redcarpet::Markdown).to receive(:render).with(factory_description).and_call_original
230
+ expect_any_instance_of(Redcarpet::Markdown).to receive(:render).with(param_description).and_call_original
231
+
232
+ process_pattern
233
+ end
234
+
235
+ private
236
+
237
+ def process_pattern
238
+ Docks::Process.process(pattern)
239
+ end
240
+ end
241
+ end
242
+ end
@@ -0,0 +1,37 @@
1
+ #TODO: check for leading whitespace when there is no language/ description
2
+
3
+ require "spec_helper"
4
+
5
+ describe Docks::Tags::Example do
6
+ subject { Docks::Tags::Example.instance }
7
+
8
+ it "allows multiline content" do
9
+ expect(subject.multiline?).to be true
10
+ end
11
+
12
+ it "allows multiple tags per block" do
13
+ expect(subject.multiple_allowed?).to be true
14
+ end
15
+
16
+ describe "#process" do
17
+ let(:symbol) { Docks::Containers::Symbol.new }
18
+ let(:code) { "foo = (bar) ->" }
19
+ let(:language) { "coffee" }
20
+
21
+ before(:each) { Docks::Languages.register_bundled_languages }
22
+
23
+ it "calls the code block processor" do
24
+ expect(subject).to receive(:code_block_with_language_and_description).and_call_original
25
+ symbol[subject.name] = [[language, code]]
26
+ subject.process(symbol)
27
+ expect(symbol[subject.name].first).to eq OpenStruct.new(language: language, code: code)
28
+ end
29
+
30
+ it "uses the extension for the current file as the language when none is provided" do
31
+ expect(Docks).to receive(:current_file).and_return "foo_bar.#{language}"
32
+ symbol[subject.name] = [[code]]
33
+ subject.process(symbol)
34
+ expect(symbol[subject.name].first).to eq OpenStruct.new(language: language, code: code)
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,29 @@
1
+ require "spec_helper"
2
+
3
+ describe Docks::Tags::Factory do
4
+ subject { Docks::Tags::Factory.instance }
5
+
6
+ it "does not allow multiline content" do
7
+ expect(subject.multiline?).to be false
8
+ end
9
+
10
+ it "only allows one tag per block" do
11
+ expect(subject.multiple_allowed?).to be false
12
+ end
13
+
14
+ describe "#process" do
15
+ it "marks the attribute as true" do
16
+ symbol = Docks::Containers::Symbol.new(name: "foo", factory: "")
17
+ Docks::Process.process(symbol)
18
+ expect(symbol[subject.name]).to be true
19
+ end
20
+
21
+ it "converts the symbol to be a factory container" do
22
+ symbol = Docks::Containers::Function.new(factory: "", name: "foo")
23
+ symbol = Docks::Process.process(symbol)
24
+
25
+ expect(symbol).to be_a Docks::Containers::Factory
26
+ expect(symbol.symbol_type).to eq Docks::Types::Symbol::FACTORY
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,45 @@
1
+ require "spec_helper"
2
+
3
+ describe Docks::Tags::For do
4
+ subject { Docks::Tags::For.instance }
5
+
6
+ it "does not allow multiline content" do
7
+ expect(subject.multiline?).to be false
8
+ end
9
+
10
+ it "only allows one tag per block" do
11
+ expect(subject.multiple_allowed?).to be false
12
+ end
13
+
14
+ describe "post process" do
15
+ let(:pattern) { Docks::Containers::Pattern.new(name: "foo") }
16
+
17
+ context "when there are components with variations" do
18
+ let(:variant) { Docks::Containers::Variant.new(name: "foo--bar") }
19
+ let(:state) { Docks::Containers::State.new(name: "foo--is-bar") }
20
+ let(:component) { Docks::Containers::Component.new(name: "foo", states: [state], variants: [variant]) }
21
+
22
+ before(:each) { pattern.add(:style, component) }
23
+
24
+ it "adds the component name for states and variants" do
25
+ post_process
26
+
27
+ expect(variant.for).to eq component.name
28
+ expect(state.for).to eq component.name
29
+ end
30
+
31
+ it "adds the for attribute on states and variants in subcomponents" do
32
+ sub_state = Docks::Containers::State.new(name: "foo__bar--is-baz")
33
+ subcomponent = Docks::Containers::Component.new(name: "foo__bar", states: [sub_state])
34
+ component.subcomponents << subcomponent
35
+ post_process
36
+
37
+ expect(sub_state.for).to eq subcomponent.name
38
+ end
39
+ end
40
+
41
+ def post_process
42
+ Docks::Process.process(pattern)
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,20 @@
1
+ require "spec_helper"
2
+
3
+ describe Docks::Tags::Group do
4
+ subject { Docks::Tags::Group.instance }
5
+
6
+ it "does not allow multiline content" do
7
+ expect(subject.multiline?).to be false
8
+ end
9
+
10
+ it "only allows one tag per block" do
11
+ expect(subject.multiple_allowed?).to be false
12
+ end
13
+
14
+ describe "#process" do
15
+ it "does not perform any processing" do
16
+ content = "foo"
17
+ expect(subject.process(content)).to eq content
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,22 @@
1
+ require "spec_helper"
2
+
3
+ describe Docks::Tags::Helper do
4
+ subject { Docks::Tags::Helper.instance }
5
+
6
+ it "allows multiline content" do
7
+ expect(subject.multiline?).to be true
8
+ end
9
+
10
+ it "only allows one description per block" do
11
+ expect(subject.multiple_allowed?).to be false
12
+ end
13
+
14
+ describe "#process" do
15
+ it "connects multiline content with line breaks" do
16
+ helper = ["foo", "bar"]
17
+ symbol = Docks::Containers::Symbol.new(helper: helper.dup)
18
+ subject.process(symbol)
19
+ expect(symbol[subject.name]).to eq helper.join("\n")
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,74 @@
1
+ require "spec_helper"
2
+
3
+ describe Docks::Tags::IncludeWith do
4
+ subject { Docks::Tags::IncludeWith.instance }
5
+
6
+ it "does not allow multiline content" do
7
+ expect(subject.multiline?).to be false
8
+ end
9
+
10
+ it "allows multiple tags per block" do
11
+ expect(subject.multiple_allowed?).to be true
12
+ end
13
+
14
+ describe "#process" do
15
+ let(:symbol) { Docks::Containers::Symbol.new }
16
+
17
+ it "breaks apart include_with on commas, spaces and pipes" do
18
+ include_with = "foo | bar, baz qux"
19
+ symbol[subject.name] = include_with
20
+ subject.process(symbol)
21
+ expect(symbol[subject.name]).to eq Docks::Processors.split_on_commas_spaces_and_pipes(include_with)
22
+ end
23
+
24
+ it "joins together multiple lines of include_with" do
25
+ include_with = ["foo | bar, baz qux", "lux fuz"]
26
+ symbol[subject.name] = include_with.dup
27
+ subject.process(symbol)
28
+ expect(symbol[subject.name]).to eq include_with.map { |with| Docks::Processors.split_on_commas_spaces_and_pipes(with) }.flatten
29
+ end
30
+ end
31
+
32
+ describe "post_process" do
33
+ describe "mirror the inclusion in the referenced symbol" do
34
+ let(:component) { Docks::Containers::Component.new(name: "foo") }
35
+ let(:included_component) { Docks::Containers::Component.new(name: "bar", include_with: [component.name]) }
36
+ let(:included_variation) { Docks::Containers::State.new(name: "baz--qux", include_with: [component.name]) }
37
+ let(:containing_component) { Docks::Containers::Component.new(name: "bar", states: [included_variation]) }
38
+ let(:pattern) { Docks::Containers::Pattern.new(name: "foo") }
39
+
40
+ it "joins included components" do
41
+ pattern.add(:style, [component, included_component])
42
+ post_process
43
+
44
+ expect(component.included_symbols).to be_an Array
45
+ expect(component.included_symbols.length).to be 1
46
+ expect(component.included_symbols).to include included_component
47
+ end
48
+
49
+ it "joins included variations" do
50
+ pattern.add(:style, [component, containing_component])
51
+ post_process
52
+
53
+ expect(component.included_symbols).to be_an Array
54
+ expect(component.included_symbols.length).to be 1
55
+ expect(component.included_symbols).to include included_variation
56
+ end
57
+
58
+ it "joins included subcomponents" do
59
+ other_component = Docks::Containers::Component.new(name: "fizz", subcomponents: [containing_component, included_component])
60
+ pattern.add(:style, [component, other_component])
61
+ post_process
62
+
63
+ expect(component.included_symbols).to be_an Array
64
+ expect(component.included_symbols.length).to be 2
65
+ expect(component.included_symbols).to include included_component
66
+ expect(component.included_symbols).to include included_variation
67
+ end
68
+
69
+ def post_process
70
+ Docks::Process.process(pattern)
71
+ end
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,20 @@
1
+ require "spec_helper"
2
+
3
+ describe Docks::Tags::JavascriptAction do
4
+ subject { Docks::Tags::JavascriptAction.instance }
5
+
6
+ it "does not allow multiline content" do
7
+ expect(subject.multiline?).to be false
8
+ end
9
+
10
+ it "only allows one tag per block" do
11
+ expect(subject.multiple_allowed?).to be false
12
+ end
13
+
14
+ describe "#process" do
15
+ it "does not perform any processing" do
16
+ content = "foo"
17
+ expect(subject.process(content)).to eq content
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,49 @@
1
+ require "spec_helper"
2
+
3
+ describe Docks::Tags::Link do
4
+ subject { Docks::Tags::Link.instance }
5
+
6
+ it "does not allow multiline content" do
7
+ expect(subject.multiline?).to be false
8
+ end
9
+
10
+ it "allows multiple tags per block" do
11
+ expect(subject.multiple_allowed?).to be true
12
+ end
13
+
14
+ describe "#process" do
15
+ let(:symbol) { Docks::Containers::Symbol.new }
16
+ let(:simple_content) { "http://apple.com" }
17
+ let(:caption) { "chrismsauve@gmail.com" }
18
+ let(:complex_content) { "#{simple_content} (#{caption})" }
19
+
20
+ it "creates a :url when there are no other details" do
21
+ expect(process_link_with(simple_content).first.url).to eq simple_content
22
+ end
23
+
24
+ it "creates a :url when there are other details" do
25
+ expect(process_link_with(complex_content).first.url).to eq simple_content
26
+ end
27
+
28
+ it "does not create a :caption when no parentheses are provided" do
29
+ expect(process_link_with(simple_content).first.caption).to be nil
30
+ end
31
+
32
+ it "creates a :caption when one is provided without a key" do
33
+ expect(process_link_with(complex_content).first.caption).to eq caption
34
+ end
35
+
36
+ it "creates a :caption when the key is provided" do
37
+ complex_content.sub!("(", "(caption: ")
38
+ expect(process_link_with(complex_content).first.caption).to eq caption
39
+ end
40
+
41
+ private
42
+
43
+ def process_link_with(content)
44
+ symbol[subject.name] = content
45
+ subject.process(symbol)
46
+ symbol[subject.name]
47
+ end
48
+ end
49
+ end