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,68 @@
|
|
1
|
+
require_relative "base_renderer.rb"
|
2
|
+
require_relative "common_features/helperable.rb"
|
3
|
+
require_relative "common_features/capturable.rb"
|
4
|
+
|
5
|
+
module Docks
|
6
|
+
module Renderers
|
7
|
+
class ERB < Base
|
8
|
+
include Common::Helperable
|
9
|
+
include Common::Capturable
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
require "erb"
|
13
|
+
|
14
|
+
super
|
15
|
+
@locals = []
|
16
|
+
@output = ""
|
17
|
+
end
|
18
|
+
|
19
|
+
def render(template, locals = {})
|
20
|
+
first_pass = @output.length < 1
|
21
|
+
final_output, @output = @output, ""
|
22
|
+
|
23
|
+
content, layout, locals = normalize_content_and_locals(template, locals)
|
24
|
+
return if content.nil?
|
25
|
+
|
26
|
+
@locals << locals
|
27
|
+
content = ::ERB.new(content, nil, nil, "@output").result(get_binding)
|
28
|
+
return content if layout.nil?
|
29
|
+
|
30
|
+
::ERB.new(layout, nil, nil, "@output").result(get_binding { |name| name.nil? ? content : @content_blocks[name] })
|
31
|
+
|
32
|
+
ensure
|
33
|
+
@locals.pop
|
34
|
+
@output = first_pass ? "" : final_output
|
35
|
+
end
|
36
|
+
|
37
|
+
def get_binding
|
38
|
+
binding
|
39
|
+
end
|
40
|
+
|
41
|
+
def capture(*args, &block)
|
42
|
+
old_output, @output = @output, ""
|
43
|
+
yield *args
|
44
|
+
content = @output
|
45
|
+
@output = old_output
|
46
|
+
content
|
47
|
+
end
|
48
|
+
|
49
|
+
def concat(content)
|
50
|
+
@output << content
|
51
|
+
end
|
52
|
+
|
53
|
+
def method_missing(meth, *arguments, &block)
|
54
|
+
super if @locals.empty?
|
55
|
+
@locals.last.fetch(meth)
|
56
|
+
rescue KeyError
|
57
|
+
super
|
58
|
+
end
|
59
|
+
|
60
|
+
private
|
61
|
+
|
62
|
+
def clean
|
63
|
+
super
|
64
|
+
@locals = []
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require_relative "base_renderer.rb"
|
2
|
+
require_relative "common_features/helperable.rb"
|
3
|
+
require_relative "common_features/capturable.rb"
|
4
|
+
|
5
|
+
module Docks
|
6
|
+
module Renderers
|
7
|
+
class Haml < Base
|
8
|
+
include Common::Helperable
|
9
|
+
include Common::Capturable
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
require "haml"
|
13
|
+
super
|
14
|
+
end
|
15
|
+
|
16
|
+
def render(template, locals = {})
|
17
|
+
old_buffer, @haml_buffer = @haml_buffer, nil
|
18
|
+
|
19
|
+
content, layout, locals = normalize_content_and_locals(template, locals)
|
20
|
+
return if content.nil?
|
21
|
+
|
22
|
+
content = ::Haml::Engine.new(content).render(binding, locals)
|
23
|
+
return content if layout.nil?
|
24
|
+
|
25
|
+
::Haml::Engine.new(layout).render(binding, locals) do |name|
|
26
|
+
name.nil? ? content : @content_blocks[name]
|
27
|
+
end
|
28
|
+
ensure
|
29
|
+
@haml_buffer = old_buffer
|
30
|
+
end
|
31
|
+
|
32
|
+
def capture(*args, &block)
|
33
|
+
capture_haml(*args, &block)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require_relative "base_renderer.rb"
|
2
|
+
require_relative "common_features/helperable.rb"
|
3
|
+
require_relative "common_features/capturable.rb"
|
4
|
+
|
5
|
+
module Docks
|
6
|
+
module Renderers
|
7
|
+
class Slim < Base
|
8
|
+
include Common::Helperable
|
9
|
+
include Common::Capturable
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
require "slim"
|
13
|
+
super
|
14
|
+
end
|
15
|
+
|
16
|
+
def render(template, locals = {})
|
17
|
+
content, layout, locals = normalize_content_and_locals(template, locals)
|
18
|
+
return if content.nil?
|
19
|
+
|
20
|
+
content = ::Slim::Template.new { content }.render(self, locals)
|
21
|
+
return content if layout.nil?
|
22
|
+
|
23
|
+
::Slim::Template.new { layout }.render(self, locals) do |name|
|
24
|
+
name.nil? ? content : @content_blocks[name]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def capture(*args, &block)
|
29
|
+
yield *args
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require_relative "base_symbol_source.rb"
|
2
|
+
require_relative "../languages.rb"
|
3
|
+
|
4
|
+
module Docks
|
5
|
+
module SymbolSources
|
6
|
+
class JQuery < Base
|
7
|
+
def recognizes?(symbol, options = {})
|
8
|
+
language = options.fetch(:language, nil)
|
9
|
+
return false if language && Languages.file_type(language) != Types::Languages::SCRIPT
|
10
|
+
|
11
|
+
symbol.downcase == "jquery"
|
12
|
+
end
|
13
|
+
|
14
|
+
def path_for(symbol); "http://api.jquery.com/" end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require_relative "base_symbol_source.rb"
|
2
|
+
require_relative "../languages.rb"
|
3
|
+
|
4
|
+
module Docks
|
5
|
+
module SymbolSources
|
6
|
+
class MDN < Base
|
7
|
+
GLOBAL_SYMBOLS = %w(
|
8
|
+
object function boolean symbol number date string regexp map set weakmap weakset arguments undefined
|
9
|
+
error evalerror internalerror rangeerror referenceerror syntaxerror typeerror urierror
|
10
|
+
array int8array uint8array uint8clampedarray int16array uint16array int32array uint32array float32array float64array
|
11
|
+
promise generator generatorfunction proxy iterator
|
12
|
+
)
|
13
|
+
|
14
|
+
WEB_API_SYMBOLS = %w(
|
15
|
+
abstractworker analysernode animationevent animationplayer apps.mgmt arraybufferview attr audiobuffer audiobuffersourcenode audiochannelmanager audiocontext audiodestinationnode audiolistener audionode audioparam audioprocessingevent batterymanager beforeinstallpromptevent beforeunloadevent biquadfilternode blob blobbuilder blobevent bluetoothadapter bluetoothdevice bluetoothdeviceevent bluetoothmanager bluetoothstatuschangedevent body broadcastchannel bytestring cdatasection css cssconditionrule csscounterstylerule cssgroupingrule csskeyframerule csskeyframesrule cssmatrix cssmediarule cssnamespacerule csspagerule cssrule cssrulelist cssstyledeclaration cssstylerule cssstylesheet csssupportsrule cache cachestorage callevent cameracapabilities cameracontrol cameramanager canvasgradient canvasimagesource canvaspattern canvasrenderingcontext2d caretposition channelmergernode channelsplitternode characterdata childnode chromeworker client clients clipboardevent closeevent comment compositionevent connection console contactmanager convolvernode coordinates crypto cryptokey customevent domapplication domapplicationsmanager domapplicationsregistry domconfiguration domcursor domerror domerrorhandler domexception domhighrestimestamp domimplementation domimplementationlist domimplementationregistry domimplementationsource domlocator dommatrix dommatrixreadonly domobject domparser dompoint dompointreadonly domrect domrectreadonly domrequest domstring domstringlist domstringmap domtimestamp domtokenlist domuserdata datastore datastorechangeevent datastorecursor datastoretask datatransfer dedicatedworkerglobalscope delaynode deviceacceleration devicelightevent devicemotionevent deviceorientationevent deviceproximityevent devicerotationrate devicestorage devicestoragechangeevent directoryentry directoryentrysync directoryreader directoryreadersync document documentfragment documenttouch documenttype dragevent dynamicscompressornode element elementtraversal encryptedmediaextensions api entity entityreference entry entrysync errorevent event eventlistener eventsource eventtarget extendableevent fmradio fetchevent file fileentry fileentrysync fileerror fileexception filehandle filelist filereader filereadersync filerequest filesystem filesystemsync focusevent formdata gainnode gamepad gamepadbutton gamepadevent geolocation globaleventhandlers globalfetch hmdvrdevice htmlanchorelement htmlareaelement htmlaudioelement htmlbrelement htmlbaseelement htmlbasefontelement htmlbodyelement htmlbuttonelement htmlcanvaselement htmlcollection htmlcontentelement htmldlistelement htmldataelement htmldatalistelement htmldialogelement htmldivelement htmldocument htmlelement htmlembedelement htmlfieldsetelement htmlformcontrolscollection htmlformelement htmlframesetelement htmlhrelement htmlheadelement htmlheadingelement htmlhtmlelement htmliframeelement htmlimageelement htmlinputelement htmlisindexelement htmlkeygenelement htmllielement htmllabelelement htmllegendelement htmllinkelement htmlmapelement htmlmediaelement htmlmetaelement htmlmeterelement htmlmodelement htmlolistelement htmlobjectelement htmloptgroupelement htmloptionelement htmloptionscollection htmloutputelement htmlparagraphelement htmlparamelement htmlpictureelement htmlpreelement htmlprogresselement htmlquoteelement htmlscriptelement htmlselectelement htmlshadowelement htmlsourceelement htmlspanelement htmlstyleelement htmltablecaptionelement htmltablecellelement htmltablecolelement htmltabledatacellelement htmltableelement htmltableheadercellelement htmltablerowelement htmltablesectionelement htmltextareaelement htmltimeelement htmltitleelement htmltrackelement htmlulistelement htmlunknownelement htmlvideoelement hashchangeevent headers history idbcursor idbcursorsync idbcursorwithvalue idbdatabase idbdatabaseexception idbdatabasesync idbenvironment idbenvironmentsync idbfactory idbfactorysync idbindex idbindexsync idbkeyrange idbobjectstore idbobjectstoresync idbopendbrequest idbrequest idbtransaction idbtransactionsync idbversionchangeevent idbversionchangerequest identitymanager imagedata index inputevent installevent keyboardevent l10n.formatvalue l10n.get l10n.language.code l10n.language.direction l10n.once l10n.ready l10n.readystate l10n.setattributes linkstyle localfilesystem localfilesystemsync localmediastream location lockedfile midiaccess midiconnectionevent midiinput midiinputmap mediadevices mediaelementaudiosourcenode mediakeymessageevent mediakeysession mediakeystatusmap mediakeysystemaccess mediakeysystemconfiguration mediakeys mediaquerylist mediaquerylistlistener mediarecorder mediasource mediastream mediastreamaudiodestinationnode mediastreamaudiosourcenode mediastreamevent mediastreamtrack messagechannel messageevent messageport mouseevent mousescrollevent mousewheelevent mozactivity mozactivityoptions mozactivityrequesthandler mozalarmsmanager mozcontact mozcontactchangeevent moziccmanager mozmmsevent mozmmsmessage mozmobilecfinfo mozmobilecellinfo mozmobileconnection mozmobileconnectioninfo mozmobileiccinfo mozmobilemessagemanager mozmobilemessagethread mozmobilenetworkinfo mozndefrecord moznfc moznfcpeer moznfctag moznetworkstats moznetworkstatsdata moznetworkstatsmanager mozsettingsevent mozsmsevent mozsmsfilter mozsmsmanager mozsmsmessage mozsmssegmentinfo mozsocial moztimemanager mozvoicemail mozvoicemailevent mozvoicemailstatus mozwificonnectioninfoevent mozwifip2pgroupowner mozwifip2pmanager mozwifistatuschangeevent mutationevent mutationobserver namelist namednodemap navigator navigatorgeolocation navigatorid navigatorlanguage navigatoronline navigatorplugins networkinformation node nodefilter nodeiterator nodelist nondocumenttypechildnode notation notification notifyaudioavailableevent offlineaudiocompletionevent offlineaudiocontext oscillatornode pagetransitionevent pannernode parentnode path2d performance performancenavigation performancetiming periodicsyncevent periodicsyncmanager periodicsyncregistration periodicwave permissionsettings permissionstatus permissions plugin pluginarray point popstateevent portcollection position positionerror positionoptions positionsensorvrdevice powermanager processinginstruction progressevent promiseresolver pushevent pushmanager pushsubscription rtcconfiguration rtcdatachannel rtcdatachannelevent rtcidentityerrorevent rtcidentityevent rtcpeerconnection rtcpeerconnectioniceevent rtcsessiondescription rtcsessiondescriptioncallback radionodelist randomsource range renderingcontext request response svgaelement svgangle svganimatecolorelement svganimateelement svganimatemotionelement svganimatetransformelement svganimatedangle svganimatedboolean svganimatedenumeration svganimatedinteger svganimatedlength svganimatedlengthlist svganimatednumber svganimatednumberlist svganimatedpoints svganimatedpreserveaspectratio svganimatedrect svganimatedstring svganimatedtransformlist svganimationelement svgcircleelement svgclippathelement svgcursorelement svgdefselement svgdescelement svgelement svgellipseelement svgevent svgfilterelement svgfontelement svgfontfaceelement svgfontfaceformatelement svgfontfacenameelement svgfontfacesrcelement svgfontfaceurielement svgforeignobjectelement svggelement svgglyphelement svggradientelement svghkernelement svgimageelement svglength svglengthlist svglineelement svglineargradientelement svgmpathelement svgmaskelement svgmatrix svgmissingglyphelement svgnumber svgnumberlist svgpathelement svgpatternelement svgpoint svgpolygonelement svgpolylineelement svgpreserveaspectratio svgradialgradientelement svgrect svgrectelement svgsvgelement svgscriptelement svgsetelement svgstopelement svgstringlist svgstylable svgstyleelement svgswitchelement svgsymbolelement svgtrefelement svgtspanelement svgtests svgtextelement svgtextpositioningelement svgtitleelement svgtransform svgtransformlist svgtransformable svguseelement svgvkernelement svgviewelement screen scriptprocessornode selection serviceworker serviceworkercontainer serviceworkerglobalscope serviceworkerregistration settingslock settingsmanager sharedworker sharedworkerglobalscope stereopannernode storage storageevent stylesheet stylesheetlist subtlecrypto syncevent syncmanager syncregistration tcpserversocket tcpsocket telephony telephonycall text textdecoder textencoder textmetrics timeevent timeranges touch touchevent touchlist transferable transitionevent treewalker typeinfo uievent url urlsearchparams urlutils urlutilsreadonly usvstring userdatahandler userproximityevent vrdevice vreyeparameters vrfieldofview vrfieldofviewreadonly vrpositionstate validitystate videoplaybackquality waveshapernode webglrenderingcontext websocket wheelevent wifimanager window windowbase64 windowclient windoweventhandlers windoweventhandlers.onbeforeprint windowtimers worker workerglobalscope workerlocation workernavigator xdomainrequest xmldocument xmlhttprequest xmlhttprequesteventtarget
|
16
|
+
)
|
17
|
+
|
18
|
+
GLOBAL_SYMBOL_URL = "https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects"
|
19
|
+
WEB_API_SYMBOL_URL = "https://developer.mozilla.org/docs/Web/API"
|
20
|
+
|
21
|
+
def recognizes?(symbol, options = {})
|
22
|
+
language = options.fetch(:language, nil)
|
23
|
+
return false if language && Languages.file_type(language) != Types::Languages::SCRIPT
|
24
|
+
|
25
|
+
symbol = symbol.to_s.downcase
|
26
|
+
GLOBAL_SYMBOLS.include?(symbol) || WEB_API_SYMBOLS.include?(symbol)
|
27
|
+
end
|
28
|
+
|
29
|
+
def path_for(symbol)
|
30
|
+
return "#{GLOBAL_SYMBOL_URL}/#{symbol}" if GLOBAL_SYMBOLS.include?(symbol.downcase.to_s)
|
31
|
+
"#{WEB_API_SYMBOL_URL}/#{symbol}"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require_relative "base_symbol_source.rb"
|
2
|
+
require_relative "../languages.rb"
|
3
|
+
require_relative "../languages/sass_language.rb"
|
4
|
+
|
5
|
+
module Docks
|
6
|
+
module SymbolSources
|
7
|
+
class Sass < Base
|
8
|
+
VALUE_SYMBOLS = %w(arglist bool color list map null number string)
|
9
|
+
|
10
|
+
def recognizes?(symbol, options = {})
|
11
|
+
language = options.fetch(:language, nil)
|
12
|
+
return false if language && Languages.language_for(language) != Languages::Sass.instance
|
13
|
+
|
14
|
+
symbol = symbol.downcase
|
15
|
+
VALUE_SYMBOLS.include?(symbol) || symbol == "function"
|
16
|
+
end
|
17
|
+
|
18
|
+
def path_for(symbol)
|
19
|
+
if symbol.downcase == "function"
|
20
|
+
"http://sass-lang.com/documentation/Sass/Script/Script/Functions.html"
|
21
|
+
else
|
22
|
+
"http://sass-lang.com/documentation/Sass/Script/Value/#{symbol.capitalize}.html"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Docks
|
2
|
+
module SymbolSources
|
3
|
+
@sources = []
|
4
|
+
|
5
|
+
def self.register(source)
|
6
|
+
source = source.instance
|
7
|
+
@sources << source unless @sources.include?(source)
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.<<(source)
|
11
|
+
register(source)
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.path_for(symbol, options = {})
|
15
|
+
@sources.each do |source|
|
16
|
+
return source.path_for(symbol) if source.recognizes?(symbol, options)
|
17
|
+
end
|
18
|
+
|
19
|
+
nil
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def self.clear
|
25
|
+
@sources = []
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Docks
|
2
|
+
module Types
|
3
|
+
module Access
|
4
|
+
PUBLIC = "public"
|
5
|
+
PRIVATE = "private"
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
module Tags
|
10
|
+
class Access < Base
|
11
|
+
def initialize
|
12
|
+
@name = :access
|
13
|
+
@multiline = false
|
14
|
+
|
15
|
+
@access_types = Docks::Types::Access.constants.map do |const|
|
16
|
+
Docks::Types::Access.const_get(const)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def process(symbol)
|
21
|
+
symbol.update(@name) do |access|
|
22
|
+
@access_types.include?(access) ? access : Docks::Types::Access::PUBLIC
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Docks
|
2
|
+
module Tags
|
3
|
+
class ActivateWith < Base
|
4
|
+
def initialize
|
5
|
+
@name = :activate_with
|
6
|
+
@multiline = false
|
7
|
+
@multiple_allowed = true
|
8
|
+
end
|
9
|
+
|
10
|
+
def process(symbol)
|
11
|
+
symbol.update(@name) do |activate_withs|
|
12
|
+
Array(activate_withs).map { |with| split_on_commas_spaces_and_pipes(with) }.flatten
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Docks
|
2
|
+
module Tags
|
3
|
+
class Alias < Base
|
4
|
+
def initialize
|
5
|
+
@name = :alias
|
6
|
+
@multiline = false
|
7
|
+
@multiple_allowed = true
|
8
|
+
end
|
9
|
+
|
10
|
+
def process(symbol)
|
11
|
+
symbol.update(@name) do |aliases|
|
12
|
+
Array(aliases).map { |alias_line| split_on_commas_spaces_and_pipes(alias_line) }.flatten
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Docks
|
2
|
+
module Tags
|
3
|
+
class Author < Base
|
4
|
+
def initialize
|
5
|
+
@name = :author
|
6
|
+
@synonyms = [:contributor]
|
7
|
+
@multiple_allowed = true
|
8
|
+
@multiline = false
|
9
|
+
end
|
10
|
+
|
11
|
+
def process(symbol)
|
12
|
+
symbol.update(@name) do |authors|
|
13
|
+
authors = Array(authors).map { |author| split_on_top_level_parens_commas_and_pipes(author) }.flatten
|
14
|
+
authors.map { |author| OpenStruct.new name_and_parenthetical(author, :name, :email) }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require_relative "../processors.rb"
|
2
|
+
|
3
|
+
module Docks
|
4
|
+
module Tags
|
5
|
+
|
6
|
+
# Public: The base tag from which bundled and custom tags can inherit.
|
7
|
+
|
8
|
+
class Base
|
9
|
+
include Singleton
|
10
|
+
include Processors
|
11
|
+
|
12
|
+
attr_reader :name
|
13
|
+
|
14
|
+
def multiline?
|
15
|
+
@multiline = true if @multiline.nil?
|
16
|
+
@multiline
|
17
|
+
end
|
18
|
+
|
19
|
+
def multiple_allowed?
|
20
|
+
@multiple_allowed = false if @multiple_allowed.nil?
|
21
|
+
@multiple_allowed
|
22
|
+
end
|
23
|
+
|
24
|
+
def type
|
25
|
+
@type ||= Docks::Types::Tags::ONE_PER_BLOCK
|
26
|
+
end
|
27
|
+
|
28
|
+
def parseable?
|
29
|
+
@parseable = true if @parseable.nil?
|
30
|
+
@parseable
|
31
|
+
end
|
32
|
+
|
33
|
+
def synonyms
|
34
|
+
@synonyms ||= []
|
35
|
+
end
|
36
|
+
|
37
|
+
def process(symbol); symbol end
|
38
|
+
|
39
|
+
def setup_post_processors; end
|
40
|
+
|
41
|
+
protected
|
42
|
+
|
43
|
+
def after_each_pattern(hook = nil, &block)
|
44
|
+
Process.register_pattern_processor(hook, &block)
|
45
|
+
end
|
46
|
+
|
47
|
+
def after_all(hook = nil, &block)
|
48
|
+
Process.register_pattern_library_processor(hook, &block)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Docks
|
2
|
+
module Tags
|
3
|
+
class Beta < Base
|
4
|
+
def initialize
|
5
|
+
@name = :beta
|
6
|
+
@synonyms = [:experimental]
|
7
|
+
end
|
8
|
+
|
9
|
+
def process(symbol)
|
10
|
+
symbol.update(@name) do |beta|
|
11
|
+
beta = multiline_description(beta) do |first_line|
|
12
|
+
if match = first_line.match(/\s*(?<version>.*?)(?:\s+\-\s+(?<description>.*))?$/)
|
13
|
+
description = match[:description]
|
14
|
+
{
|
15
|
+
version: match[:version],
|
16
|
+
description: description.nil? || description.length == 0 ? nil : match[:description]
|
17
|
+
}
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
OpenStruct.new(beta)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Docks
|
2
|
+
module Tags
|
3
|
+
class Klass < Base
|
4
|
+
def initialize
|
5
|
+
@name = :class
|
6
|
+
@multiline = false
|
7
|
+
end
|
8
|
+
|
9
|
+
def process(symbol)
|
10
|
+
symbol.symbol_type = Types::Symbol::CLASS
|
11
|
+
symbol[@name] = true
|
12
|
+
Containers::Klass.from_symbol(symbol)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Docks
|
2
|
+
module Tags
|
3
|
+
class Compatibility < Base
|
4
|
+
def initialize
|
5
|
+
@name = :compatibility
|
6
|
+
@synonyms = [:compatible_with, :support]
|
7
|
+
@multiline = false
|
8
|
+
@multiple_allowed = true
|
9
|
+
end
|
10
|
+
|
11
|
+
def process(symbol)
|
12
|
+
symbol.update(@name) do |compatibilities|
|
13
|
+
compatibilities = Array(compatibilities).map { |compatibility| split_on_top_level_parens_commas_and_pipes(compatibility) }.flatten
|
14
|
+
compatibilities.map { |compatibility| OpenStruct.new name_and_parenthetical(compatibility, :browser, :version) }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Docks
|
2
|
+
module Tags
|
3
|
+
class Deprecated < Base
|
4
|
+
def initialize
|
5
|
+
@name = :deprecated
|
6
|
+
@synonyms = [:deprecation]
|
7
|
+
end
|
8
|
+
|
9
|
+
def process(symbol)
|
10
|
+
symbol.update(@name) do |deprecated|
|
11
|
+
deprecated = multiline_description(deprecated) do |first_line|
|
12
|
+
if match = first_line.match(/\s*(?<version>.*?)(?:\s+\-\s+(?<description>.*))?$/)
|
13
|
+
description = match[:description]
|
14
|
+
{
|
15
|
+
version: match[:version],
|
16
|
+
description: description.nil? || description.length == 0 ? nil : match[:description]
|
17
|
+
}
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
OpenStruct.new(deprecated)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
require "redcarpet"
|
2
|
+
require_relative "../markdown.rb"
|
3
|
+
|
4
|
+
module Docks
|
5
|
+
module Tags
|
6
|
+
class Description < Base
|
7
|
+
def initialize
|
8
|
+
@name = :description
|
9
|
+
@markdown = Redcarpet::Markdown.new(Markdown::Renderer, fenced_code_blocks: true)
|
10
|
+
end
|
11
|
+
|
12
|
+
def process(symbol)
|
13
|
+
symbol.update(@name) { |description| join_with_smart_line_breaks(description) }
|
14
|
+
end
|
15
|
+
|
16
|
+
def setup_post_processors
|
17
|
+
after_each_pattern(:late) do |pattern|
|
18
|
+
associate_external_description_files(pattern)
|
19
|
+
recursive_markdown_description(pattern)
|
20
|
+
pattern.symbols.each { |symbol| recursive_markdown_description(symbol) }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
protected
|
25
|
+
|
26
|
+
def recursive_markdown_description(symbol)
|
27
|
+
return unless symbol.respond_to?(:description)
|
28
|
+
description = symbol.description
|
29
|
+
|
30
|
+
if description.nil? || description.strip.empty?
|
31
|
+
symbol.description = nil
|
32
|
+
else
|
33
|
+
symbol.description = @markdown.render(description)
|
34
|
+
end
|
35
|
+
|
36
|
+
return unless symbol.respond_to?(:each)
|
37
|
+
symbol.each do |tag, value|
|
38
|
+
if value.kind_of?(Array)
|
39
|
+
value.each { |item| recursive_markdown_description(item) }
|
40
|
+
else
|
41
|
+
recursive_markdown_description(value)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
if symbol.respond_to?(:members)
|
46
|
+
symbol.members.each { |member| recursive_markdown_description(member) }
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def associate_external_description_files(pattern)
|
51
|
+
description_file = pattern.files.find { |file| Languages.file_type(file) == Types::Languages::DESCRIPTION }
|
52
|
+
return if description_file.nil?
|
53
|
+
|
54
|
+
description = File.read(description_file)
|
55
|
+
remaining_description = slice_up_description_for_symbols(description, pattern.symbols)
|
56
|
+
pattern.description ||= remaining_description
|
57
|
+
end
|
58
|
+
|
59
|
+
def smart_description_association(symbol, description)
|
60
|
+
case symbol
|
61
|
+
when Containers::Component
|
62
|
+
remaining_description = slice_up_description_for_symbols(description, symbol.fetch(:states, []) + symbol.fetch(:variants, []))
|
63
|
+
symbol.description ||= remaining_description
|
64
|
+
|
65
|
+
when Containers::Function
|
66
|
+
remaining_description = slice_up_description_for_symbols(description, symbol.fetch(:params, []) + symbol.members)
|
67
|
+
symbol.description ||= remaining_description
|
68
|
+
|
69
|
+
when Containers::Symbol
|
70
|
+
remaining_description = slice_up_description_for_symbols(description, symbol.members)
|
71
|
+
symbol.description ||= remaining_description
|
72
|
+
|
73
|
+
else
|
74
|
+
symbol.description = description
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def slice_up_description_for_symbols(description, symbols)
|
79
|
+
earliest_other_description_start = description.length
|
80
|
+
|
81
|
+
symbols.each do |symbol|
|
82
|
+
next unless symbol.description.nil?
|
83
|
+
|
84
|
+
regex = Regexp.new("^(#+)\\s*#{Regexp.escape(symbol.name)}\\s*$", Regexp::MULTILINE)
|
85
|
+
if match = regex.match(description)
|
86
|
+
next_matched_heading = Regexp.new("^#\{1,#{match[1].length}} [^#]", Regexp::MULTILINE).match(description, match.offset(1)[1])
|
87
|
+
next_matched_heading_position = next_matched_heading.nil? ? description.length : next_matched_heading.offset(0)[0] - 1
|
88
|
+
|
89
|
+
description_range = match.offset(0)[1]..next_matched_heading_position
|
90
|
+
smart_description_association(symbol, description[description_range].strip)
|
91
|
+
earliest_other_description_start = [earliest_other_description_start, description_range.first - match[0].length - 1].min
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
description[0..earliest_other_description_start].strip
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Docks
|
2
|
+
module Tags
|
3
|
+
class Example < Base
|
4
|
+
def initialize
|
5
|
+
@name = :example
|
6
|
+
@multiple_allowed = true
|
7
|
+
end
|
8
|
+
|
9
|
+
def process(symbol)
|
10
|
+
symbol.update(@name) do |examples|
|
11
|
+
examples.map do |example|
|
12
|
+
example = code_block_with_language_and_description(example)
|
13
|
+
example[:language] ||= Docks::Languages.extension_for_file(Docks.current_file)
|
14
|
+
OpenStruct.new(example)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Docks
|
2
|
+
module Tags
|
3
|
+
class Factory < Base
|
4
|
+
def initialize
|
5
|
+
@name = :factory
|
6
|
+
@multiline = false
|
7
|
+
end
|
8
|
+
|
9
|
+
def process(symbol)
|
10
|
+
symbol[@name] = true
|
11
|
+
symbol.symbol_type = Types::Symbol::FACTORY
|
12
|
+
Containers::Factory.from_symbol(symbol)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|