docks_app 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.editorconfig +8 -0
- data/.gitignore +22 -0
- data/.rubocop.yml +20 -0
- data/.travis.yml +10 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +35 -0
- data/Rakefile +3 -0
- data/bin/docks +5 -0
- data/config/json/docks_config.json +71 -0
- data/config/ruby/docks_config.rb +127 -0
- data/config/yaml/docks_config.yml +70 -0
- data/docks.gemspec +38 -0
- data/lib/docks/build.rb +300 -0
- data/lib/docks/cache.rb +143 -0
- data/lib/docks/command_line.rb +65 -0
- data/lib/docks/configuration.rb +217 -0
- data/lib/docks/containers/base_container.rb +103 -0
- data/lib/docks/containers/class_container.rb +39 -0
- data/lib/docks/containers/component_container.rb +92 -0
- data/lib/docks/containers/demo_container.rb +105 -0
- data/lib/docks/containers/factory_container.rb +12 -0
- data/lib/docks/containers/function_container.rb +46 -0
- data/lib/docks/containers/mixin_container.rb +19 -0
- data/lib/docks/containers/pattern_container.rb +168 -0
- data/lib/docks/containers/pattern_library_container.rb +77 -0
- data/lib/docks/containers/state_container.rb +9 -0
- data/lib/docks/containers/symbol_container.rb +77 -0
- data/lib/docks/containers/variable_container.rb +47 -0
- data/lib/docks/containers/variant_container.rb +9 -0
- data/lib/docks/containers/variation_container.rb +38 -0
- data/lib/docks/containers.rb +25 -0
- data/lib/docks/descriptor.rb +60 -0
- data/lib/docks/errors.rb +5 -0
- data/lib/docks/group.rb +66 -0
- data/lib/docks/helpers/github_helper.rb +29 -0
- data/lib/docks/helpers/path_helper.rb +94 -0
- data/lib/docks/helpers/render_helper.rb +87 -0
- data/lib/docks/helpers.rb +19 -0
- data/lib/docks/languages/base_language.rb +17 -0
- data/lib/docks/languages/coffeescript_language.rb +30 -0
- data/lib/docks/languages/common_types/markup_language.rb +71 -0
- data/lib/docks/languages/css_language.rb +13 -0
- data/lib/docks/languages/erb_language.rb +21 -0
- data/lib/docks/languages/haml_language.rb +21 -0
- data/lib/docks/languages/html_language.rb +10 -0
- data/lib/docks/languages/javascript_language.rb +42 -0
- data/lib/docks/languages/json_language.rb +18 -0
- data/lib/docks/languages/less_language.rb +33 -0
- data/lib/docks/languages/markdown_language.rb +10 -0
- data/lib/docks/languages/sass_language.rb +36 -0
- data/lib/docks/languages/slim_language.rb +21 -0
- data/lib/docks/languages/stylus_language.rb +26 -0
- data/lib/docks/languages/yaml_language.rb +18 -0
- data/lib/docks/languages.rb +103 -0
- data/lib/docks/markdown.rb +18 -0
- data/lib/docks/messenger.rb +69 -0
- data/lib/docks/naming_conventions/base_naming_convention.rb +9 -0
- data/lib/docks/naming_conventions/bem_naming_convention.rb +45 -0
- data/lib/docks/naming_conventions/suit_naming_convention.rb +45 -0
- data/lib/docks/naming_conventions.rb +21 -0
- data/lib/docks/ostruct.rb +17 -0
- data/lib/docks/parser.rb +86 -0
- data/lib/docks/parsers/base_parser.rb +128 -0
- data/lib/docks/parsers/coffeescript_parser.rb +30 -0
- data/lib/docks/parsers/css_parser.rb +27 -0
- data/lib/docks/parsers/javascript_parser.rb +30 -0
- data/lib/docks/parsers/less_parser.rb +22 -0
- data/lib/docks/parsers/sass_parser.rb +31 -0
- data/lib/docks/parsers/stylus_parser.rb +28 -0
- data/lib/docks/process.rb +60 -0
- data/lib/docks/processors.rb +416 -0
- data/lib/docks/renderers/base_renderer.rb +64 -0
- data/lib/docks/renderers/common_features/capturable.rb +69 -0
- data/lib/docks/renderers/common_features/helperable.rb +23 -0
- data/lib/docks/renderers/erb_renderer.rb +68 -0
- data/lib/docks/renderers/haml_renderer.rb +37 -0
- data/lib/docks/renderers/slim_renderer.rb +33 -0
- data/lib/docks/symbol_sources/base_symbol_source.rb +12 -0
- data/lib/docks/symbol_sources/jquery_symbol_source.rb +17 -0
- data/lib/docks/symbol_sources/mdn_symbol_source.rb +35 -0
- data/lib/docks/symbol_sources/sass_symbol_source.rb +27 -0
- data/lib/docks/symbol_sources.rb +28 -0
- data/lib/docks/tags/access_tag.rb +27 -0
- data/lib/docks/tags/activate_with_tag.rb +17 -0
- data/lib/docks/tags/active_tag.rb +14 -0
- data/lib/docks/tags/alias_tag.rb +17 -0
- data/lib/docks/tags/author_tag.rb +19 -0
- data/lib/docks/tags/base_tag.rb +52 -0
- data/lib/docks/tags/beta_tag.rb +26 -0
- data/lib/docks/tags/class_tag.rb +16 -0
- data/lib/docks/tags/compatibility_tag.rb +19 -0
- data/lib/docks/tags/demo_type_tag.rb +14 -0
- data/lib/docks/tags/deprecated_tag.rb +26 -0
- data/lib/docks/tags/description_tag.rb +99 -0
- data/lib/docks/tags/example_tag.rb +20 -0
- data/lib/docks/tags/factory_tag.rb +16 -0
- data/lib/docks/tags/for_tag.rb +23 -0
- data/lib/docks/tags/group_tag.rb +10 -0
- data/lib/docks/tags/helper_tag.rb +13 -0
- data/lib/docks/tags/include_with_tag.rb +57 -0
- data/lib/docks/tags/javascript_action_tag.rb +10 -0
- data/lib/docks/tags/link_tag.rb +18 -0
- data/lib/docks/tags/markup_tag.rb +106 -0
- data/lib/docks/tags/member_tag.rb +37 -0
- data/lib/docks/tags/method_tag.rb +18 -0
- data/lib/docks/tags/name_tag.rb +10 -0
- data/lib/docks/tags/object_tag.rb +15 -0
- data/lib/docks/tags/param_tag.rb +94 -0
- data/lib/docks/tags/pattern_tag.rb +21 -0
- data/lib/docks/tags/preclude_tag.rb +17 -0
- data/lib/docks/tags/private_tag.rb +15 -0
- data/lib/docks/tags/property_tag.rb +18 -0
- data/lib/docks/tags/public_tag.rb +15 -0
- data/lib/docks/tags/require_tag.rb +47 -0
- data/lib/docks/tags/returns_tag.rb +31 -0
- data/lib/docks/tags/set_by_tag.rb +18 -0
- data/lib/docks/tags/signature_tag.rb +35 -0
- data/lib/docks/tags/since_tag.rb +26 -0
- data/lib/docks/tags/source_tag.rb +12 -0
- data/lib/docks/tags/state_tag.rb +21 -0
- data/lib/docks/tags/static_tag.rb +14 -0
- data/lib/docks/tags/subcomponent_tag.rb +68 -0
- data/lib/docks/tags/subtitle_tag.rb +11 -0
- data/lib/docks/tags/symbol_type_tag.rb +10 -0
- data/lib/docks/tags/throws_tag.rb +30 -0
- data/lib/docks/tags/title_tag.rb +10 -0
- data/lib/docks/tags/type_tag.rb +10 -0
- data/lib/docks/tags/value_tag.rb +10 -0
- data/lib/docks/tags/variant_tag.rb +21 -0
- data/lib/docks/tags/variation_tag.rb +136 -0
- data/lib/docks/tags.rb +103 -0
- data/lib/docks/templates.rb +122 -0
- data/lib/docks/themes.rb +19 -0
- data/lib/docks/types.rb +26 -0
- data/lib/docks/version.rb +3 -0
- data/lib/docks.rb +37 -0
- data/spec/fixtures/build/scripts/bar/bar_2.js +1 -0
- data/spec/fixtures/build/scripts/bar.js +1 -0
- data/spec/fixtures/build/styles/foo/foo-2.css +1 -0
- data/spec/fixtures/build/styles/foo.css +1 -0
- data/spec/fixtures/build/templates/baz/baz_2.erb +1 -0
- data/spec/fixtures/build/templates/baz.erb +1 -0
- data/spec/fixtures/grouper/components/button/button.coffee +0 -0
- data/spec/fixtures/grouper/components/button/button.haml +0 -0
- data/spec/fixtures/grouper/components/button/button.scss +0 -0
- data/spec/fixtures/grouper/components/checkbox/_checkbox.haml +0 -0
- data/spec/fixtures/grouper/components/checkbox/_checkbox.scss +0 -0
- data/spec/fixtures/grouper/components/checkbox/checkbox.coffee +0 -0
- data/spec/fixtures/grouper/components/form/form.coffee +0 -0
- data/spec/fixtures/grouper/components/form/form.m +0 -0
- data/spec/fixtures/grouper/components/form/form.scss +0 -0
- data/spec/fixtures/grouper/components/next-expanding-textarea/_next-expanding-textarea.scss +0 -0
- data/spec/fixtures/grouper/components/next-expanding-textarea/_next_expanding_textarea.coffee +0 -0
- data/spec/fixtures/grouper/components/next-expanding-textarea/next-expanding-textarea.haml +0 -0
- data/spec/fixtures/grouper/components/next-tab/next-tab.coffee +0 -0
- data/spec/fixtures/grouper/components/next-tab/next-tab.haml +0 -0
- data/spec/fixtures/grouper/components/next-tab/next-tab.scss +0 -0
- data/spec/fixtures/grouper/components/segmented control/segmented control.coffee +0 -0
- data/spec/fixtures/grouper/components/segmented control/segmented control.haml +0 -0
- data/spec/fixtures/grouper/components/segmented control/segmented control.min.html +0 -0
- data/spec/fixtures/grouper/components/segmented control/segmented control.scss +0 -0
- data/spec/fixtures/grouper/markup/list-view.haml +0 -0
- data/spec/fixtures/grouper/markup/resizable/resizable.haml +0 -0
- data/spec/fixtures/grouper/markup/toggle.haml +0 -0
- data/spec/fixtures/grouper/scripts/resizable/resizable.coffee +0 -0
- data/spec/fixtures/grouper/scripts/toggle.coffee +0 -0
- data/spec/fixtures/grouper/style/_list-view.scss +0 -0
- data/spec/fixtures/grouper/style/_toggle.scss +0 -0
- data/spec/fixtures/languages/stub.json +3 -0
- data/spec/fixtures/languages/stub.yml +2 -0
- data/spec/fixtures/parsers/coffeescript_parser_fixture_basic.coffee +20 -0
- data/spec/fixtures/parsers/coffeescript_parser_fixture_complex.coffee +80 -0
- data/spec/fixtures/parsers/css_parser_fixture_basic.css +44 -0
- data/spec/fixtures/parsers/css_parser_fixture_complex.css +120 -0
- data/spec/fixtures/parsers/javascript_parser_fixture_basic.js +27 -0
- data/spec/fixtures/parsers/javascript_parser_fixture_complex.js +85 -0
- data/spec/fixtures/parsers/sass_parser_fixture_basic.scss +39 -0
- data/spec/fixtures/parsers/sass_parser_fixture_complex.scss +149 -0
- data/spec/fixtures/parsers/stylus_parser_fixture_basic.styl +34 -0
- data/spec/fixtures/parsers/stylus_parser_fixture_complex.styl +113 -0
- data/spec/fixtures/processors/join_with_smart_line_breaks/code_blocks.txt +10 -0
- data/spec/fixtures/processors/join_with_smart_line_breaks/headings.txt +15 -0
- data/spec/fixtures/processors/join_with_smart_line_breaks/lists.txt +21 -0
- data/spec/fixtures/processors/join_with_smart_line_breaks/lists_with_nesting.txt +13 -0
- data/spec/fixtures/processors/join_with_smart_line_breaks/multiple_paragraphs.txt +11 -0
- data/spec/fixtures/renderers/helpers.rb +37 -0
- data/spec/fixtures/renderers/html_output.html +7 -0
- data/spec/fixtures/renderers/templates/layouts/application.html.erb +0 -0
- data/spec/fixtures/renderers/templates/layouts/more/subdirectory.html.erb +0 -0
- data/spec/fixtures/renderers/templates/partials/_leading_underscore.html.erb +1 -0
- data/spec/fixtures/renderers/templates/partials/more/_subdirectory.html.erb +1 -0
- data/spec/fixtures/renderers/templates/partials/partial.html.erb +0 -0
- data/spec/fixtures/renderers/templates/partials/template.html.erb +1 -0
- data/spec/fixtures/renderers/templates/template.html.erb +1 -0
- data/spec/fixtures/tags/description/button.md +24 -0
- data/spec/fixtures/tags/description/class.md +27 -0
- data/spec/fixtures/tags/description/component.md +23 -0
- data/spec/fixtures/tags/description/function.md +30 -0
- data/spec/lib/build_spec.rb +467 -0
- data/spec/lib/cache_spec.rb +175 -0
- data/spec/lib/command_line_spec.rb +77 -0
- data/spec/lib/configuration_spec.rb +180 -0
- data/spec/lib/containers/base_container_spec.rb +214 -0
- data/spec/lib/containers/class_container_spec.rb +209 -0
- data/spec/lib/containers/component_container_spec.rb +158 -0
- data/spec/lib/containers/demo_container_spec.rb +113 -0
- data/spec/lib/containers/function_container_spec.rb +116 -0
- data/spec/lib/containers/mixin_container_spec.rb +4 -0
- data/spec/lib/containers/pattern_container_spec.rb +291 -0
- data/spec/lib/containers/pattern_library_container_spec.rb +130 -0
- data/spec/lib/containers/symbol_container_spec.rb +216 -0
- data/spec/lib/containers/variable_container_spec.rb +116 -0
- data/spec/lib/containers/variation_container_spec.rb +52 -0
- data/spec/lib/containers_spec.rb +22 -0
- data/spec/lib/descriptor_spec.rb +73 -0
- data/spec/lib/group_spec.rb +151 -0
- data/spec/lib/helpers/path_helper_spec.rb +202 -0
- data/spec/lib/helpers/render_helper_spec.rb +159 -0
- data/spec/lib/helpers_spec.rb +35 -0
- data/spec/lib/languages/base_language_spec.rb +32 -0
- data/spec/lib/languages/coffeescript_language_spec.rb +52 -0
- data/spec/lib/languages/css_language_spec.rb +13 -0
- data/spec/lib/languages/erb_language_spec.rb +33 -0
- data/spec/lib/languages/haml_language_spec.rb +32 -0
- data/spec/lib/languages/javascript_language_spec.rb +54 -0
- data/spec/lib/languages/json_language_spec.rb +24 -0
- data/spec/lib/languages/less_language_spec.rb +39 -0
- data/spec/lib/languages/markup_language_spec.rb +95 -0
- data/spec/lib/languages/sass_language_spec.rb +53 -0
- data/spec/lib/languages/slim_language_spec.rb +32 -0
- data/spec/lib/languages/stylus_language_spec.rb +34 -0
- data/spec/lib/languages/yaml_language_spec.rb +24 -0
- data/spec/lib/languages_spec.rb +127 -0
- data/spec/lib/markdown_spec.rb +63 -0
- data/spec/lib/messenger_spec.rb +1 -0
- data/spec/lib/naming_conventions/bem_naming_convention_spec.rb +112 -0
- data/spec/lib/naming_conventions/suit_naming_convention_spec.rb +107 -0
- data/spec/lib/naming_conventions_spec.rb +28 -0
- data/spec/lib/ostruct_spec.rb +15 -0
- data/spec/lib/parser_spec.rb +93 -0
- data/spec/lib/parsers/base_parser_spec.rb +128 -0
- data/spec/lib/parsers/coffeescript_parser_spec.rb +184 -0
- data/spec/lib/parsers/css_parser_spec.rb +136 -0
- data/spec/lib/parsers/javascript_parser_spec.rb +216 -0
- data/spec/lib/parsers/less_parser_spec.rb +111 -0
- data/spec/lib/parsers/sass_parser_spec.rb +233 -0
- data/spec/lib/parsers/stylus_parser_spec.rb +212 -0
- data/spec/lib/process_spec.rb +96 -0
- data/spec/lib/processors_spec.rb +555 -0
- data/spec/lib/renderers/base_renderer_spec.rb +122 -0
- data/spec/lib/renderers/common_features/helperable_spec.rb +30 -0
- data/spec/lib/renderers/erb_renderer_spec.rb +119 -0
- data/spec/lib/renderers/haml_renderer_spec.rb +103 -0
- data/spec/lib/renderers/slim_renderer_spec.rb +103 -0
- data/spec/lib/symbol_sources/jquery_symbol_source_spec.rb +25 -0
- data/spec/lib/symbol_sources/mdn_symbol_source_spec.rb +40 -0
- data/spec/lib/symbol_sources/sass_symbol_source_spec.rb +39 -0
- data/spec/lib/symbol_sources_spec.rb +19 -0
- data/spec/lib/tags/access_tag_spec.rb +32 -0
- data/spec/lib/tags/activate_with_tag_spec.rb +31 -0
- data/spec/lib/tags/active_tag_spec.rb +24 -0
- data/spec/lib/tags/alias_tag_spec.rb +31 -0
- data/spec/lib/tags/author_tag_spec.rb +172 -0
- data/spec/lib/tags/base_tag_spec.rb +21 -0
- data/spec/lib/tags/beta_tag_spec.rb +52 -0
- data/spec/lib/tags/class_tag_spec.rb +29 -0
- data/spec/lib/tags/compatibility_tag_spec.rb +159 -0
- data/spec/lib/tags/demo_type_tag_spec.rb +24 -0
- data/spec/lib/tags/deprecated_tag_spec.rb +50 -0
- data/spec/lib/tags/description_tag_spec.rb +242 -0
- data/spec/lib/tags/example_tag_spec.rb +37 -0
- data/spec/lib/tags/factory_tag_spec.rb +29 -0
- data/spec/lib/tags/for_tag_spec.rb +45 -0
- data/spec/lib/tags/group_tag_spec.rb +20 -0
- data/spec/lib/tags/helper_tag_spec.rb +22 -0
- data/spec/lib/tags/include_with_tag_spec.rb +74 -0
- data/spec/lib/tags/javascript_action_tag_spec.rb +20 -0
- data/spec/lib/tags/link_tag_spec.rb +49 -0
- data/spec/lib/tags/markup_tag_spec.rb +255 -0
- data/spec/lib/tags/member_tag_spec.rb +167 -0
- data/spec/lib/tags/method_tag_spec.rb +27 -0
- data/spec/lib/tags/name_tag_spec.rb +20 -0
- data/spec/lib/tags/object_tag_spec.rb +24 -0
- data/spec/lib/tags/param_tag_spec.rb +261 -0
- data/spec/lib/tags/pattern_tag_spec.rb +49 -0
- data/spec/lib/tags/preclude_tag_spec.rb +31 -0
- data/spec/lib/tags/private_tag_spec.rb +31 -0
- data/spec/lib/tags/property_tag_spec.rb +27 -0
- data/spec/lib/tags/public_tag_spec.rb +29 -0
- data/spec/lib/tags/require_tag_spec.rb +133 -0
- data/spec/lib/tags/returns_tag_spec.rb +85 -0
- data/spec/lib/tags/set_by_tag_spec.rb +92 -0
- data/spec/lib/tags/signature_tag_spec.rb +125 -0
- data/spec/lib/tags/since_tag_spec.rb +48 -0
- data/spec/lib/tags/state_tag_spec.rb +199 -0
- data/spec/lib/tags/static_tag_spec.rb +27 -0
- data/spec/lib/tags/subcomponent_tag_spec.rb +78 -0
- data/spec/lib/tags/subtitle_tag_spec.rb +13 -0
- data/spec/lib/tags/symbol_type_tag_spec.rb +20 -0
- data/spec/lib/tags/throws_tag_spec.rb +49 -0
- data/spec/lib/tags/title_tag_spec.rb +20 -0
- data/spec/lib/tags/type_tag_spec.rb +20 -0
- data/spec/lib/tags/value_tag_spec.rb +20 -0
- data/spec/lib/tags/variant_tag_spec.rb +13 -0
- data/spec/lib/tags/variation_tag_spec.rb +154 -0
- data/spec/lib/tags_spec.rb +264 -0
- data/spec/lib/templates_spec.rb +185 -0
- data/spec/lib/themes_spec.rb +32 -0
- data/spec/spec_helper.rb +34 -0
- data/tasks/rspec.rake +7 -0
- data/tasks/rubocop.rake +8 -0
- metadata +740 -0
@@ -0,0 +1,94 @@
|
|
1
|
+
module Docks
|
2
|
+
module Helpers
|
3
|
+
module Path
|
4
|
+
def docks_path(symbol, options = {})
|
5
|
+
@path_cache ||= {}
|
6
|
+
|
7
|
+
postfixed_symbol = "#{symbol}#{"-#{options[:language]}" if options.fetch(:language, false)}"
|
8
|
+
return @path_cache[postfixed_symbol] unless @path_cache[postfixed_symbol].nil?
|
9
|
+
|
10
|
+
if search_result = @pattern.find(symbol)
|
11
|
+
@path_cache[postfixed_symbol] = "##{search_result.symbol_id}"
|
12
|
+
elsif search_result = @pattern_library.find(symbol)
|
13
|
+
@path_cache[postfixed_symbol] = relative_pattern_path(search_result.pattern.name, anchor: search_result.symbol.nil? ? nil : search_result.symbol.symbol_id)
|
14
|
+
elsif path = Docks::SymbolSources.path_for(symbol, options)
|
15
|
+
@path_cache[postfixed_symbol] = path
|
16
|
+
end
|
17
|
+
|
18
|
+
@path_cache[postfixed_symbol]
|
19
|
+
end
|
20
|
+
|
21
|
+
def relative_asset_path(asset)
|
22
|
+
(Docks.config.destination + asset).relative_path_from(Docks.current_render_destination)
|
23
|
+
end
|
24
|
+
|
25
|
+
def stylesheet_link_tag(stylesheet)
|
26
|
+
pathname = Pathname.new(stylesheet)
|
27
|
+
path = if pathname.absolute?
|
28
|
+
pathname.to_path
|
29
|
+
else
|
30
|
+
relative_asset_path(File.join(Docks.config.asset_folders.styles, "#{pathname.extname.length > 0 ? stylesheet.sub(/#{pathname.extname}$/, "") : stylesheet}.css"))
|
31
|
+
end
|
32
|
+
|
33
|
+
"<link rel='stylesheet' type='text/css' href='#{path}'>"
|
34
|
+
end
|
35
|
+
|
36
|
+
def docks_stylesheet(stylesheet = :main)
|
37
|
+
return unless Docks.config.use_theme_assets
|
38
|
+
postfix = (stylesheet.to_sym == :main ? "" : "-#{stylesheet.to_s}")
|
39
|
+
stylesheet_link_tag("docks#{postfix}.css")
|
40
|
+
end
|
41
|
+
|
42
|
+
def docks_javascript(script = :main)
|
43
|
+
return unless Docks.config.use_theme_assets
|
44
|
+
postfix = (script.to_sym == :main ? "" : "_#{script.to_s}")
|
45
|
+
javascript_include_tag("docks#{postfix}.js")
|
46
|
+
end
|
47
|
+
|
48
|
+
def javascript_include_tag(script)
|
49
|
+
pathname = Pathname.new(script)
|
50
|
+
path = if pathname.absolute?
|
51
|
+
pathname.to_path
|
52
|
+
else
|
53
|
+
relative_asset_path(File.join(Docks.config.asset_folders.scripts, "#{pathname.extname.length > 0 ? script.sub(/#{pathname.extname}$/, "") : script}.js"))
|
54
|
+
end
|
55
|
+
|
56
|
+
"<script src='#{path}'></script>"
|
57
|
+
end
|
58
|
+
|
59
|
+
def compiled_style_tags
|
60
|
+
content = Array(Docks.config.compiled_assets)
|
61
|
+
.select { |asset| Docks::Languages.language_for(asset).kind_of?(Docks::Languages::CSS) }
|
62
|
+
.map { |asset| stylesheet_link_tag(asset) }
|
63
|
+
.join("\n")
|
64
|
+
|
65
|
+
content.strip.empty? ? nil : content
|
66
|
+
end
|
67
|
+
|
68
|
+
def compiled_script_tags
|
69
|
+
content = Array(Docks.config.compiled_assets)
|
70
|
+
.select { |asset| Docks::Languages.language_for(asset).kind_of?(Docks::Languages::JavaScript) }
|
71
|
+
.map { |asset| javascript_include_tag(asset) }
|
72
|
+
.join("\n")
|
73
|
+
|
74
|
+
content.strip.empty? ? nil : content
|
75
|
+
end
|
76
|
+
|
77
|
+
def pattern_path(pattern, options = {})
|
78
|
+
pattern = pattern.name if pattern.kind_of?(Containers::Pattern)
|
79
|
+
|
80
|
+
file = "index.html"
|
81
|
+
file << "##{options[:anchor]}" if options.fetch(:anchor, false)
|
82
|
+
|
83
|
+
Docks.config.destination + File.join(Docks.config.mount_at, pattern.to_s, file)
|
84
|
+
end
|
85
|
+
|
86
|
+
private
|
87
|
+
|
88
|
+
def relative_pattern_path(pattern, options = {})
|
89
|
+
path = relative_asset_path(pattern_path(pattern, options)).to_s
|
90
|
+
path
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
require "erb"
|
2
|
+
require "active_support/core_ext/string/output_safety"
|
3
|
+
|
4
|
+
module Docks
|
5
|
+
module Helpers
|
6
|
+
module Render
|
7
|
+
include ::ERB::Util
|
8
|
+
|
9
|
+
def render_everything
|
10
|
+
render_everything_for(@pattern)
|
11
|
+
@pattern.symbols.each { |symbol| render_everything_for(symbol) }
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def render_everything_for(symbol, options = {})
|
17
|
+
case symbol
|
18
|
+
when Containers::Base
|
19
|
+
options[:language] = symbol.source.nil? ? nil : symbol.source.language_code
|
20
|
+
render_markup(symbol)
|
21
|
+
|
22
|
+
symbol.each do |k, v|
|
23
|
+
next if v.nil?
|
24
|
+
|
25
|
+
if k == :description
|
26
|
+
symbol[k] = render_description(v, options)
|
27
|
+
else
|
28
|
+
symbol[k] = render_everything_for(v, options)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
if symbol.respond_to?(:members)
|
33
|
+
symbol.members.each { |member| render_everything_for(member, options) }
|
34
|
+
end
|
35
|
+
|
36
|
+
when Array
|
37
|
+
symbol.map! { |each_symbol| render_everything_for(each_symbol, options) }
|
38
|
+
|
39
|
+
when OpenStruct
|
40
|
+
symbol.each do |k, v|
|
41
|
+
next if v.nil?
|
42
|
+
|
43
|
+
if k == :description
|
44
|
+
symbol.description = render_description(v, options)
|
45
|
+
else
|
46
|
+
symbol.send("#{k.to_s}=".to_sym, render_everything_for(v, options))
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
symbol
|
52
|
+
end
|
53
|
+
|
54
|
+
def render_markup(symbol)
|
55
|
+
markup, helper = symbol.markup, symbol.helper
|
56
|
+
return if markup.nil? && helper.nil?
|
57
|
+
symbol.markup = render(inline: (helper || markup), layout: false)
|
58
|
+
end
|
59
|
+
|
60
|
+
def render_description(description, options = {})
|
61
|
+
@example_count ||= 0
|
62
|
+
description.gsub! /(href\s*=\s*['"])@link\s([^'"]*)(.)/ do |match|
|
63
|
+
"#{$1}#{docks_path($2, options)}#{$3}"
|
64
|
+
end
|
65
|
+
|
66
|
+
render(layout: false, inline: description.gsub(/<fenced_code_block[^>]*>(.*?)<\/fenced_code_block>/m) { |match|
|
67
|
+
@example_count += 1
|
68
|
+
code = $1.dup
|
69
|
+
has_demo = match.include?("data-has-demo")
|
70
|
+
language = match.match(/data\-language=["']([^'"]*)/).captures.first
|
71
|
+
|
72
|
+
code_details = []
|
73
|
+
code_details << { code: code, language: language, label: "Helper" }
|
74
|
+
|
75
|
+
if has_demo
|
76
|
+
code_details << { code: render(inline: code, layout: false), language: "html", label: "Markup" }
|
77
|
+
end
|
78
|
+
|
79
|
+
docks_code_block code: code_details,
|
80
|
+
hideable?: has_demo,
|
81
|
+
id: "code-block--example-#{@example_count}",
|
82
|
+
demo?: has_demo
|
83
|
+
})
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
Dir[File.expand_path("../helpers/*.rb", __FILE__)].each do |helper|
|
2
|
+
require helper
|
3
|
+
end
|
4
|
+
|
5
|
+
module Docks
|
6
|
+
module Helpers
|
7
|
+
def self.add_helpers_to(renderer)
|
8
|
+
return unless renderer.respond_to?(:helpers)
|
9
|
+
|
10
|
+
renderer.helpers(*bundled_helpers)
|
11
|
+
renderer.helpers(*Docks.config.helpers)
|
12
|
+
renderer
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.bundled_helpers
|
16
|
+
@bundled_helpers ||= constants.map { |const| const_get(const) }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require_relative "../languages.rb"
|
2
|
+
|
3
|
+
module Docks
|
4
|
+
module Languages
|
5
|
+
class Base
|
6
|
+
include Singleton
|
7
|
+
|
8
|
+
def self.type; nil end
|
9
|
+
def self.extensions; nil end
|
10
|
+
def self.symbol_sources; nil end
|
11
|
+
|
12
|
+
def load_stub(file); nil end
|
13
|
+
def parser; nil end
|
14
|
+
def renderer; nil end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require_relative "base_language.rb"
|
2
|
+
require_relative "../parsers/coffeescript_parser.rb"
|
3
|
+
|
4
|
+
module Docks
|
5
|
+
module Languages
|
6
|
+
class CoffeeScript < Base
|
7
|
+
def self.type; Docks::Types::Languages::SCRIPT end
|
8
|
+
def self.extensions; %w(coffee coffeescript) end
|
9
|
+
|
10
|
+
def parser; Docks::Parsers::CoffeeScript.instance end
|
11
|
+
|
12
|
+
def signature_for(symbol)
|
13
|
+
is_class = symbol.symbol_type == Types::Symbol::CLASS
|
14
|
+
return unless is_class || [Types::Symbol::MIXIN, Types::Symbol::FUNCTION, Types::Symbol::FACTORY].include?(symbol.symbol_type)
|
15
|
+
params = symbol.fetch(:params, [])
|
16
|
+
|
17
|
+
presentation = if is_class
|
18
|
+
"class #{symbol.name}\n constructor: "
|
19
|
+
elsif symbol.respond_to?(:method?) && symbol.method?
|
20
|
+
symbol.static? ? "#{symbol.for}.#{symbol.name} = " : "#{symbol.name}: "
|
21
|
+
else
|
22
|
+
"#{symbol.name} = "
|
23
|
+
end
|
24
|
+
|
25
|
+
presentation << "(#{params.map { |param| "#{param.name}#{" = #{param.default}" if param.default}" }.join(", ")}) " unless params.empty?
|
26
|
+
"#{presentation}-> # ..."
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
module Docks
|
2
|
+
module Languages
|
3
|
+
module Common
|
4
|
+
module Markup
|
5
|
+
# TODO: empty arguments
|
6
|
+
private
|
7
|
+
|
8
|
+
def functionize_helper(helper_name, arguments, options = {})
|
9
|
+
arguments = normalize_arguments(arguments)
|
10
|
+
start_with = options[:start_with] || ""
|
11
|
+
end_with = options[:end_with] || ""
|
12
|
+
|
13
|
+
index = 0
|
14
|
+
arguments_length = arguments.length
|
15
|
+
|
16
|
+
function_string = arguments.inject("#{start_with}#{helper_name} ") do |func, argument|
|
17
|
+
index += 1
|
18
|
+
|
19
|
+
unless index == 1
|
20
|
+
func << ", "
|
21
|
+
end
|
22
|
+
|
23
|
+
stringified = if index == arguments_length && argument.kind_of?(Hash)
|
24
|
+
stringify_val(argument, join_with: ",\n#{" " * func.length}").sub(/\A[^\{]*\{ /, "").sub(/ \}[^\}]*\z/m, "")
|
25
|
+
else
|
26
|
+
stringify_val(argument)
|
27
|
+
end
|
28
|
+
|
29
|
+
func << stringified
|
30
|
+
func
|
31
|
+
end
|
32
|
+
|
33
|
+
"#{function_string}#{end_with}"
|
34
|
+
end
|
35
|
+
|
36
|
+
def normalize_arguments(arguments)
|
37
|
+
arguments.kind_of?(Array) ? arguments : [(arguments[:arguments] || arguments["arguments"] || [arguments])].flatten
|
38
|
+
end
|
39
|
+
|
40
|
+
def stringify_val(val, options = {})
|
41
|
+
if val.kind_of?(String)
|
42
|
+
"\"#{val}\""
|
43
|
+
elsif val.kind_of?(Hash)
|
44
|
+
options[:join_with] ||= ", "
|
45
|
+
"{ #{val.map { |k, v| "#{(!k.kind_of?(String) && simple_symbol?(k)) ? "#{k}:" : "#{stringify_val(k)} =>"} #{stringify_val(v)}" }.join(options[:join_with])} }"
|
46
|
+
elsif val.kind_of?(Array)
|
47
|
+
options[:join_with] ||= ", "
|
48
|
+
"[#{val.map { |v| stringify_val(v) }.join(options[:join_with])}]"
|
49
|
+
elsif val.nil?
|
50
|
+
"nil"
|
51
|
+
elsif val.kind_of?(Symbol)
|
52
|
+
val = val.to_s
|
53
|
+
if simple_symbol?(val)
|
54
|
+
":#{val}"
|
55
|
+
else
|
56
|
+
":\"#{val}\""
|
57
|
+
end
|
58
|
+
elsif val.kind_of?(Numeric)
|
59
|
+
val.to_s.reverse.gsub(/(\d{3})(?=\d)/, '\\1_').reverse
|
60
|
+
else
|
61
|
+
val.to_s
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def simple_symbol?(symbol)
|
66
|
+
symbol.to_s.split(" ").length == 1
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require_relative "base_language.rb"
|
2
|
+
require_relative "../parsers/css_parser.rb"
|
3
|
+
|
4
|
+
module Docks
|
5
|
+
module Languages
|
6
|
+
class CSS < Base
|
7
|
+
def self.type; Docks::Types::Languages::STYLE end
|
8
|
+
def self.extensions; %w(css) end
|
9
|
+
|
10
|
+
def parser; Docks::Parsers::CSS.instance end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require_relative "base_language.rb"
|
2
|
+
require_relative "common_types/markup_language.rb"
|
3
|
+
|
4
|
+
require_relative "../renderers/erb_renderer.rb"
|
5
|
+
|
6
|
+
module Docks
|
7
|
+
module Languages
|
8
|
+
class ERB < Base
|
9
|
+
include Common::Markup
|
10
|
+
|
11
|
+
def self.type; Docks::Types::Languages::MARKUP end
|
12
|
+
def self.extensions; %w(erb) end
|
13
|
+
|
14
|
+
def helper_markup_for(helper_name, arguments)
|
15
|
+
functionize_helper(helper_name, arguments, start_with: "<%= ", end_with: " %>")
|
16
|
+
end
|
17
|
+
|
18
|
+
def renderer; Docks::Renderers::ERB.new end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require_relative "base_language.rb"
|
2
|
+
require_relative "common_types/markup_language.rb"
|
3
|
+
|
4
|
+
require_relative "../renderers/haml_renderer.rb"
|
5
|
+
|
6
|
+
module Docks
|
7
|
+
module Languages
|
8
|
+
class Haml < Base
|
9
|
+
include Common::Markup
|
10
|
+
|
11
|
+
def self.type; Docks::Types::Languages::MARKUP end
|
12
|
+
def self.extensions; %w(haml) end
|
13
|
+
|
14
|
+
def helper_markup_for(helper_name, arguments)
|
15
|
+
functionize_helper(helper_name, arguments, start_with: "= ")
|
16
|
+
end
|
17
|
+
|
18
|
+
def renderer; Docks::Renderers::Haml.new end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require_relative "base_language.rb"
|
2
|
+
require_relative "../parsers/javascript_parser.rb"
|
3
|
+
require_relative "../symbol_sources/jquery_symbol_source.rb"
|
4
|
+
require_relative "../symbol_sources/mdn_symbol_source.rb"
|
5
|
+
|
6
|
+
module Docks
|
7
|
+
module Languages
|
8
|
+
class JavaScript < Base
|
9
|
+
def self.type; Docks::Types::Languages::SCRIPT end
|
10
|
+
def self.extensions; %w(js) end
|
11
|
+
def self.symbol_sources; [SymbolSources::JQuery, SymbolSources::MDN] end
|
12
|
+
|
13
|
+
def parser; Docks::Parsers::JavaScript.instance end
|
14
|
+
|
15
|
+
def signature_for(symbol)
|
16
|
+
return unless [Types::Symbol::MIXIN, Types::Symbol::FUNCTION, Types::Symbol::FACTORY, Types::Symbol::CLASS].include?(symbol.symbol_type)
|
17
|
+
params = symbol.fetch(:params, []).map do |param|
|
18
|
+
text = ""
|
19
|
+
text << "[" if param.optional
|
20
|
+
text << param.name
|
21
|
+
text << " = #{param.default}" if param.default
|
22
|
+
text << "]" if param.optional
|
23
|
+
text
|
24
|
+
end
|
25
|
+
|
26
|
+
presentation = if symbol.respond_to?(:method?) && symbol.method?
|
27
|
+
if symbol.static?
|
28
|
+
"#{symbol.for}.#{symbol.name} = function"
|
29
|
+
elsif symbol.belongs_to.instance_of?(Containers::Klass)
|
30
|
+
"#{symbol.for}.prototype.#{symbol.name} = function"
|
31
|
+
else
|
32
|
+
"#{symbol.name}: function"
|
33
|
+
end
|
34
|
+
else
|
35
|
+
"function #{symbol.name}"
|
36
|
+
end
|
37
|
+
|
38
|
+
"#{presentation}(#{params.join(", ")}) { /* ... */ }"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require_relative "base_language.rb"
|
2
|
+
|
3
|
+
module Docks
|
4
|
+
module Languages
|
5
|
+
class JSON < Base
|
6
|
+
def self.type; Docks::Types::Languages::STUB end
|
7
|
+
def self.extensions; %w(json) end
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
require "json"
|
11
|
+
end
|
12
|
+
|
13
|
+
def load_stub(file)
|
14
|
+
::JSON::load(File.read(file).force_encoding("UTF-8"))
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require_relative "base_language.rb"
|
2
|
+
require_relative "../parsers/less_parser.rb"
|
3
|
+
|
4
|
+
module Docks
|
5
|
+
module Languages
|
6
|
+
class Less < Base
|
7
|
+
def self.type; Docks::Types::Languages::STYLE end
|
8
|
+
def self.extensions; %w(less) end
|
9
|
+
|
10
|
+
def signature_for(symbol)
|
11
|
+
return unless symbol.kind_of?(Containers::Mixin)
|
12
|
+
|
13
|
+
directive = clean_presentation(symbol.name, ".")
|
14
|
+
params = symbol.fetch(:param, []).map do |param|
|
15
|
+
name, default = param.name, param.default
|
16
|
+
param_string = clean_presentation(name)
|
17
|
+
param_string << ": #{default}" if default
|
18
|
+
param_string
|
19
|
+
end
|
20
|
+
|
21
|
+
"#{directive}(#{params.join(", ")}) { /* ... */ }"
|
22
|
+
end
|
23
|
+
|
24
|
+
def parser; Docks::Parsers::Less.instance end
|
25
|
+
|
26
|
+
protected
|
27
|
+
|
28
|
+
def clean_presentation(symbol, prefix = "@")
|
29
|
+
"#{prefix unless symbol.start_with?(prefix)}#{symbol}"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require_relative "base_language.rb"
|
2
|
+
require_relative "../parsers/sass_parser.rb"
|
3
|
+
require_relative "../symbol_sources/sass_symbol_source.rb"
|
4
|
+
|
5
|
+
module Docks
|
6
|
+
module Languages
|
7
|
+
class Sass < Base
|
8
|
+
def self.type; Docks::Types::Languages::STYLE end
|
9
|
+
def self.extensions; %w(scss sass) end
|
10
|
+
def self.symbol_sources; SymbolSources::Sass end
|
11
|
+
|
12
|
+
def signature_for(symbol)
|
13
|
+
return unless [Types::Symbol::FUNCTION, Types::Symbol::MIXIN].include?(symbol.symbol_type)
|
14
|
+
directive = "@#{symbol.symbol_type == Types::Symbol::FUNCTION ? "function" : "mixin"} #{symbol.name}"
|
15
|
+
|
16
|
+
params = symbol.fetch(:params, []).map do |param|
|
17
|
+
name, default = param.name, param.default
|
18
|
+
param_string = variable_presentation(name)
|
19
|
+
param_string << ": #{default}" if default
|
20
|
+
param_string
|
21
|
+
end
|
22
|
+
|
23
|
+
"#{directive}(#{params.join(", ")}) { /* ... */ }"
|
24
|
+
end
|
25
|
+
|
26
|
+
def parser; Docks::Parsers::Sass.instance end
|
27
|
+
|
28
|
+
protected
|
29
|
+
|
30
|
+
def variable_presentation(symbol, type = :variable)
|
31
|
+
prefix = type == :variable ? "$" : "%"
|
32
|
+
"#{prefix unless symbol.start_with?(prefix)}#{symbol}"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require_relative "base_language.rb"
|
2
|
+
require_relative "common_types/markup_language.rb"
|
3
|
+
|
4
|
+
require_relative "../renderers/slim_renderer.rb"
|
5
|
+
|
6
|
+
module Docks
|
7
|
+
module Languages
|
8
|
+
class Slim < Base
|
9
|
+
include Common::Markup
|
10
|
+
|
11
|
+
def self.type; Docks::Types::Languages::MARKUP end
|
12
|
+
def self.extensions; %w(slim) end
|
13
|
+
|
14
|
+
def helper_markup_for(helper_name, arguments)
|
15
|
+
functionize_helper(helper_name, arguments, start_with: "== ")
|
16
|
+
end
|
17
|
+
|
18
|
+
def renderer; Docks::Renderers::Slim.new end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require_relative "base_language.rb"
|
2
|
+
require_relative "../parsers/stylus_parser.rb"
|
3
|
+
|
4
|
+
module Docks
|
5
|
+
module Languages
|
6
|
+
class Stylus < Base
|
7
|
+
def self.type; Docks::Types::Languages::STYLE end
|
8
|
+
def self.extensions; %w(styl) end
|
9
|
+
|
10
|
+
def signature_for(symbol)
|
11
|
+
return unless [Types::Symbol::FUNCTION, Types::Symbol::MIXIN].include?(symbol.symbol_type)
|
12
|
+
|
13
|
+
params = symbol.fetch(:params, []).map do |param|
|
14
|
+
default = param.default
|
15
|
+
param_string = param.name
|
16
|
+
param_string << " = #{default}" if default
|
17
|
+
param_string
|
18
|
+
end
|
19
|
+
|
20
|
+
"#{symbol.name}(#{params.join(", ")}) // ..."
|
21
|
+
end
|
22
|
+
|
23
|
+
def parser; Docks::Parsers::Stylus.instance end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require_relative "base_language.rb"
|
2
|
+
|
3
|
+
module Docks
|
4
|
+
module Languages
|
5
|
+
class YAML < Base
|
6
|
+
def self.type; Docks::Types::Languages::STUB end
|
7
|
+
def self.extensions; %w(yml yaml) end
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
require "yaml"
|
11
|
+
end
|
12
|
+
|
13
|
+
def load_stub(file)
|
14
|
+
::YAML::load_file(file)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|