From 75710cf12962e8e9ea13a32712f314f64541365e Mon Sep 17 00:00:00 2001 From: schalkms <30376729+schalkms@users.noreply.github.com> Date: Sat, 9 Jul 2022 00:37:32 +0200 Subject: [PATCH] Improve extensions.doc format with admonitions More information can be seen in the Docusaurus doc: https://docusaurus.io/docs/next/markdown-features/admonitions --- website/docs/introduction/extensions.md | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/website/docs/introduction/extensions.md b/website/docs/introduction/extensions.md index 6d72e9e8a09..4e8097b6b26 100644 --- a/website/docs/introduction/extensions.md +++ b/website/docs/introduction/extensions.md @@ -13,9 +13,13 @@ The associated **code samples** to this guide can be found in the package [detek _detekt_ uses the `ServiceLoader` pattern to collect all instances of `RuleSetProvider` interfaces. So it is possible to define rules/rule sets and enhance _detekt_ with your own flavor. -Attention: You need a `resources/META-INF/services/io.gitlab.arturbosch.detekt.api.RuleSetProvider` file which +:::caution Attention + +You need a `resources/META-INF/services/io.gitlab.arturbosch.detekt.api.RuleSetProvider` file which has as content the fully qualified name of your `RuleSetProvider` e.g. `io.gitlab.arturbosch.detekt.sample.extensions.SampleProvider`. +::: + You can use our [GitHub template](https://github.com/detekt/detekt-custom-rule-template) to have a basic scaffolding to develop your own custom rules. Another option is to clone the provided [detekt/detekt-sample-extensions](https://github.com/detekt/detekt/tree/main/detekt-sample-extensions) project. @@ -104,9 +108,13 @@ By specifying the rule set and rule ids, _detekt_ will use the sub configuration ```val threshold = valueOrDefault("threshold", THRESHOLD)``` -Note: As of version 1.2.0 detekt now verifies if all configured properties actually exist in a configuration created by `--generate-config`. +:::note + +As of version 1.2.0 detekt now verifies if all configured properties actually exist in a configuration created by `--generate-config`. This means that by default detekt does not know about your new properties. -Therefore we need to mention them in the configuration under `config>excludes`: +Therefore we need to mention them in the configuration under `config>excludes`. + +::: ```yaml config: @@ -156,6 +164,7 @@ class NumberOfLoopsProcessor : FileProcessListener { } } ``` + To let detekt know about the new processor, we specify a `resources/META-INF/services/io.gitlab.arturbosch.detekt.api.FileProcessListener` file with the full qualify name of our processor as the content: `io.gitlab.arturbosch.detekt.sample.extensions.processors.NumberOfLoopsProcessor`. @@ -243,4 +252,4 @@ you created a pure kotlin module which has no Android dependencies. `apply plugi In detekt you can write custom rules which can manipulate your code base. For this a cli flag `--auto-correct` and the gradle plugin property `autoCorrect` exists. -Only write auto correcting code within the `Rule#withAutoCorrect()`-function. \ No newline at end of file +Only write auto correcting code within the `Rule#withAutoCorrect()`-function.