PreviewEntity
Represents 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)
Identity
#
id
→ String
Human-readable unique ID for the entity.
#
label
→ String
Titlized name for use in navigation etc.
Can be customized using the @label
tag where supported.
#
name
→ String
Parameter-safe entity name.
#
type
→ Symbol
Entity type identifier.
Paths
#
directory_path
→ Pathname
Full directory path for the entity file.
Aliases:
#
file_extension
→ String
Extension of the entity file.
#
file_name
(strip_ext = false)
→ String
Name of the entity file.
Includes file extension unless the strip_ext
argument is true
.
Arguments:
strip_ext
|
Boolean
|
Whether or not to remove the file extension |
#
file_path
→ Pathname
Full path to the entity file.
Aliases:
#
last_modified
→ Time
Time that the entity file was last modified.
#
lookup_path
→ String
Canonical reference path.
Used for generating URL paths and looking up entities.
Aliases:
#
relative_directory_path
→ Pathname
Relative directory path for the entity file.
Returned path is relative to the appropriate base directory (i.e. the preview directory for previews).
#
relative_file_path
→ Pathname
Relative path to the entity file.
Returned path is relative to the appropriate base directory (i.e. the preview directory for previews).
Aliases:
Render Targets
#
render_targets
→ Array<RenderableEntity>
All 'render targets' (i.e. components or partials) that are known to be rendered within the scenarios defined within this preview.
Render targets are guessed where possible (based on the preview class name)
but can also be manually specified using the @renders
tag.
Example:
"This preview renders: #{preview.render_targets.map(&:label).join(", ")}"
Aliases:
Scenarios
#
default_scenario
→ ScenarioEntity
The scenario used when a preview is rendered without explicity specifying a scenario.
Example:
default_scenario_name = preview.default_scenario.name
#
scenario
(scenario_name)
→ ScenarioEntity
Find a specific scenario by (i.e. method) name.
Arguments:
scenario_name
|
Symbol,String
|
Name of the scenario |
Example:
default_scenario_preview_path = preview.scenario(:default).preview_path
Aliases:
#
scenarios
→ Array<ScenarioEntity>
Get all scenarios defined in the preview class.
Example:
scenario_names = preview.scenarios.map(&:name)
Aliases:
#
visible_scenarios
→ Array<ScenarioEntity>
Get all scenarios defined in the preview class that
have not been hidden (by using the @hidden
tag).
Example:
visible_scenario_names = preview.visible_scenarios.map(&:name)
URLs
#
inspect_path
→ String
The inspector URL path for this preview.
Aliases:
#
preview_path
→ String
The standalone preview URL path for this preview.
Visibility
#
visible?
→ Boolean
Whether or not the entity is visible (i.e. present in navigation).
Other
#
preview_class_name
→ String
The name of the associated preview class.