Module: Lookbook

Defined in:
lib/lookbook.rb,
lib/lookbook/lang.rb,
lib/lookbook/error.rb,
lib/lookbook/param.rb,
lib/lookbook/theme.rb,
lib/lookbook/engine.rb,
lib/lookbook/process.rb,
lib/lookbook/version.rb,
lib/lookbook/features.rb,
lib/lookbook/websocket.rb,
lib/lookbook/tags/id_tag.rb,
lib/lookbook/file_watcher.rb,
lib/lookbook/entities/page.rb,
lib/lookbook/support/store.rb,
lib/lookbook/tags/yard_tag.rb,
lib/lookbook/preview_parser.rb,
lib/lookbook/tags/label_tag.rb,
lib/lookbook/tags/param_tag.rb,
lib/lookbook/entities/entity.rb,
lib/lookbook/preview_actions.rb,
lib/lookbook/support/service.rb,
lib/lookbook/tags/custom_tag.rb,
lib/lookbook/tags/hidden_tag.rb,
lib/lookbook/tags/source_tag.rb,
lib/lookbook/entities/preview.rb,
lib/lookbook/rendered_example.rb,
lib/lookbook/stores/tag_store.rb,
lib/lookbook/tags/display_tag.rb,
lib/lookbook/stores/hook_store.rb,
lib/lookbook/support/tree_node.rb,
lib/lookbook/tags/position_tag.rb,
lib/lookbook/tags/tag_provider.rb,
lib/lookbook/entities/component.rb,
lib/lookbook/stores/input_store.rb,
lib/lookbook/stores/panel_store.rb,
lib/lookbook/tags/component_tag.rb,
app/channels/lookbook/connection.rb,
app/helpers/lookbook/page_helper.rb,
lib/lookbook/stores/config_store.rb,
lib/lookbook/support/null_object.rb,
lib/lookbook/support/utils/utils.rb,
app/helpers/lookbook/output_helper.rb,
lib/lookbook/entities/page_section.rb,
lib/lookbook/tags/logical_path_tag.rb,
app/helpers/lookbook/preview_helper.rb,
lib/lookbook/entities/preview_group.rb,
lib/lookbook/services/config_loader.rb,
app/channels/lookbook/reload_channel.rb,
app/components/lookbook/nav/component.rb,
app/components/lookbook/tag_component.rb,
app/helpers/lookbook/component_helper.rb,
lib/lookbook/entities/preview_example.rb,
lib/lookbook/support/utils/path_utils.rb,
app/components/lookbook/base_component.rb,
app/components/lookbook/code/component.rb,
app/components/lookbook/icon/component.rb,
app/components/lookbook/tabs/component.rb,
app/components/lookbook/embed/component.rb,
app/components/lookbook/prose/component.rb,
app/helpers/lookbook/application_helper.rb,
lib/lookbook/services/markdown_renderer.rb,
app/components/lookbook/button/component.rb,
app/components/lookbook/filter/component.rb,
app/components/lookbook/header/component.rb,
app/controllers/lookbook/page_controller.rb,
lib/lookbook/entities/concerns/locatable.rb,
lib/lookbook/entities/concerns/navigable.rb,
lib/lookbook/services/code/code_indenter.rb,
lib/lookbook/support/errors/config_error.rb,
lib/lookbook/support/errors/parser_error.rb,
app/components/lookbook/toolbar/component.rb,
app/controllers/lookbook/pages_controller.rb,
lib/lookbook/services/string_value_caster.rb,
app/components/lookbook/nav/item/component.rb,
app/components/lookbook/tabs/tab/component.rb,
app/components/lookbook/viewport/component.rb,
lib/lookbook/entities/concerns/annotatable.rb,
lib/lookbook/entities/concerns/inspectable.rb,
lib/lookbook/services/code/code_beautifier.rb,
lib/lookbook/support/errors/lookbook_error.rb,
app/components/lookbook/page_tabs/component.rb,
lib/lookbook/services/code/code_highlighter.rb,
app/components/lookbook/debug_menu/component.rb,
app/components/lookbook/nav/entity/component.rb,
app/components/lookbook/tab_panels/component.rb,
app/controllers/lookbook/previews_controller.rb,
lib/lookbook/services/position_prefix_parser.rb,
app/components/lookbook/copy_button/component.rb,
app/controllers/lookbook/inspector_controller.rb,
lib/lookbook/services/tags/tag_options_parser.rb,
app/components/lookbook/button_group/component.rb,
app/components/lookbook/params/field/component.rb,
app/components/lookbook/split_layout/component.rb,
lib/lookbook/services/data/parsers/data_parser.rb,
lib/lookbook/services/data/parsers/json_parser.rb,
lib/lookbook/services/data/parsers/yaml_parser.rb,
lib/lookbook/services/urls/search_param_parser.rb,
app/components/lookbook/nav/directory/component.rb,
app/components/lookbook/params/editor/component.rb,
app/controllers/lookbook/application_controller.rb,
lib/lookbook/services/tags/key_value_tag_parser.rb,
lib/lookbook/services/urls/search_param_builder.rb,
lib/lookbook/services/templates/styles_extractor.rb,
app/components/lookbook/inspector_panel/component.rb,
lib/lookbook/entities/collections/page_collection.rb,
app/components/lookbook/tab_panels/panel/component.rb,
lib/lookbook/services/data/resolvers/data_resolver.rb,
lib/lookbook/services/data/resolvers/eval_resolver.rb,
lib/lookbook/services/data/resolvers/file_resolver.rb,
lib/lookbook/services/data/resolvers/yaml_resolver.rb,
lib/lookbook/services/entities/entity_tree_builder.rb,
app/components/lookbook/tabs/dropdown_tab/component.rb,
lib/lookbook/entities/collections/entity_collection.rb,
app/components/lookbook/dimensions_display/component.rb,
app/controllers/concerns/lookbook/targetable_concern.rb,
lib/lookbook/entities/collections/preview_collection.rb,
lib/lookbook/services/data/resolvers/method_resolver.rb,
lib/lookbook/services/templates/frontmatter_extractor.rb,
lib/lookbook/entities/collections/component_collection.rb,
app/components/lookbook/display_options/field/component.rb,
app/components/lookbook/display_options/editor/component.rb,
lib/lookbook/entities/collections/preview_example_collection.rb,
lib/lookbook/services/templates/action_view_annotations_handler.rb,
lib/lookbook/services/templates/action_view_annotations_stripper.rb,
app/controllers/concerns/lookbook/with_preview_controller_concern.rb,
lib/lookbook/entities/collections/concerns/hierarchical_collection.rb

Defined Under Namespace

Modules: Annotatable, ApplicationHelper, ComponentHelper, DisplayOptions, Features, HierarchicalCollection, Inspectable, Lang, Locatable, Navigable, OutputHelper, PageHelper, Params, PathUtils, PreviewActions, PreviewHelper, TargetableConcern, Utils, WithPreviewControllerConcern Classes: ActionViewAnnotationsHandler, ActionViewAnnotationsStripper, ApplicationController, BaseComponent, CodeBeautifier, CodeHighlighter, CodeIndenter, Component, ComponentCollection, ComponentTag, ConfigError, ConfigLoader, ConfigStore, Connection, CustomTag, DataParser, DataResolver, DisplayTag, Engine, Entity, EntityCollection, EntityTreeBuilder, Error, EvalResolver, FileResolver, FileWatcher, FrontmatterExtractor, HiddenTag, HookStore, IdTag, InputStore, InspectorController, JsonParser, KeyValueTagParser, LabelTag, LogicalPathTag, LookbookError, MarkdownRenderer, MethodResolver, NullObject, NullWebsocket, Page, PageCollection, PageController, PageSection, PagesController, PanelStore, Param, ParamTag, ParserError, PositionPrefixParser, PositionTag, Preview, PreviewCollection, PreviewExample, PreviewExampleCollection, PreviewGroup, PreviewParser, PreviewsController, Process, ReloadChannel, RenderedExample, SearchParamBuilder, SearchParamParser, Service, SourceTag, Store, StringValueCaster, StylesExtractor, TagComponent, TagOptionsParser, TagProvider, TagStore, Theme, TreeNode, Websocket, YamlParser, YamlResolver, YardTag

Constant Summary collapse

VERSION =
"1.5.5"

Class Method Summary collapse

Class Method Details

.after_change(&block) ⇒ Object



108
109
110
# File 'lib/lookbook.rb', line 108

def after_change(&block)
  Engine.hooks.add_hook(:after_change, block)
end

.after_initialize(&block) ⇒ Object



100
101
102
# File 'lib/lookbook.rb', line 100

def after_initialize(&block)
  Engine.hooks.add_hook(:after_initialize, block)
end

.amend_panel(*args) ⇒ Object



85
86
87
# File 'lib/lookbook.rb', line 85

def amend_panel(*args)
  Engine.panels.update_panel(*args)
end

.before_exit(&block) ⇒ Object



104
105
106
# File 'lib/lookbook.rb', line 104

def before_exit(&block)
  Engine.hooks.add_hook(:before_exit, block)
end

.broadcast(event_name, data = {}) ⇒ Object



69
70
71
# File 'lib/lookbook.rb', line 69

def broadcast(event_name, data = {})
  Engine.websocket&.broadcast(event_name.to_s, data)
end

.configObject



18
19
20
# File 'lib/lookbook.rb', line 18

def config
  @_config ||= ConfigStore.init_from_config
end

.configure {|config| ... } ⇒ Object

Yields:



22
23
24
# File 'lib/lookbook.rb', line 22

def configure
  yield(config)
end

.dataObject



30
31
32
# File 'lib/lookbook.rb', line 30

def data
  @_data ||= Store.new
end

.data=(new_data) ⇒ Object



34
35
36
# File 'lib/lookbook.rb', line 34

def data=(new_data)
  @_data = Store.new(new_data)
end

.debug_dataObject



48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/lookbook.rb', line 48

def debug_data
  {
    version: version,
    env: Rails.env.to_s,
    config: [
      config.to_h,
      {panels: Engine.panels.to_h},
      {inputs: Engine.inputs.to_h},
      {tags: Engine.tags.to_h}
    ].inject(:merge)
  }
end

.define_panel(name, *args) ⇒ Object



81
82
83
# File 'lib/lookbook.rb', line 81

def define_panel(name, *args)
  Engine.panels.add_panel(name, :drawer, *args)
end

.define_param_input(*args) ⇒ Object



77
78
79
# File 'lib/lookbook.rb', line 77

def define_param_input(*args)
  Engine.inputs.add_input(*args)
end

.define_tag(name, args = nil, &block) ⇒ Object



93
94
95
96
97
98
# File 'lib/lookbook.rb', line 93

def define_tag(name, args = nil, &block)
  Engine.tags.add_tag(name, {
    named_args: args.to_a,
    after_parse: block
  })
end

.engineObject



26
27
28
# File 'lib/lookbook.rb', line 26

def engine
  Engine
end

.loggerObject



38
39
40
41
42
43
44
45
46
# File 'lib/lookbook.rb', line 38

def logger
  @_logger ||= if Rails.logger.present? && config.log_use_rails_logger
    Rails.logger
  else
    logger = Logger.new($stdout)
    logger.level = config.log_level
    logger
  end
end

.pagesObject



65
66
67
# File 'lib/lookbook.rb', line 65

def pages
  Engine.pages
end

.previewsObject



61
62
63
# File 'lib/lookbook.rb', line 61

def previews
  Engine.previews
end

.remove_panel(name) ⇒ Object



89
90
91
# File 'lib/lookbook.rb', line 89

def remove_panel(name)
  Engine.panels.remove_panel(name)
end

.themeObject



73
74
75
# File 'lib/lookbook.rb', line 73

def theme
  @_theme ||= Lookbook::Theme.new(config.ui_theme, config.ui_theme_overrides)
end

.versionObject



14
15
16
# File 'lib/lookbook.rb', line 14

def version
  Lookbook::VERSION
end