diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 4bfbbd167..80f51ae84 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -10,6 +10,10 @@ nav_order: 5 ## main +* Fix API documentation and revert unnecessary change in `preview.rb`. + + *Richard Macklin* + * Initialize ViewComponent::Config with defaults before framework load. *Simon Fish* diff --git a/docs/api.md b/docs/api.md index a4a820abe..883387948 100644 --- a/docs/api.md +++ b/docs/api.md @@ -14,11 +14,6 @@ nav_order: 3 Returns the current config. -### `.config=(value)` - -Replaces the entire config. You shouldn't need to use this directly -unless you're building a `ViewComponent::Config` elsewhere. - ### `.sidecar_files(extensions)` Find sidecar files for the given extensions. @@ -160,6 +155,13 @@ Defaults to `nil`. If this is falsy, generators will use Returns the value of attribute config. +### `#current` + +Returns the current ViewComponent::Config. This is persisted against this +class so that config options remain accessible before the rest of +ViewComponent has loaded. Defaults to an instance of ViewComponent::Config +with all other documented defaults set. + ### `.default_preview_layout` A custom default layout used for the previews index page and individual diff --git a/lib/view_component/preview.rb b/lib/view_component/preview.rb index 0510f1ec6..717acbd5b 100644 --- a/lib/view_component/preview.rb +++ b/lib/view_component/preview.rb @@ -4,7 +4,7 @@ module ViewComponent # :nodoc: class Preview - include Rails.application.routes.url_helpers if defined?(Rails) && Rails.application.present? + include Rails.application.routes.url_helpers if defined?(Rails.application.routes.url_helpers) include ActionView::Helpers::TagHelper include ActionView::Helpers::AssetTagHelper extend ActiveSupport::DescendantsTracker