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.
- 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,217 @@
|
|
|
1
|
+
require "singleton"
|
|
2
|
+
require "pathname"
|
|
3
|
+
|
|
4
|
+
require_relative "cache.rb"
|
|
5
|
+
require_relative "templates.rb"
|
|
6
|
+
require_relative "tags.rb"
|
|
7
|
+
require_relative "symbol_sources.rb"
|
|
8
|
+
require_relative "naming_conventions.rb"
|
|
9
|
+
require_relative "themes.rb"
|
|
10
|
+
|
|
11
|
+
module Docks
|
|
12
|
+
class Configuration
|
|
13
|
+
include Singleton
|
|
14
|
+
|
|
15
|
+
ROOT_DEPENDENT_PATHS = [
|
|
16
|
+
:sources,
|
|
17
|
+
:destination,
|
|
18
|
+
:cache_location,
|
|
19
|
+
:templates,
|
|
20
|
+
:helpers
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
# Key details — these are required
|
|
24
|
+
attr_accessor :sources, :destination, :theme
|
|
25
|
+
|
|
26
|
+
# Locations
|
|
27
|
+
attr_accessor :root, :cache_location, :templates, :asset_folders
|
|
28
|
+
|
|
29
|
+
# Random assortment of other stuff
|
|
30
|
+
attr_accessor :github_repo, :mount_at, :helpers, :compiled_assets,
|
|
31
|
+
:naming_convention, :pattern_id, :paginate, :use_theme_assets
|
|
32
|
+
|
|
33
|
+
# Stateful stuff
|
|
34
|
+
attr_reader :configured
|
|
35
|
+
|
|
36
|
+
def initialize
|
|
37
|
+
restore_defaults
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def root=(new_root)
|
|
41
|
+
@root = new_root.kind_of?(Pathname) ? new_root : Pathname.new(new_root)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def asset_folders=(new_asset_folders)
|
|
45
|
+
new_asset_folders.each do |type, dir|
|
|
46
|
+
@asset_folders.send("#{type}=".to_sym, dir)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
@asset_folders
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def naming_convention=(new_naming_convention)
|
|
53
|
+
@naming_convention = NamingConventions.for(new_naming_convention)
|
|
54
|
+
@naming_convention
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def theme=(new_theme)
|
|
58
|
+
@theme = Themes.for(new_theme)
|
|
59
|
+
@theme
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def github_repo
|
|
63
|
+
return nil if @github_repo.nil? || @github_repo.empty?
|
|
64
|
+
"https://github.com/#{@github_repo.split("/")[-2..-1].join("/")}"
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def paginate?
|
|
68
|
+
!!@paginate
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def pattern_id(*args)
|
|
72
|
+
Docks.pattern_id(*args)
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def pattern_id=(block)
|
|
76
|
+
Docks.pattern_id = block
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def finalize
|
|
80
|
+
@configured = true
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def custom_languages
|
|
84
|
+
yield Languages
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def custom_tags
|
|
88
|
+
yield Tags
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def custom_templates
|
|
92
|
+
yield Templates
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def custom_templates=(custom_templates)
|
|
96
|
+
Templates.register(custom_templates)
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def custom_symbol_sources
|
|
100
|
+
yield SymbolSources
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
def custom_parsers
|
|
104
|
+
yield Parser
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
ROOT_DEPENDENT_PATHS.each do |path|
|
|
108
|
+
define_method(path) do
|
|
109
|
+
paths = instance_variable_get("@#{path.to_s}".to_sym)
|
|
110
|
+
return if paths.nil?
|
|
111
|
+
|
|
112
|
+
if paths.kind_of?(Array)
|
|
113
|
+
paths.map { |a_path| make_path_absolute(a_path) }
|
|
114
|
+
else
|
|
115
|
+
make_path_absolute(paths)
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
def restore_defaults
|
|
121
|
+
@configured = false
|
|
122
|
+
@sources = [
|
|
123
|
+
"styles/**/*.{css,scss,sass,less,styl}",
|
|
124
|
+
"scripts/**/*.{js,coffee,coffeescript}"
|
|
125
|
+
]
|
|
126
|
+
@compiled_assets = []
|
|
127
|
+
@github_repo = ""
|
|
128
|
+
@paginate = :pattern
|
|
129
|
+
@naming_convention = NamingConventions::BEM.instance
|
|
130
|
+
@helpers = []
|
|
131
|
+
|
|
132
|
+
@theme = Themes.for("API")
|
|
133
|
+
@use_theme_assets = true
|
|
134
|
+
|
|
135
|
+
@root = Pathname.pwd
|
|
136
|
+
@cache_location = ".#{Docks::Cache::DIR}"
|
|
137
|
+
|
|
138
|
+
@templates = "#{Docks::ASSETS_DIR}/templates"
|
|
139
|
+
@custom_templates = {
|
|
140
|
+
fallback: "pattern",
|
|
141
|
+
demo: "demo"
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
@destination = "public"
|
|
145
|
+
@asset_folders = OpenStruct.new(scripts: "scripts", styles: "styles")
|
|
146
|
+
|
|
147
|
+
@mount_at = "pattern-library"
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
private
|
|
151
|
+
|
|
152
|
+
def make_path_absolute(path)
|
|
153
|
+
pathname = path.kind_of?(Pathname) ? path : Pathname.new(path)
|
|
154
|
+
if pathname.absolute?
|
|
155
|
+
pathname
|
|
156
|
+
else
|
|
157
|
+
@root + pathname
|
|
158
|
+
end
|
|
159
|
+
end
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
@configuration = Configuration.instance
|
|
164
|
+
|
|
165
|
+
def self.config
|
|
166
|
+
@configuration
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
def self.configure_with(configurer)
|
|
170
|
+
if configurer.kind_of?(Hash)
|
|
171
|
+
configure do |config|
|
|
172
|
+
configurer.each do |key, val|
|
|
173
|
+
key = "#{key}=".to_sym
|
|
174
|
+
config.send(key, val) if config.respond_to?(key)
|
|
175
|
+
end
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
return
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
configurer = Dir[configurer].first
|
|
182
|
+
|
|
183
|
+
unless File.exists?(configurer)
|
|
184
|
+
Messenger.error("No configuration file could be found.")
|
|
185
|
+
exit
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
if File.extname(configurer) =~ /rb/
|
|
189
|
+
self.class_eval(File.read(configurer))
|
|
190
|
+
else
|
|
191
|
+
Languages.register_bundled_languages
|
|
192
|
+
language = Languages.language_for(configurer)
|
|
193
|
+
configure_with(language.load_stub(configurer)) unless language.nil?
|
|
194
|
+
end
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
def self.configure
|
|
198
|
+
unless block_given?
|
|
199
|
+
return configure_with(CONFIG_FILE)
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
pre_configuration unless @configuration.configured
|
|
203
|
+
yield @configuration
|
|
204
|
+
post_configuration
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
private
|
|
208
|
+
|
|
209
|
+
def self.pre_configuration
|
|
210
|
+
Tags.register_bundled_tags
|
|
211
|
+
Languages.register_bundled_languages
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
def self.post_configuration
|
|
215
|
+
@configuration.finalize
|
|
216
|
+
end
|
|
217
|
+
end
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
require "forwardable"
|
|
2
|
+
require_relative "../tags.rb"
|
|
3
|
+
require_relative "../descriptor.rb"
|
|
4
|
+
|
|
5
|
+
module Docks
|
|
6
|
+
module Containers
|
|
7
|
+
|
|
8
|
+
# Public: the base container for symbols. This class should be inherited
|
|
9
|
+
# from for all other symbol containers. Its most important feature is that
|
|
10
|
+
# it normalizes synonymous tags so that any tag can be called on a
|
|
11
|
+
# container and the result will be returned as expected.
|
|
12
|
+
|
|
13
|
+
class Base
|
|
14
|
+
extend Forwardable
|
|
15
|
+
def_delegators :@details, :to_s, :inspect, :to_json, :each
|
|
16
|
+
|
|
17
|
+
def initialize(details = {})
|
|
18
|
+
if details.kind_of?(Base)
|
|
19
|
+
details.delete(:symbol_type)
|
|
20
|
+
details = details.to_h
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
details = Tags.join_synonymous_tags(details)
|
|
24
|
+
@details = details
|
|
25
|
+
@summary = false
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def to_h; @details end
|
|
29
|
+
alias_method :to_hash, :to_h
|
|
30
|
+
|
|
31
|
+
def ==(other_container)
|
|
32
|
+
self.class == other_container.class && @details == other_container.instance_variable_get(:@details)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def update(tag)
|
|
36
|
+
self[tag] = yield(self[tag])
|
|
37
|
+
self
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def [](tag)
|
|
41
|
+
fetch(tag, nil)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def []=(tag, new_value)
|
|
45
|
+
tag = Tags.base_tag_name(tag)
|
|
46
|
+
@details[tag] = new_value unless tag.nil?
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def delete(tag)
|
|
50
|
+
@details.delete(Tags.base_tag_name(tag))
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def fetch(tag, *args)
|
|
54
|
+
@details.fetch(Tags.base_tag_name(tag), *args)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def tags
|
|
58
|
+
@details.keys.map { |tag| Tags.tag_for(tag) }
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def method_missing(meth, *args, &block)
|
|
62
|
+
stripped = meth.to_s.sub("=", "").to_sym
|
|
63
|
+
has_tag = Tags.has_tag?(stripped)
|
|
64
|
+
|
|
65
|
+
if stripped != meth && has_tag
|
|
66
|
+
self[stripped] = args.first
|
|
67
|
+
elsif has_tag
|
|
68
|
+
fetch(meth, nil)
|
|
69
|
+
else
|
|
70
|
+
super(meth, *args, &block)
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def respond_to?(meth)
|
|
75
|
+
Tags.has_tag?(meth.to_s.sub("=", "")) || super
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def summarized?; @summary end
|
|
79
|
+
alias_method :summary?, :summarized?
|
|
80
|
+
|
|
81
|
+
def summary
|
|
82
|
+
summary = self.class.new(name: self.name)
|
|
83
|
+
summary.instance_variable_set(:@summary, true)
|
|
84
|
+
summary
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def find(descriptor)
|
|
88
|
+
descriptor = Descriptor.new(descriptor)
|
|
89
|
+
matches_exactly?(descriptor) && self
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
protected
|
|
93
|
+
|
|
94
|
+
def matches?(descriptor)
|
|
95
|
+
fetch(:name, nil) == descriptor.symbol
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def matches_exactly?(descriptor)
|
|
99
|
+
!descriptor.member? && matches?(descriptor)
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
require_relative "symbol_container.rb"
|
|
2
|
+
|
|
3
|
+
module Docks
|
|
4
|
+
module Containers
|
|
5
|
+
|
|
6
|
+
# Public: a container for Class symbols.
|
|
7
|
+
|
|
8
|
+
class Klass < Symbol
|
|
9
|
+
# Public: the type of symbols that should be encapsulated by this
|
|
10
|
+
# container. This is compared against a symbol's `symbol_type` to
|
|
11
|
+
# determine which container to use.
|
|
12
|
+
#
|
|
13
|
+
# Returns the type String.
|
|
14
|
+
|
|
15
|
+
def self.type; Docks::Types::Symbol::CLASS end
|
|
16
|
+
|
|
17
|
+
def public_methods; methods.select { |meth| meth.public? } end
|
|
18
|
+
def private_methods; methods.select { |meth| meth.private? } end
|
|
19
|
+
|
|
20
|
+
def static_methods; methods.select { |meth| meth.static? } end
|
|
21
|
+
def instance_methods; methods.reject { |meth| meth.static? } end
|
|
22
|
+
|
|
23
|
+
def public_properties; properties.select { |prop| prop.public? } end
|
|
24
|
+
def private_properties; properties.select { |prop| prop.private? } end
|
|
25
|
+
|
|
26
|
+
def static_properties; properties.select { |prop| prop.static? } end
|
|
27
|
+
def instance_properties; properties.reject { |prop| prop.static? } end
|
|
28
|
+
|
|
29
|
+
def instance_members; instance_methods + instance_properties end
|
|
30
|
+
def static_members; static_methods + static_properties end
|
|
31
|
+
|
|
32
|
+
def add_member(symbol)
|
|
33
|
+
static = symbol.static?
|
|
34
|
+
super
|
|
35
|
+
symbol.static = static
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
require_relative "symbol_container.rb"
|
|
2
|
+
|
|
3
|
+
module Docks
|
|
4
|
+
module Containers
|
|
5
|
+
|
|
6
|
+
# Public: a container for Component symbols.
|
|
7
|
+
|
|
8
|
+
class Component < Symbol
|
|
9
|
+
|
|
10
|
+
# Public: the type of symbols that should be encapsulated by this
|
|
11
|
+
# container. This is compared against a symbol's `symbol_type` to
|
|
12
|
+
# determine which container to use.
|
|
13
|
+
#
|
|
14
|
+
# Returns the type String.
|
|
15
|
+
|
|
16
|
+
def self.type; Docks::Types::Symbol::COMPONENT end
|
|
17
|
+
|
|
18
|
+
def initialize(component_hash = {})
|
|
19
|
+
super
|
|
20
|
+
|
|
21
|
+
self[:states] ||= []
|
|
22
|
+
self[:variants] ||= []
|
|
23
|
+
self[:subcomponents] ||= []
|
|
24
|
+
self[:included_symbols] ||= []
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def subcomponents(options = {}, &block)
|
|
28
|
+
subcomponents = if options.fetch(:recursive, false)
|
|
29
|
+
recursive_subcomponents
|
|
30
|
+
else
|
|
31
|
+
self[:subcomponents]
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
block_given? ? subcomponents.each(&block) : subcomponents
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
alias_method :subcomponent, :subcomponents
|
|
38
|
+
|
|
39
|
+
def has_demo?
|
|
40
|
+
!((markup || "") + (helper || "")).empty?
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def variations(&block)
|
|
44
|
+
variations = states + variants
|
|
45
|
+
block_given? ? variations.each(&block) : variations
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def find(descriptor)
|
|
49
|
+
super || find_in_members(descriptor)
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def summary
|
|
53
|
+
summary = super
|
|
54
|
+
|
|
55
|
+
[:states, :variants, :subcomponents].each do |property|
|
|
56
|
+
summary[property] = fetch(property, []).map(&:summary)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
summary
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
protected
|
|
63
|
+
|
|
64
|
+
def recursive_subcomponents
|
|
65
|
+
self[:subcomponents].inject([]) do |all_subcomponents, subcomponent|
|
|
66
|
+
all_subcomponents << subcomponent
|
|
67
|
+
all_subcomponents.concat(subcomponent.recursive_subcomponents)
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def find_in_members(descriptor)
|
|
72
|
+
descriptor = Descriptor.new(descriptor)
|
|
73
|
+
|
|
74
|
+
found = if !(descriptor.member? && descriptor.symbol != fetch(:name, nil))
|
|
75
|
+
possible_variation_name = descriptor.member || descriptor.symbol
|
|
76
|
+
variations.find { |variation| variation.find(descriptor) } || false
|
|
77
|
+
else
|
|
78
|
+
false
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
return found if found
|
|
82
|
+
|
|
83
|
+
# Can't do a regular #find since each component searches its subcomponents
|
|
84
|
+
subcomponents.each do |subcomponent|
|
|
85
|
+
break if found = subcomponent.find(descriptor)
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
found
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
require_relative "base_container.rb"
|
|
2
|
+
|
|
3
|
+
module Docks
|
|
4
|
+
module Containers
|
|
5
|
+
|
|
6
|
+
# Public: a container for demos. This is a special type of container in
|
|
7
|
+
# that it does not correspond directly to a symbol from the parse results.
|
|
8
|
+
# Instead, it encapsulates and provides helper methods for sets of
|
|
9
|
+
# components that require a demo.
|
|
10
|
+
|
|
11
|
+
class Demo
|
|
12
|
+
|
|
13
|
+
# Public: the type of symbols that should be encapsulated by this
|
|
14
|
+
# container. This is compared against a symbol's `symbol_type` to
|
|
15
|
+
# determine which container to use.
|
|
16
|
+
#
|
|
17
|
+
# Returns the type String.
|
|
18
|
+
|
|
19
|
+
def self.type; Docks::Types::Symbol::DEMO end
|
|
20
|
+
|
|
21
|
+
attr_reader :component, :name
|
|
22
|
+
|
|
23
|
+
# Public: initializes a new demo.
|
|
24
|
+
|
|
25
|
+
def initialize(component)
|
|
26
|
+
@component = component
|
|
27
|
+
@name = component.name
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# Public: collects all variations on the components that are being demo'ed
|
|
31
|
+
# that were specified to be "select" types. The optional options Hash
|
|
32
|
+
# allows you to choose whether or not to group the result by base class
|
|
33
|
+
# (using the `group_by_component` key of `true`), in which case the
|
|
34
|
+
# result will be a Hash of Arrays where the keys are the base classes.
|
|
35
|
+
# Otherwise, a simple Array of variation symbols is returned.
|
|
36
|
+
#
|
|
37
|
+
# options - A hash of options. Defaults to {}.
|
|
38
|
+
#
|
|
39
|
+
# Returns a Hash or Array of "select"-type variations, depending on the
|
|
40
|
+
# value of the `group_by_component` option.
|
|
41
|
+
|
|
42
|
+
def select_variations(options = {})
|
|
43
|
+
variations_of_type(Docks::Types::Demo::SELECT, options)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# Public: collects all the variations of the demo'ed components that
|
|
47
|
+
# should be presented as joint demos.
|
|
48
|
+
#
|
|
49
|
+
# Returns an Array of "joint"-type variations.
|
|
50
|
+
|
|
51
|
+
def joint_variations
|
|
52
|
+
variations_of_type(Docks::Types::Demo::JOINT)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
private
|
|
58
|
+
|
|
59
|
+
# Private: Collects all variations of components in this demo whose
|
|
60
|
+
# `demo_type` has been set to the passed `type`.
|
|
61
|
+
#
|
|
62
|
+
# type - a String of the demo type to search for.
|
|
63
|
+
# options - an optional options Hash. Default is {}.
|
|
64
|
+
#
|
|
65
|
+
# Returns a Hash or Array of variations matching the passed type,
|
|
66
|
+
# depending on the value of the `group_by_component` option.
|
|
67
|
+
|
|
68
|
+
def variations_of_type(type, options = {})
|
|
69
|
+
group_by_component = options[:group_by_component]
|
|
70
|
+
matches = group_by_component ? {} : []
|
|
71
|
+
|
|
72
|
+
return matches unless @component.symbol_type == Docks::Types::Symbol::COMPONENT
|
|
73
|
+
|
|
74
|
+
([@component] + @component.subcomponents + @component.included_symbols).each do |a_component|
|
|
75
|
+
if demo_type = a_component.demo_type
|
|
76
|
+
next unless demo_type == type
|
|
77
|
+
|
|
78
|
+
if group_by_component
|
|
79
|
+
matches[a_component.base_class] ||= []
|
|
80
|
+
matches[a_component.base_class] << a_component
|
|
81
|
+
else
|
|
82
|
+
matches << a_component
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
next
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
component_name = a_component.name
|
|
89
|
+
a_component.variations.each do |v|
|
|
90
|
+
next unless v.demo_type == type
|
|
91
|
+
|
|
92
|
+
if group_by_component
|
|
93
|
+
matches[component_name] ||= []
|
|
94
|
+
matches[component_name] << v
|
|
95
|
+
else
|
|
96
|
+
matches.push << v
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
matches
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
require_relative "symbol_container.rb"
|
|
2
|
+
|
|
3
|
+
module Docks
|
|
4
|
+
module Containers
|
|
5
|
+
# Public: a container for Function symbols.
|
|
6
|
+
|
|
7
|
+
class Function < Symbol
|
|
8
|
+
def self.type; Docks::Types::Symbol::FUNCTION end
|
|
9
|
+
|
|
10
|
+
def static?; fetch(:static, false) end
|
|
11
|
+
def instance?; !static? end
|
|
12
|
+
def method?; fetch(:method, false) end
|
|
13
|
+
|
|
14
|
+
def symbol_id
|
|
15
|
+
return super unless method?
|
|
16
|
+
"method-#{"static-" if static?}#{self[:for]}-#{self[:name]}"
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def to_descriptor
|
|
20
|
+
return super unless method?
|
|
21
|
+
"#{belongs_to.to_descriptor}#{static? ? "." : "#"}#{fetch(:name)}"
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def summary
|
|
25
|
+
summary = super
|
|
26
|
+
summary.static = static?
|
|
27
|
+
summary.method = method?
|
|
28
|
+
summary.for = fetch(:for, nil)
|
|
29
|
+
summary
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
protected
|
|
33
|
+
|
|
34
|
+
def matches_exactly?(descriptor)
|
|
35
|
+
name = fetch(:name, nil)
|
|
36
|
+
is_method = method?
|
|
37
|
+
|
|
38
|
+
matches = (!is_method && super) ||
|
|
39
|
+
(is_method && instance? && descriptor.instance_member == name) ||
|
|
40
|
+
(is_method && static? && descriptor.static_member == name)
|
|
41
|
+
|
|
42
|
+
matches && self
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require_relative "symbol_container.rb"
|
|
2
|
+
|
|
3
|
+
module Docks
|
|
4
|
+
module Containers
|
|
5
|
+
|
|
6
|
+
# Public: a container for Mixin symbols.
|
|
7
|
+
|
|
8
|
+
class Mixin < Symbol
|
|
9
|
+
|
|
10
|
+
# Public: the type of symbols that should be encapsulated by this
|
|
11
|
+
# container. This is compared against a symbol's `symbol_type` to
|
|
12
|
+
# determine which container to use.
|
|
13
|
+
#
|
|
14
|
+
# Returns the type String.
|
|
15
|
+
|
|
16
|
+
def self.type; Docks::Types::Symbol::MIXIN end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|