mirror of
https://github.com/jlengrand/detekt.git
synced 2026-03-10 08:11:23 +00:00
Setup a Remark plugin to replace [detekt_version] with the current version on website (#5001)
This commit is contained in:
@@ -66,9 +66,9 @@ tasks {
|
|||||||
register("incrementMajor") { doLast { updateVersion { it.nextMajor() } } }
|
register("incrementMajor") { doLast { updateVersion { it.nextMajor() } } }
|
||||||
|
|
||||||
register<UpdateVersionInFileTask>("applyDocVersion") {
|
register<UpdateVersionInFileTask>("applyDocVersion") {
|
||||||
fileToUpdate.set(file("${rootProject.rootDir}/website/docusaurus.config.js"))
|
fileToUpdate.set(file("${rootProject.rootDir}/website/src/remark/detektVersionReplace.js"))
|
||||||
linePartToFind.set(" detektVersion:")
|
linePartToFind.set("const detektVersion = ")
|
||||||
lineTransformation.set(" detektVersion: '${Versions.DETEKT}'")
|
lineTransformation.set("const detektVersion = \"${Versions.DETEKT}\";")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
import DetektVersion from "./_detekt-version.jsx";
|
|
||||||
|
|
||||||
:::info
|
|
||||||
The latest released version of Detekt is **<DetektVersion/>**
|
|
||||||
:::
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
import React from "react";
|
|
||||||
import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
|
|
||||||
|
|
||||||
const DetektVersion = () => (
|
|
||||||
<span>{useDocusaurusContext().siteConfig.customFields.detektVersion}</span>
|
|
||||||
);
|
|
||||||
|
|
||||||
export default DetektVersion
|
|
||||||
@@ -8,7 +8,6 @@ summary:
|
|||||||
sidebar_position: 1
|
sidebar_position: 1
|
||||||
---
|
---
|
||||||
|
|
||||||
import DetektVersionBanner from "../_detekt-version-banner.mdx";
|
|
||||||
import CliOptions from "./_cli-options.md";
|
import CliOptions from "./_cli-options.md";
|
||||||
|
|
||||||
## Install the cli
|
## Install the cli
|
||||||
@@ -31,8 +30,6 @@ detekt [options]
|
|||||||
|
|
||||||
### Any OS:
|
### Any OS:
|
||||||
|
|
||||||
<DetektVersionBanner />
|
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
curl -sSLO https://github.com/detekt/detekt/releases/download/v[detekt_version]/detekt-cli-[detekt_version].zip
|
curl -sSLO https://github.com/detekt/detekt/releases/download/v[detekt_version]/detekt-cli-[detekt_version].zip
|
||||||
unzip detekt-cli-[detekt_version].zip
|
unzip detekt-cli-[detekt_version].zip
|
||||||
|
|||||||
@@ -8,8 +8,6 @@ summary:
|
|||||||
sidebar_position: 2
|
sidebar_position: 2
|
||||||
---
|
---
|
||||||
|
|
||||||
import DetektVersionBanner from "../\_detekt-version-banner.mdx";
|
|
||||||
|
|
||||||
Detekt requires **Gradle 6.1** or higher. We, however, recommend using the version of Gradle that is [listed in this table](/docs/introduction/compatibility).
|
Detekt requires **Gradle 6.1** or higher. We, however, recommend using the version of Gradle that is [listed in this table](/docs/introduction/compatibility).
|
||||||
|
|
||||||
## <a name="tasks">Available plugin tasks</a>
|
## <a name="tasks">Available plugin tasks</a>
|
||||||
@@ -64,8 +62,6 @@ Using the plugins DSL:
|
|||||||
|
|
||||||
#### Groovy DSL
|
#### Groovy DSL
|
||||||
|
|
||||||
<DetektVersionBanner/>
|
|
||||||
|
|
||||||
```groovy
|
```groovy
|
||||||
plugins {
|
plugins {
|
||||||
id "io.gitlab.arturbosch.detekt" version "[detekt_version]"
|
id "io.gitlab.arturbosch.detekt" version "[detekt_version]"
|
||||||
|
|||||||
@@ -8,13 +8,9 @@ summary:
|
|||||||
sidebar_position: 3
|
sidebar_position: 3
|
||||||
---
|
---
|
||||||
|
|
||||||
import DetektVersionBanner from "../\_detekt-version-banner.mdx";
|
|
||||||
|
|
||||||
1. Add following lines to your build.gradle file.
|
1. Add following lines to your build.gradle file.
|
||||||
2. Run `gradle detekt`
|
2. Run `gradle detekt`
|
||||||
|
|
||||||
<DetektVersionBanner/>
|
|
||||||
|
|
||||||
###### Groovy DSL
|
###### Groovy DSL
|
||||||
```groovy
|
```groovy
|
||||||
repositories {
|
repositories {
|
||||||
|
|||||||
@@ -8,13 +8,9 @@ summary:
|
|||||||
sidebar_position: 4
|
sidebar_position: 4
|
||||||
---
|
---
|
||||||
|
|
||||||
import DetektVersionBanner from "../\_detekt-version-banner.mdx";
|
|
||||||
|
|
||||||
1. Add following lines to your pom.xml.
|
1. Add following lines to your pom.xml.
|
||||||
2. Run `mvn verify` (when using the verify phase as we are doing here)
|
2. Run `mvn verify` (when using the verify phase as we are doing here)
|
||||||
|
|
||||||
<DetektVersionBanner/>
|
|
||||||
|
|
||||||
```xml
|
```xml
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
|||||||
@@ -5,8 +5,6 @@ sidebar_position: 1
|
|||||||
summary:
|
summary:
|
||||||
---
|
---
|
||||||
|
|
||||||
import DetektVersionBanner from "./\_detekt-version-banner.mdx";
|
|
||||||
|
|
||||||

|

|
||||||

|

|
||||||
|
|
||||||
@@ -26,8 +24,6 @@ import DetektVersionBanner from "./\_detekt-version-banner.mdx";
|
|||||||
|
|
||||||
Apply the following configuration to your Gradle project build file:
|
Apply the following configuration to your Gradle project build file:
|
||||||
|
|
||||||
<DetektVersionBanner/>
|
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
plugins {
|
plugins {
|
||||||
id("io.gitlab.arturbosch.detekt").version("[detekt_version]")
|
id("io.gitlab.arturbosch.detekt").version("[detekt_version]")
|
||||||
|
|||||||
@@ -5,8 +5,6 @@ keywords: [extensions, rulesets]
|
|||||||
sidebar_position: 9
|
sidebar_position: 9
|
||||||
---
|
---
|
||||||
|
|
||||||
import DetektVersionBanner from "../\_detekt-version-banner.mdx";
|
|
||||||
|
|
||||||
The following page describes how to extend detekt and how to customize it to your domain-specific needs.
|
The following page describes how to extend detekt and how to customize it to your domain-specific needs.
|
||||||
The associated **code samples** to this guide can be found in the package [detekt/detekt-sample-extensions](https://github.com/detekt/detekt/tree/main/detekt-sample-extensions).
|
The associated **code samples** to this guide can be found in the package [detekt/detekt-sample-extensions](https://github.com/detekt/detekt/tree/main/detekt-sample-extensions).
|
||||||
|
|
||||||
@@ -221,11 +219,9 @@ To enable it, we add the published dependency to `detekt` via the `detektPlugins
|
|||||||
|
|
||||||
###### Gradle (Kotlin/Groovy DSL)
|
###### Gradle (Kotlin/Groovy DSL)
|
||||||
|
|
||||||
<DetektVersionBanner/>
|
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
dependencies {
|
dependencies {
|
||||||
detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:{{ site.detekt_version }}")
|
detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:[detekt_version]")
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
const lightCodeTheme = require('prism-react-renderer/themes/github');
|
const lightCodeTheme = require('prism-react-renderer/themes/github');
|
||||||
const darkCodeTheme = require('prism-react-renderer/themes/dracula');
|
const darkCodeTheme = require('prism-react-renderer/themes/dracula');
|
||||||
|
const detektVersionReplace = require('./src/remark/detektVersionReplace');
|
||||||
|
|
||||||
/** @type {import('@docusaurus/types').Config} */
|
/** @type {import('@docusaurus/types').Config} */
|
||||||
const config = {
|
const config = {
|
||||||
@@ -25,6 +26,7 @@ const config = {
|
|||||||
docs: {
|
docs: {
|
||||||
sidebarPath: require.resolve('./sidebars.js'),
|
sidebarPath: require.resolve('./sidebars.js'),
|
||||||
editUrl: 'https://github.com/detekt/detekt/edit/main/website/',
|
editUrl: 'https://github.com/detekt/detekt/edit/main/website/',
|
||||||
|
remarkPlugins: [detektVersionReplace],
|
||||||
},
|
},
|
||||||
blog: {
|
blog: {
|
||||||
showReadingTime: true,
|
showReadingTime: true,
|
||||||
@@ -179,9 +181,6 @@ const config = {
|
|||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
||||||
customFields: {
|
|
||||||
detektVersion: '1.21.0-RC1'
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = config;
|
module.exports = config;
|
||||||
|
|||||||
19
website/src/remark/detektVersionReplace.js
Normal file
19
website/src/remark/detektVersionReplace.js
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
const visit = require("unist-util-visit");
|
||||||
|
|
||||||
|
// Remark plugin that is replacing the [detekt_version] with the latest
|
||||||
|
// released version. Please note that this field is updated automatically
|
||||||
|
// by the `:detekt-generator:generateDocumentation` task.
|
||||||
|
const detektVersion = "1.21.0-RC1";
|
||||||
|
|
||||||
|
const plugin = (options) => {
|
||||||
|
const transformer = async (ast) => {
|
||||||
|
visit(ast, "code", (node) => {
|
||||||
|
if (node.value.includes("[detekt_version]")) {
|
||||||
|
node.value = node.value.replace("[detekt_version]", detektVersion);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
return transformer;
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = plugin;
|
||||||
Reference in New Issue
Block a user