From 9b8e782381da5df8f176ca543044c45c4a4fdbae Mon Sep 17 00:00:00 2001 From: Sean Collins Date: Fri, 7 Mar 2025 13:35:38 -0700 Subject: [PATCH 1/6] Fix/improve config no_auto_register_paths docs --- content/v2.2/app/app-config.md | 3 ++- content/v2.2/app/container-and-components.md | 10 ++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/content/v2.2/app/app-config.md b/content/v2.2/app/app-config.md index 9703906c..8f78c3f7 100644 --- a/content/v2.2/app/app-config.md +++ b/content/v2.2/app/app-config.md @@ -62,7 +62,8 @@ Sets the keys for the app components to be automatically imported into each slic ### `no_auto_register_paths` -Sets an array of paths (relative to the root of the app or any slice) to be excluded from component auto-registration. Defaults to `["entities"]`. See the [containers and components guide](/v2.2/app/container-and-components) for more detail. +Sets an array of paths to be excluded from component auto-registration. Defaults to `["db", "relations", "structs", "entities"]`. Note that files in `lib/` are always excluded from auto-registration, too. These paths are all relative to the root of the app or any slice. See the [containers and components guide](/v2.2/app/container-and-components) for more detail. + ## Router diff --git a/content/v2.2/app/container-and-components.md b/content/v2.2/app/container-and-components.md index ab019d95..918c9dac 100644 --- a/content/v2.2/app/container-and-components.md +++ b/content/v2.2/app/container-and-components.md @@ -324,7 +324,7 @@ end If you have a whole class of objects that shouldn't be placed in your container, you can configure your Hanami application to exclude an entire directory from auto registration by adjusting its `no_auto_register_paths` configuration. -Here for example, the `app/structs` directory is excluded, meaning nothing in the `app/structs` directory will be registered with the container: +Here for example, the `app/values` directory is excluded, meaning nothing in the `app/values` directory will be registered with the container: ```ruby # config/app.rb @@ -333,11 +333,17 @@ require "hanami" module Bookshelf class App < Hanami::App - config.no_auto_register_paths << "structs" + config.no_auto_register_paths << "values" end end ``` +Note that the default value for `no_auto_register_paths` is `["db", "relations", "structs", "entities"]`, +so you do not need to specify those. Also, be sure to append to that list. + +These apply for the root of the application, as well within any slices. +Additionally, the `config/` directory within a slice is always excluded from auto-registration. + A third alternative for classes you do not want to be registered in your container is to place them in the `lib` directory at the root of your project. For example, this `SlackNotifier` class can be used anywhere in your application, and is not registered in the container: From 93380e69644ab0ae167b7999d72f17fec6331eaa Mon Sep 17 00:00:00 2001 From: Sean Collins Date: Fri, 7 Mar 2025 14:00:07 -0700 Subject: [PATCH 2/6] Fix order of values I wrote it the other way to prioritize which are core Hanami concepts, but I think it's better to be accurate --- content/v2.2/app/app-config.md | 2 +- content/v2.2/app/container-and-components.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/content/v2.2/app/app-config.md b/content/v2.2/app/app-config.md index 8f78c3f7..8c0b8d78 100644 --- a/content/v2.2/app/app-config.md +++ b/content/v2.2/app/app-config.md @@ -62,7 +62,7 @@ Sets the keys for the app components to be automatically imported into each slic ### `no_auto_register_paths` -Sets an array of paths to be excluded from component auto-registration. Defaults to `["db", "relations", "structs", "entities"]`. Note that files in `lib/` are always excluded from auto-registration, too. These paths are all relative to the root of the app or any slice. See the [containers and components guide](/v2.2/app/container-and-components) for more detail. +Sets an array of paths to be excluded from component auto-registration. Defaults to `["db", "entities", "relations", "structs"]`. Note that files in `lib/` are always excluded from auto-registration, too. These paths are all relative to the root of the app or any slice. See the [containers and components guide](/v2.2/app/container-and-components) for more detail. ## Router diff --git a/content/v2.2/app/container-and-components.md b/content/v2.2/app/container-and-components.md index 918c9dac..7ce04138 100644 --- a/content/v2.2/app/container-and-components.md +++ b/content/v2.2/app/container-and-components.md @@ -338,7 +338,7 @@ module Bookshelf end ``` -Note that the default value for `no_auto_register_paths` is `["db", "relations", "structs", "entities"]`, +Note that the default value for `no_auto_register_paths` is `["db", "entities", "relations", "structs"]`, so you do not need to specify those. Also, be sure to append to that list. These apply for the root of the application, as well within any slices. From ed05ca0d55767b22032c4671a5a1a33e2ab9db41 Mon Sep 17 00:00:00 2001 From: Sean Collins Date: Wed, 12 Mar 2025 14:02:03 -0600 Subject: [PATCH 3/6] Link to slices guide --- content/v2.2/app/container-and-components.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/v2.2/app/container-and-components.md b/content/v2.2/app/container-and-components.md index 7ce04138..6100028e 100644 --- a/content/v2.2/app/container-and-components.md +++ b/content/v2.2/app/container-and-components.md @@ -341,7 +341,7 @@ end Note that the default value for `no_auto_register_paths` is `["db", "entities", "relations", "structs"]`, so you do not need to specify those. Also, be sure to append to that list. -These apply for the root of the application, as well within any slices. +These apply for the root of the application, as well within any [slices](/v2.2/app/slices) Additionally, the `config/` directory within a slice is always excluded from auto-registration. A third alternative for classes you do not want to be registered in your container is to place them in the `lib` directory at the root of your project. From ac97576df2fbff73c228cd1392b27d2badf3b7cd Mon Sep 17 00:00:00 2001 From: Sean Collins Date: Wed, 12 Mar 2025 14:22:02 -0600 Subject: [PATCH 4/6] Update no_auto_register_paths guides for 2.1 --- content/v2.1/app/app-config.md | 2 +- content/v2.1/app/container-and-components.md | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/content/v2.1/app/app-config.md b/content/v2.1/app/app-config.md index 5e11674c..67f1183c 100644 --- a/content/v2.1/app/app-config.md +++ b/content/v2.1/app/app-config.md @@ -62,7 +62,7 @@ Sets the keys for the app components to be automatically imported into each slic ### `no_auto_register_paths` -Sets an array of paths (relative to the root of the app or any slice) to be excluded from component auto-registration. Defaults to `["entities"]`. See the [containers and components guide](/v2.1/app/container-and-components) for more detail. +Sets an array of paths to be excluded from component auto-registration. Defaults to `["entities"]`. Note that files in `lib/` are always excluded from auto-registration, too. These paths are all relative to the root of the app or any slice. See the [containers and components guide](/v2.1/app/container-and-components) for more detail. ## Router diff --git a/content/v2.1/app/container-and-components.md b/content/v2.1/app/container-and-components.md index 69f00aec..521abd92 100644 --- a/content/v2.1/app/container-and-components.md +++ b/content/v2.1/app/container-and-components.md @@ -324,7 +324,7 @@ end If you have a whole class of objects that shouldn't be placed in your container, you can configure your Hanami application to exclude an entire directory from auto registration by adjusting its `no_auto_register_paths` configuration. -Here for example, the `app/structs` directory is excluded, meaning nothing in the `app/structs` directory will be registered with the container: +Here for example, the `app/values` directory is excluded, meaning nothing in the `app/values` directory will be registered with the container: ```ruby # config/app.rb @@ -333,11 +333,16 @@ require "hanami" module Bookshelf class App < Hanami::App - config.no_auto_register_paths << "structs" + config.no_auto_register_paths << "values" end end ``` +The default value for `no_auto_register_paths` is `["entities"]`. + +These apply for the root of the application, as well within any [slices](/v2.1/app/slices) +Additionally, the `config/` directory within a slice is always excluded from auto-registration. + A third alternative for classes you do not want to be registered in your container is to place them in the `lib` directory at the root of your project. For example, this `SlackNotifier` class can be used anywhere in your application, and is not registered in the container: From 5eae661270620d81ac96edc4ccce737048d93064 Mon Sep 17 00:00:00 2001 From: Sean Collins Date: Wed, 12 Mar 2025 14:23:28 -0600 Subject: [PATCH 5/6] Update no_auto_register_paths guides for 2.0 --- content/v2.0/app/app-config.md | 2 +- content/v2.0/app/container-and-components.md | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/content/v2.0/app/app-config.md b/content/v2.0/app/app-config.md index a2115d50..e00ac973 100644 --- a/content/v2.0/app/app-config.md +++ b/content/v2.0/app/app-config.md @@ -62,7 +62,7 @@ Sets the keys for the app components to be automatically imported into each slic ### `no_auto_register_paths` -Sets an array of paths (relative to the root of the app or any slice) to be excluded from component auto-registration. Defaults to `["entities"]`. See the [containers and components guide](/v2.0/app/container-and-components) for more detail. +Sets an array of paths to be excluded from component auto-registration. Defaults to `["entities"]`. Note that files in `lib/` are always excluded from auto-registration, too. These paths are all relative to the root of the app or any slice. See the [containers and components guide](/v2.0/app/container-and-components) for more detail. ## Router diff --git a/content/v2.0/app/container-and-components.md b/content/v2.0/app/container-and-components.md index 62e2c255..a9b49116 100644 --- a/content/v2.0/app/container-and-components.md +++ b/content/v2.0/app/container-and-components.md @@ -324,7 +324,7 @@ end If you have a whole class of objects that shouldn't be placed in your container, you can configure your Hanami application to exclude an entire directory from auto registration by adjusting its `no_auto_register_paths` configuration. -Here for example, the `app/structs` directory is excluded, meaning nothing in the `app/structs` directory will be registered with the container: +Here for example, the `app/values` directory is excluded, meaning nothing in the `app/values` directory will be registered with the container: ```ruby # config/app.rb @@ -333,11 +333,16 @@ require "hanami" module Bookshelf class App < Hanami::App - config.no_auto_register_paths << "structs" + config.no_auto_register_paths << "values" end end ``` +The default value for `no_auto_register_paths` is `["entities"]`. + +These apply for the root of the application, as well within any [slices](/v2.0/app/slices) +Additionally, the `config/` directory within a slice is always excluded from auto-registration. + A third alternative for classes you do not want to be registered in your container is to place them in the `lib` directory at the root of your project. For example, this `SlackNotifier` class can be used anywhere in your application, and is not registered in the container: From baef2b4e5500a358eb511cc8ac153a3052feed5e Mon Sep 17 00:00:00 2001 From: Sean Collins Date: Wed, 12 Mar 2025 14:34:30 -0600 Subject: [PATCH 6/6] Add more link to slices guide --- content/v2.0/app/app-config.md | 2 +- content/v2.1/app/app-config.md | 2 +- content/v2.2/app/app-config.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/content/v2.0/app/app-config.md b/content/v2.0/app/app-config.md index e00ac973..86f6069a 100644 --- a/content/v2.0/app/app-config.md +++ b/content/v2.0/app/app-config.md @@ -62,7 +62,7 @@ Sets the keys for the app components to be automatically imported into each slic ### `no_auto_register_paths` -Sets an array of paths to be excluded from component auto-registration. Defaults to `["entities"]`. Note that files in `lib/` are always excluded from auto-registration, too. These paths are all relative to the root of the app or any slice. See the [containers and components guide](/v2.0/app/container-and-components) for more detail. +Sets an array of paths to be excluded from component auto-registration. Defaults to `["entities"]`. Note that files in `lib/` are always excluded from auto-registration, too. These paths are all relative to the root of the app or any [slice](/v2.0/app/slices). See the [containers and components guide](/v2.0/app/container-and-components) for more detail. ## Router diff --git a/content/v2.1/app/app-config.md b/content/v2.1/app/app-config.md index 67f1183c..f3f7cd47 100644 --- a/content/v2.1/app/app-config.md +++ b/content/v2.1/app/app-config.md @@ -62,7 +62,7 @@ Sets the keys for the app components to be automatically imported into each slic ### `no_auto_register_paths` -Sets an array of paths to be excluded from component auto-registration. Defaults to `["entities"]`. Note that files in `lib/` are always excluded from auto-registration, too. These paths are all relative to the root of the app or any slice. See the [containers and components guide](/v2.1/app/container-and-components) for more detail. +Sets an array of paths to be excluded from component auto-registration. Defaults to `["entities"]`. Note that files in `lib/` are always excluded from auto-registration, too. These paths are all relative to the root of the app or any [slice](/v2.1/app/slices). See the [containers and components guide](/v2.1/app/container-and-components) for more detail. ## Router diff --git a/content/v2.2/app/app-config.md b/content/v2.2/app/app-config.md index 8c0b8d78..34e5c5fc 100644 --- a/content/v2.2/app/app-config.md +++ b/content/v2.2/app/app-config.md @@ -62,7 +62,7 @@ Sets the keys for the app components to be automatically imported into each slic ### `no_auto_register_paths` -Sets an array of paths to be excluded from component auto-registration. Defaults to `["db", "entities", "relations", "structs"]`. Note that files in `lib/` are always excluded from auto-registration, too. These paths are all relative to the root of the app or any slice. See the [containers and components guide](/v2.2/app/container-and-components) for more detail. +Sets an array of paths to be excluded from component auto-registration. Defaults to `["db", "entities", "relations", "structs"]`. Note that files in `lib/` are always excluded from auto-registration, too. These paths are all relative to the root of the app or any [slice](/v2.2/app/slices). See the [containers and components guide](/v2.2/app/container-and-components) for more detail. ## Router