Module: Lookbook
- Defined in:
- lib/lookbook.rb,
lib/lookbook/lang.rb,
lib/lookbook/param.rb,
lib/lookbook/theme.rb,
lib/lookbook/engine.rb,
lib/lookbook/preview.rb,
lib/lookbook/version.rb,
lib/lookbook/reloaders.rb,
lib/lookbook/websocket.rb,
lib/lookbook/cable/cable.rb,
lib/lookbook/tags/id_tag.rb,
lib/lookbook/file_watcher.rb,
lib/lookbook/support/store.rb,
lib/lookbook/tags/type_tag.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/runtime_context.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/cable/connection.rb,
lib/lookbook/stores/tag_store.rb,
lib/lookbook/tags/display_tag.rb,
lib/lookbook/tags/renders_tag.rb,
lib/lookbook/stores/hook_store.rb,
lib/lookbook/support/tree_node.rb,
lib/lookbook/tags/priority_tag.rb,
lib/lookbook/tags/tag_provider.rb,
lib/lookbook/stores/input_store.rb,
lib/lookbook/stores/panel_store.rb,
lib/lookbook/helpers/page_helper.rb,
lib/lookbook/stores/config_store.rb,
lib/lookbook/support/deprecation.rb,
lib/lookbook/support/null_object.rb,
lib/lookbook/support/utils/utils.rb,
lib/lookbook/support/utils/where.rb,
lib/lookbook/cable/reload_channel.rb,
lib/lookbook/entities/page_entity.rb,
lib/lookbook/preview_after_render.rb,
lib/lookbook/support/errors/error.rb,
lib/lookbook/tags/after_render_tag.rb,
lib/lookbook/tags/logical_path_tag.rb,
lib/lookbook/helpers/preview_helper.rb,
lib/lookbook/services/config_loader.rb,
lib/lookbook/services/list_resolver.rb,
lib/lookbook/support/null_websocket.rb,
lib/lookbook/entities/preview_entity.rb,
app/components/lookbook/nav/component.rb,
app/components/lookbook/tag_component.rb,
lib/lookbook/entities/scenario_entity.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/logo/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/entities/renderable_entity.rb,
lib/lookbook/helpers/class_names_helper.rb,
lib/lookbook/helpers/ui_elements_helper.rb,
lib/lookbook/preview_controller_actions.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/services/code/code_indenter.rb,
lib/lookbook/support/errors/config_error.rb,
lib/lookbook/support/errors/parser_error.rb,
app/components/lookbook/message/component.rb,
app/components/lookbook/toolbar/component.rb,
app/controllers/lookbook/pages_controller.rb,
lib/lookbook/entities/page_section_entity.rb,
lib/lookbook/services/string_value_caster.rb,
lib/lookbook/support/errors/routing_error.rb,
app/components/lookbook/nav/item/component.rb,
app/components/lookbook/tabs/tab/component.rb,
app/components/lookbook/viewport/component.rb,
app/controllers/lookbook/embeds_controller.rb,
lib/lookbook/services/code/code_beautifier.rb,
lib/lookbook/support/errors/template_error.rb,
app/components/lookbook/page_tabs/component.rb,
app/controllers/lookbook/preview_controller.rb,
lib/lookbook/entities/scenario_group_entity.rb,
lib/lookbook/services/code/code_highlighter.rb,
lib/lookbook/services/urls/data_uri_encoder.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/priority_prefix_parser.rb,
app/components/lookbook/copy_button/component.rb,
app/components/lookbook/file_source/component.rb,
app/components/lookbook/icon_button/component.rb,
app/components/lookbook/text_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/entities/rendered_scenario_entity.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/entities/concerns/locatable_entity.rb,
lib/lookbook/entities/concerns/navigable_entity.rb,
lib/lookbook/services/tags/key_value_tag_parser.rb,
lib/lookbook/services/urls/search_param_encoder.rb,
lib/lookbook/services/entities/page_tree_builder.rb,
lib/lookbook/services/templates/styles_extractor.rb,
lib/lookbook/services/urls/file_data_uri_encoder.rb,
lib/lookbook/support/evented_file_update_checker.rb,
app/components/lookbook/embed/inspector/component.rb,
app/components/lookbook/inspector_panel/component.rb,
lib/lookbook/entities/collections/page_collection.rb,
lib/lookbook/entities/concerns/annotatable_entity.rb,
lib/lookbook/entities/concerns/inspectable_entity.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/support/errors/preview_template_error.rb,
app/components/lookbook/tabs/dropdown_tab/component.rb,
lib/lookbook/entities/collections/entity_collection.rb,
lib/lookbook/services/entities/preview_tree_builder.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,
app/components/lookbook/embed_code_dropdown/component.rb,
app/controllers/concerns/lookbook/with_panels_concern.rb,
lib/lookbook/entities/collections/scenario_collection.rb,
lib/lookbook/services/templates/frontmatter_extractor.rb,
app/components/lookbook/display_options/field/component.rb,
app/components/lookbook/display_options/editor/component.rb,
lib/lookbook/entities/collections/render_target_collection.rb,
lib/lookbook/services/templates/action_view_config_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
Overview
The Lookbook application entry point.
Defined Under Namespace
Modules: AnnotatableEntity, ApplicationHelper, ClassNamesHelper, DisplayOptions, HierarchicalCollection, InspectableEntity, Lang, LocatableEntity, NavigableEntity, PageHelper, Params, PathUtils, PreviewAfterRender, PreviewControllerActions, PreviewHelper, TargetableConcern, UiElementsHelper, Utils, Where, WithPanelsConcern, WithPreviewControllerConcern Classes: ActionViewAnnotationsStripper, ActionViewConfigHandler, AfterRenderTag, ApplicationController, BaseComponent, Cable, CodeBeautifier, CodeHighlighter, CodeIndenter, ConfigError, ConfigLoader, ConfigStore, Connection, CustomTag, DataParser, DataResolver, DataUriEncoder, DisplayTag, EmbedsController, Engine, Entity, EntityCollection, Error, EvalResolver, EventedFileUpdateChecker, FileDataUriEncoder, FileResolver, FileWatcher, FrontmatterExtractor, HiddenTag, HookStore, IdTag, InputStore, InspectorController, JsonParser, KeyValueTagParser, LabelTag, ListResolver, LogicalPathTag, MarkdownRenderer, MethodResolver, NullObject, NullWebsocket, PageCollection, PageController, PageEntity, PageSectionEntity, PageTreeBuilder, PagesController, PanelStore, Param, ParamTag, ParserError, Preview, PreviewCollection, PreviewController, PreviewEntity, PreviewParser, PreviewTemplateError, PreviewTreeBuilder, PreviewsController, PriorityPrefixParser, PriorityTag, ReloadChannel, Reloaders, RenderTargetCollection, RenderableEntity, RenderedScenarioEntity, RendersTag, RoutingError, RuntimeContext, ScenarioCollection, ScenarioEntity, ScenarioGroupEntity, SearchParamEncoder, SearchParamParser, Service, SourceTag, Store, StringValueCaster, StylesExtractor, TagComponent, TagOptionsParser, TagProvider, TagStore, TemplateError, Theme, TreeNode, TypeTag, Websocket, YamlParser, YamlResolver, YardTag
Constant Summary collapse
- VERSION =
"2.3.14"- Deprecation =
::ActiveSupport::Deprecation.new("3.0", "Lookbook")
Params collapse
-
.add_input_type(name, partial_path, opts = {}) ⇒ Object
(also: define_param_input)
Add a custom
@paramtag input type.
Inspector Panels collapse
-
.add_panel(name, partial_path, opts = {}) ⇒ Object
(also: define_panel)
Add a custom inspector panel.
-
.remove_panel(name) ⇒ Object
Remove a panel from the inspector.
-
.update_panel(name, opts) ⇒ Object
(also: amend_panel)
Edit the properties of an existing inspector panel.
Custom Tags collapse
-
.add_tag(name, args = nil) {|tag| ... } ⇒ Object
(also: define_tag)
Add a custom tag.
Lifecycle Callbacks collapse
-
.after_change {|app, changes| ... } ⇒ Object
Add a callback to run when a change to a watched file occurs.
-
.after_initialize {|app| ... } ⇒ Object
Add a callback to run after app initialization.
-
.before_exit {|app| ... } ⇒ Object
Add a callback to run before Lookbook shuts down.
Class Method Summary collapse
- .broadcast(event_name, data = {}) ⇒ Object private
-
.config ⇒ ConfigStore
Provides access to the Lookbook config store.
- .configure {|config| ... } ⇒ Object private
-
.data ⇒ Store
Get the global data store instance.
-
.data=(new_data) ⇒ Store
Replace the global data store contents.
- .debug_data ⇒ Object private
- .engine ⇒ Object private
- .logger ⇒ Object private
-
.pages ⇒ Array<PageEntity>
Get an array of documentation page objects.
-
.previews ⇒ Array<PreviewEntity>
Get an array of component preview objects.
-
.version ⇒ String
Returns the installed Lookbook version.
Class Method Details
.add_input_type(name, partial_path, opts = {}) ⇒ Object Also known as: define_param_input
Add a custom @param tag input type
78 79 80 |
# File 'lib/lookbook.rb', line 78 def add_input_type(name, partial_path, opts = {}) Engine.inputs.add_input(name, partial_path, opts) end |
.add_panel(name, partial_path, opts = {}) ⇒ Object Also known as: define_panel
Add a custom inspector panel
101 102 103 |
# File 'lib/lookbook.rb', line 101 def add_panel(name, partial_path, opts = {}) Engine.panels.add_panel(name, partial_path, opts) end |
.add_tag(name, args = nil) {|tag| ... } ⇒ Object Also known as: define_tag
Add a custom tag
143 144 145 146 147 148 |
# File 'lib/lookbook.rb', line 143 def add_tag(name, args = nil, &block) Engine..add_tag(name, { named_args: args.to_a, after_parse: block }) end |
.after_change {|app, changes| ... } ⇒ Object
Add a callback to run when a change to a watched file occurs. Only called when an evented file watcher is being used to detect changes.
178 179 180 |
# File 'lib/lookbook.rb', line 178 def after_change(&block) Engine.hooks.add_hook(:after_change, block) end |
.after_initialize {|app| ... } ⇒ Object
Add a callback to run after app initialization.
162 163 164 |
# File 'lib/lookbook.rb', line 162 def after_initialize(&block) Engine.hooks.add_hook(:after_initialize, block) end |
.before_exit {|app| ... } ⇒ Object
Add a callback to run before Lookbook shuts down
169 170 171 |
# File 'lib/lookbook.rb', line 169 def before_exit(&block) Engine.hooks.add_hook(:before_exit, block) end |
.broadcast(event_name, data = {}) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
185 186 187 |
# File 'lib/lookbook.rb', line 185 def broadcast(event_name, data = {}) Engine.websocket&.broadcast(event_name.to_s, data) end |
.config ⇒ ConfigStore
Provides access to the Lookbook config store
38 39 40 |
# File 'lib/lookbook.rb', line 38 def config @_config ||= ConfigStore.init_from_config end |
.configure {|config| ... } ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
195 196 197 |
# File 'lib/lookbook.rb', line 195 def configure yield(config) end |
.data ⇒ Store
Get the global data store instance
59 60 61 |
# File 'lib/lookbook.rb', line 59 def data @_data ||= Store.new end |
.data=(new_data) ⇒ Store
Replace the global data store contents
67 68 69 |
# File 'lib/lookbook.rb', line 67 def data=(new_data) @_data = Store.new(new_data) end |
.debug_data ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 |
# File 'lib/lookbook.rb', line 211 def debug_data { version: version, env: Rails.env.to_s, config: [ config.to_h, { dependencies: { actioncable: Engine.runtime_context.actioncable_installed?, listen: Engine.runtime_context.listen_installed?, view_component: config.using_view_component } }, {panels: Engine.panels.to_h.reject { |k, v| v[:system] }}, {inputs: Engine.inputs.to_h.reject { |k, v| v[:system] }}, {tags: Engine..to_h.reject { |k, v| v[:system] }} ].inject(:merge) } end |
.engine ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
190 191 192 |
# File 'lib/lookbook.rb', line 190 def engine Engine end |
.logger ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
200 201 202 203 204 205 206 207 208 |
# File 'lib/lookbook.rb', line 200 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 |
.pages ⇒ Array<PageEntity>
Get an array of documentation page objects
52 53 54 |
# File 'lib/lookbook.rb', line 52 def pages Engine.pages.to_a end |
.previews ⇒ Array<PreviewEntity>
Get an array of component preview objects
45 46 47 |
# File 'lib/lookbook.rb', line 45 def previews Engine.previews.to_a end |
.remove_panel(name) ⇒ Object
Remove a panel from the inspector
130 131 132 |
# File 'lib/lookbook.rb', line 130 def remove_panel(name) Engine.panels.remove_panel(name) end |