From 7c6219713b8777183742798ff74b5467f424f535 Mon Sep 17 00:00:00 2001 From: Philippe Perrin Date: Tue, 20 Apr 2021 17:34:56 +0200 Subject: [PATCH] SONAR-14725 Remove embedded documentation's calls to the update-center --- server/sonar-docs/README.md | 8 ++++ .../__tests__/index-test.js | 44 +++++++++++++++++++ .../sonarsource-source-filesystem/index.js | 33 +++++++++----- .../analysis/scan/sonarscanner-for-ant.md | 7 ++- .../scan/sonarscanner-for-azure-devops.md | 6 +++ .../analysis/scan/sonarscanner-for-gradle.md | 6 +++ .../analysis/scan/sonarscanner-for-jenkins.md | 6 +++ .../analysis/scan/sonarscanner-for-maven.md | 6 +++ .../analysis/scan/sonarscanner-for-msbuild.md | 8 +++- .../src/pages/analysis/scan/sonarscanner.md | 6 +++ .../js/components/docs/DocMarkdownBlock.tsx | 6 +-- .../docs/__tests__/DocMarkdownBlock-test.tsx | 10 +---- 12 files changed, 118 insertions(+), 28 deletions(-) create mode 100644 server/sonar-docs/plugins/sonarsource-source-filesystem/__tests__/index-test.js diff --git a/server/sonar-docs/README.md b/server/sonar-docs/README.md index acd52390717..22e09c69b99 100644 --- a/server/sonar-docs/README.md +++ b/server/sonar-docs/README.md @@ -156,6 +156,12 @@ this content is displayed in SonarQube and in the static website this content is displayed only in the static website + + + +this content is displayed only in the embedded documentation + + ``` You can also use these comments inline: @@ -303,6 +309,8 @@ Note that an iframe is **not** a self-closing tag. This means that the following #### Dynamic Scanner Version Info +_Only supported by the static documentation_ + You can dynamically include a scanner version block to any page, using the following special tag: ```html diff --git a/server/sonar-docs/plugins/sonarsource-source-filesystem/__tests__/index-test.js b/server/sonar-docs/plugins/sonarsource-source-filesystem/__tests__/index-test.js new file mode 100644 index 00000000000..b07fff954b1 --- /dev/null +++ b/server/sonar-docs/plugins/sonarsource-source-filesystem/__tests__/index-test.js @@ -0,0 +1,44 @@ +/* + * SonarQube + * Copyright (C) 2009-2021 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +const { cutAdditionalContent, cleanContent } = require('../index.js'); + +it('should cut additional content properly', () => { + const tag = 'special'; + const content = 'This section contains a special content.'; + expect(cutAdditionalContent(content, tag)).toBe('This section contains a .'); +}); + +it('should clean the content', () => { + const content = ` +This is a sonarcloud content to cut +This is a sonarqube content to preserve +This is an embedded content to cut +This a static content to preserve +This is a {instance} instance +`; + expect(cleanContent(content)).toBe(` + +This is a sonarqube content to preserve + +This a static content to preserve +This is a SonarQube instance +`); +}); diff --git a/server/sonar-docs/plugins/sonarsource-source-filesystem/index.js b/server/sonar-docs/plugins/sonarsource-source-filesystem/index.js index c62427f34a5..a54ae0519db 100644 --- a/server/sonar-docs/plugins/sonarsource-source-filesystem/index.js +++ b/server/sonar-docs/plugins/sonarsource-source-filesystem/index.js @@ -133,26 +133,33 @@ function loadNodeContent(fileNode) { } function loadNodeContentSync(fileNode) { - const content = processPluginOverridesIfAvailable( - fs.readFileSync(fileNode.absolutePath, 'utf-8') - ); - let newContent = cutSonarCloudContent(content); - newContent = removeRemainingContentTags(newContent); - newContent = handleIncludes(newContent, fileNode); - newContent = replaceInstanceTag(newContent); - return newContent; + let content = processPluginOverridesIfAvailable(fs.readFileSync(fileNode.absolutePath, 'utf-8')); + + content = cleanContent(content); + content = handleIncludes(content, fileNode); + + return content; +} + +function cleanContent(content) { + content = cutAdditionalContent(content, 'sonarcloud'); + content = cutAdditionalContent(content, 'embedded'); + content = removeRemainingContentTags(content); + content = replaceInstanceTag(content); + + return content; } function removeRemainingContentTags(content) { - const regexBase = ''; + const regexBase = ''; return content .replace(new RegExp(`^${regexBase}(\n|\r|\r\n|$)`, 'gm'), '') .replace(new RegExp(`${regexBase}`, 'g'), ''); } -function cutSonarCloudContent(content) { - const beginning = ''; - const ending = ''; +function cutAdditionalContent(content, tag) { + const beginning = ''; + const ending = ''; let newContent = content; let start = newContent.indexOf(beginning); @@ -191,3 +198,5 @@ function replaceInstanceTag(content) { exports.createFilePath = createFilePath; exports.createRemoteFileNode = createRemoteFileNode; exports.loadNodeContent = loadNodeContent; +exports.cleanContent = cleanContent; +exports.cutAdditionalContent = cutAdditionalContent; diff --git a/server/sonar-docs/src/pages/analysis/scan/sonarscanner-for-ant.md b/server/sonar-docs/src/pages/analysis/scan/sonarscanner-for-ant.md index bf4507c3fdd..9129c3f0945 100644 --- a/server/sonar-docs/src/pages/analysis/scan/sonarscanner-for-ant.md +++ b/server/sonar-docs/src/pages/analysis/scan/sonarscanner-for-ant.md @@ -3,13 +3,18 @@ title: SonarScanner for Ant url: /analysis/scan/sonarscanner-for-ant/ --- + + + +[[info]] +| See the [online documentation](https://redirect.sonarsource.com/doc/download-scanner-ant.html) to get more details on the latest version of the scanner and how to download it. + The SonarScanner for Ant provides a `task` to allow integration of SonarQube analysis into an Apache Ant build script. The SonarScanner for Ant is an Ant Task that is a wrapper of [SonarScanner](/analysis/scan/sonarscanner/), which works by invoking SonarScanner and passing to it all [properties](/analysis/analysis-parameters/) named following a `sonar.*` convention. This has the downside of not being very Ant-y, but the upside of providing instant availability of any new analysis parameter introduced by a new version of SonarQube. Therefore, successful use of the SonarScanner for Ant requires strict adherence to the property names shown below. - ## Using the SonarScanner for Ant Define a new sonar Ant target in your Ant build script: ``` diff --git a/server/sonar-docs/src/pages/analysis/scan/sonarscanner-for-azure-devops.md b/server/sonar-docs/src/pages/analysis/scan/sonarscanner-for-azure-devops.md index 431e7cd6e65..d95a6fb25b2 100644 --- a/server/sonar-docs/src/pages/analysis/scan/sonarscanner-for-azure-devops.md +++ b/server/sonar-docs/src/pages/analysis/scan/sonarscanner-for-azure-devops.md @@ -3,7 +3,13 @@ title: SonarScanner for Azure DevOps url: /analysis/scan/sonarscanner-for-azure-devops/ --- + + + +[[info]] +| See the [online documentation](https://redirect.sonarsource.com/doc/download-scanner-azure.html) to get more details on the latest version of the scanner and how to download it. + The [SonarScanner for Azure DevOps](https://marketplace.visualstudio.com/items?itemName=SonarSource.sonarqube) makes it easy to integrate analysis into your build pipeline. The extension allows the analysis of all languages supported by SonarQube. diff --git a/server/sonar-docs/src/pages/analysis/scan/sonarscanner-for-gradle.md b/server/sonar-docs/src/pages/analysis/scan/sonarscanner-for-gradle.md index 23bcc653a95..aa01e9a40c4 100644 --- a/server/sonar-docs/src/pages/analysis/scan/sonarscanner-for-gradle.md +++ b/server/sonar-docs/src/pages/analysis/scan/sonarscanner-for-gradle.md @@ -3,7 +3,13 @@ title: SonarScanner for Gradle url: /analysis/scan/sonarscanner-for-gradle/ --- + + + +[[info]] +| See the [online documentation](https://redirect.sonarsource.com/doc/download-scanner-gradle.html) to get more details on the latest version of the scanner and how to download it. + The SonarScanner for Gradle provides an easy way to start SonarQube analysis of a Gradle project. diff --git a/server/sonar-docs/src/pages/analysis/scan/sonarscanner-for-jenkins.md b/server/sonar-docs/src/pages/analysis/scan/sonarscanner-for-jenkins.md index 7ee272fd082..aa1e0481f37 100644 --- a/server/sonar-docs/src/pages/analysis/scan/sonarscanner-for-jenkins.md +++ b/server/sonar-docs/src/pages/analysis/scan/sonarscanner-for-jenkins.md @@ -3,7 +3,13 @@ title: SonarScanner for Jenkins url: /analysis/scan/sonarscanner-for-jenkins/ --- + + + +[[info]] +| See the [online documentation](https://redirect.sonarsource.com/doc/download-scanner-jenkins.html) to get more details on the latest version of the scanner and how to download it. + This plugin lets you centralize the configuration of SonarQube server connection details in Jenkins global configuration. diff --git a/server/sonar-docs/src/pages/analysis/scan/sonarscanner-for-maven.md b/server/sonar-docs/src/pages/analysis/scan/sonarscanner-for-maven.md index 0b02c880a30..79fa78b392b 100644 --- a/server/sonar-docs/src/pages/analysis/scan/sonarscanner-for-maven.md +++ b/server/sonar-docs/src/pages/analysis/scan/sonarscanner-for-maven.md @@ -3,7 +3,13 @@ title: SonarScanner for Maven url: /analysis/scan/sonarscanner-for-maven/ --- + + + +[[info]] +| See the [online documentation](https://redirect.sonarsource.com/doc/download-scanner-maven.html) to get more details on the latest version of the scanner and how to download it. + The SonarScanner for Maven is recommended as the default scanner for Maven projects. diff --git a/server/sonar-docs/src/pages/analysis/scan/sonarscanner-for-msbuild.md b/server/sonar-docs/src/pages/analysis/scan/sonarscanner-for-msbuild.md index e972bd48ae8..47b650509ac 100644 --- a/server/sonar-docs/src/pages/analysis/scan/sonarscanner-for-msbuild.md +++ b/server/sonar-docs/src/pages/analysis/scan/sonarscanner-for-msbuild.md @@ -4,7 +4,13 @@ title: SonarScanner for .NET --- + + + +[[info]] +| See the [online documentation](https://redirect.sonarsource.com/doc/download-scanner-msbuild.html) to get more details on the latest version of the scanner and how to download it. + @@ -17,7 +23,7 @@ title: SonarScanner for .NET [[info]] | Since version 5.0, the SonarScanner for MSBuild is now the SonarScanner for .NET. -| documentation is updated with that new name, artifacts and links will remain with the old name for now. +| Documentation is updated with that new name, artifacts and links will remain with the old name for now. The SonarScanner for .NET is the recommended way to launch an analysis for projects/solutions using MSBuild or dotnet command as a build tool. It is the result of a [collaboration between SonarSource and Microsoft](https://www.sonarqube.org/announcing-sonarqube-integration-with-msbuild-and-team-build/). diff --git a/server/sonar-docs/src/pages/analysis/scan/sonarscanner.md b/server/sonar-docs/src/pages/analysis/scan/sonarscanner.md index 16d1c2616db..50393459c60 100644 --- a/server/sonar-docs/src/pages/analysis/scan/sonarscanner.md +++ b/server/sonar-docs/src/pages/analysis/scan/sonarscanner.md @@ -3,7 +3,13 @@ title: SonarScanner url: /analysis/scan/sonarscanner/ --- + + + +[[info]] +| See the [online documentation](https://redirect.sonarsource.com/doc/download-scanner.html) to get more details on the latest version of the scanner and how to download it. + The SonarScanner is the scanner to use when there is no specific scanner for your build system. diff --git a/server/sonar-web/src/main/js/components/docs/DocMarkdownBlock.tsx b/server/sonar-web/src/main/js/components/docs/DocMarkdownBlock.tsx index 2e5420495ba..f85d262ef41 100644 --- a/server/sonar-web/src/main/js/components/docs/DocMarkdownBlock.tsx +++ b/server/sonar-web/src/main/js/components/docs/DocMarkdownBlock.tsx @@ -25,7 +25,6 @@ import rehypeSlug from 'rehype-slug'; import remark from 'remark'; import remarkCustomBlocks from 'remark-custom-blocks'; import remarkRehype from 'remark-rehype'; -import MetaData from 'sonar-ui-common/components/ui/update-center/MetaData'; import { scrollToElement } from 'sonar-ui-common/helpers/scrolling'; import DocCollapsibleBlock from './DocCollapsibleBlock'; import DocImg from './DocImg'; @@ -84,10 +83,7 @@ export default class DocMarkdownBlock extends React.PureComponent { ? withChildProps(DocTooltipLink, childProps) : withChildProps(DocLink, { onAnchorClick: this.handleAnchorClick }), // use custom img tag to render documentation images - img: DocImg, - 'update-center': ({ updatecenterkey }: { updatecenterkey: string }) => ( - - ) + img: DocImg } }); diff --git a/server/sonar-web/src/main/js/components/docs/__tests__/DocMarkdownBlock-test.tsx b/server/sonar-web/src/main/js/components/docs/__tests__/DocMarkdownBlock-test.tsx index 0ae3f768354..3cdc7fdabe2 100644 --- a/server/sonar-web/src/main/js/components/docs/__tests__/DocMarkdownBlock-test.tsx +++ b/server/sonar-web/src/main/js/components/docs/__tests__/DocMarkdownBlock-test.tsx @@ -17,9 +17,8 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -import { mount, shallow } from 'enzyme'; +import { shallow } from 'enzyme'; import * as React from 'react'; -import MetaData from 'sonar-ui-common/components/ui/update-center/MetaData'; import DocMarkdownBlock from '../DocMarkdownBlock'; const CONTENT = ` @@ -80,13 +79,6 @@ it('should render a sticky TOC if available', () => { expect(wrapper.find('DocToc').exists()).toBe(true); }); -it('should correctly render update-center tags', () => { - const wrapper = mount( - - ); - expect(wrapper.find(MetaData).length).toBe(1); -}); - function shallowRender(props: Partial = {}) { return shallow(); } -- 2.39.5