API / Entities

ScenarioEntity

Represents a preview scenario method within a preview class.

Instance Methods

Annotations

# notes → String

Any notes added to the entity. Returns the raw (unrendered) string which may contain markdown formatting.

# tag (name = nil) → Array<YardTag>

The first tag (optionally of a particular type) added to the entity.

Arguments:

name Symbol

Optional tag type to filter by

Example:

first_tag = entity.tag
first_display_tag = entity.tag(:display)
# tags (name = nil) → Array<YardTag>

All tags that have been added to the entity. Can be filtered by tag name by providing the name as an argument.

Arguments:

name Symbol

Optional tag type to filter by

Example:

all_tags = entity.tags
display_tags = entity.tags(:display)

Display options

# display_options → Hash

Display options hash.

Contains all display options defined via the @display tag merged with any globally-defined options.

Identity

# id → String

Human-readable unique scenario ID.

# label → String

Titlized name for use in navigation etc.

Can be customized using the @label tag where supported.

# name → String

Parameter-safe scenario name.

# type → Symbol

Entity type identifier. Returns :scenario for scenarios.

Paths

# lookup_path → String

Canonical reference path.

Used for generating URL paths and looking up entities.

Aliases:

#path

Render Targets

# render_target → RenderableEntity

The item (component or partial) that the scenario renders.

The render target is guessed where possible (based on the preview class name) but can also be manually specified using the @renders tag.

Example:

"This scenario renders: #{scenario.render_target.label}"

Aliases:

#component

Source

# source → String

Scenario method source code.

# source_lang → Hash

Source code language info.

Returns a Hash with name, ext & label entries.

Example:

source_lang_name = entity.lang[:name]

URLs

# inspect_path → String

The inspector URL path for this preview.

Aliases:

#url_path
# preview_path → String

The standalone preview URL path for this preview.

Visibility

# hidden? → Boolean

Whether or not the entity is hidden (i.e. hidden from navigation).

# visible? → Boolean

Whether or not the entity is visible (i.e. present in navigation).

Other

# preview → PreviewEntity

The preview that this scenario belongs to.

Aliases:

#parent

User Guide

Extending Lookbook

API

Elsewhere