Browse Source

SONAR-14725 Remove embedded documentation's calls to the update-center

tags/8.9.0.43852
Philippe Perrin 3 years ago
parent
commit
7c6219713b

+ 8
- 0
server/sonar-docs/README.md View File

@@ -156,6 +156,12 @@ this content is displayed in SonarQube and in the static website
this content is displayed only in the static website

<!-- /static -->

<!-- embedded -->

this content is displayed only in the embedded documentation

<!-- /embedded -->
```

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

+ 44
- 0
server/sonar-docs/plugins/sonarsource-source-filesystem/__tests__/index-test.js View File

@@ -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 -->special content<!-- /special -->.';
expect(cutAdditionalContent(content, tag)).toBe('This section contains a .');
});

it('should clean the content', () => {
const content = `
<!-- sonarcloud -->This is a sonarcloud content to cut<!-- /sonarcloud -->
<!-- sonarqube -->This is a sonarqube content to preserve<!-- /sonarqube -->
<!-- embedded -->This is an embedded content to cut<!-- /embedded -->
<!-- static -->This a static content to preserve<!-- /static -->
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
`);
});

+ 21
- 12
server/sonar-docs/plugins/sonarsource-source-filesystem/index.js View File

@@ -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 = '<!-- \\/?(sonarqube|sonarcloud|static) -->';
const regexBase = '<!-- \\/?(sonarqube|sonarcloud|static|embedded) -->';
return content
.replace(new RegExp(`^${regexBase}(\n|\r|\r\n|$)`, 'gm'), '')
.replace(new RegExp(`${regexBase}`, 'g'), '');
}

function cutSonarCloudContent(content) {
const beginning = '<!-- sonarcloud -->';
const ending = '<!-- /sonarcloud -->';
function cutAdditionalContent(content, tag) {
const beginning = '<!-- ' + tag + ' -->';
const ending = '<!-- /' + tag + ' -->';

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;

+ 6
- 1
server/sonar-docs/src/pages/analysis/scan/sonarscanner-for-ant.md View File

@@ -3,13 +3,18 @@ title: SonarScanner for Ant
url: /analysis/scan/sonarscanner-for-ant/
---

<!-- static -->
<update-center updatecenterkey="scannerant"></update-center>
<!-- /static -->
<!-- embedded -->
[[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.
<!-- /embedded -->

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:
```

+ 6
- 0
server/sonar-docs/src/pages/analysis/scan/sonarscanner-for-azure-devops.md View File

@@ -3,7 +3,13 @@ title: SonarScanner for Azure DevOps
url: /analysis/scan/sonarscanner-for-azure-devops/
---

<!-- static -->
<update-center updatecenterkey="scannerazure"></update-center>
<!-- /static -->
<!-- embedded -->
[[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.
<!-- /embedded -->

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.


+ 6
- 0
server/sonar-docs/src/pages/analysis/scan/sonarscanner-for-gradle.md View File

@@ -3,7 +3,13 @@ title: SonarScanner for Gradle
url: /analysis/scan/sonarscanner-for-gradle/
---

<!-- static -->
<update-center updatecenterkey="scannergradle"></update-center>
<!-- /static -->
<!-- embedded -->
[[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.
<!-- /embedded -->

The SonarScanner for Gradle provides an easy way to start SonarQube analysis of a Gradle project.


+ 6
- 0
server/sonar-docs/src/pages/analysis/scan/sonarscanner-for-jenkins.md View File

@@ -3,7 +3,13 @@ title: SonarScanner for Jenkins
url: /analysis/scan/sonarscanner-for-jenkins/
---

<!-- static -->
<update-center updatecenterkey="scannerjenkins"></update-center>
<!-- /static -->
<!-- embedded -->
[[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.
<!-- /embedded -->

This plugin lets you centralize the configuration of SonarQube server connection details in Jenkins global configuration.


+ 6
- 0
server/sonar-docs/src/pages/analysis/scan/sonarscanner-for-maven.md View File

@@ -3,7 +3,13 @@ title: SonarScanner for Maven
url: /analysis/scan/sonarscanner-for-maven/
---

<!-- static -->
<update-center updatecenterkey="scannermaven"></update-center>
<!-- /static -->
<!-- embedded -->
[[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.
<!-- /embedded -->

The SonarScanner for Maven is recommended as the default scanner for Maven projects.


+ 7
- 1
server/sonar-docs/src/pages/analysis/scan/sonarscanner-for-msbuild.md View File

@@ -4,7 +4,13 @@ title: SonarScanner for .NET
---

<!-- sonarqube -->
<!-- static -->
<update-center updatecenterkey="scannermsbuild"></update-center>
<!-- /static -->
<!-- embedded -->
[[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.
<!-- /embedded -->
<!-- /sonarqube -->

<!-- sonarcloud -->
@@ -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/).


+ 6
- 0
server/sonar-docs/src/pages/analysis/scan/sonarscanner.md View File

@@ -3,7 +3,13 @@ title: SonarScanner
url: /analysis/scan/sonarscanner/
---

<!-- static -->
<update-center updatecenterkey="scannercli"></update-center>
<!-- /static -->
<!-- embedded -->
[[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.
<!-- /embedded -->

The SonarScanner is the scanner to use when there is no specific scanner for your build system.


+ 1
- 5
server/sonar-web/src/main/js/components/docs/DocMarkdownBlock.tsx View File

@@ -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<Props> {
? withChildProps(DocTooltipLink, childProps)
: withChildProps(DocLink, { onAnchorClick: this.handleAnchorClick }),
// use custom img tag to render documentation images
img: DocImg,
'update-center': ({ updatecenterkey }: { updatecenterkey: string }) => (
<MetaData updateCenterKey={updatecenterkey} />
)
img: DocImg
}
});


+ 1
- 9
server/sonar-web/src/main/js/components/docs/__tests__/DocMarkdownBlock-test.tsx View File

@@ -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(
<DocMarkdownBlock content='<update-center updatecenterkey="abap"></update-center>' />
);
expect(wrapper.find(MetaData).length).toBe(1);
});

function shallowRender(props: Partial<DocMarkdownBlock['props']> = {}) {
return shallow(<DocMarkdownBlock content="" {...props} />);
}

Loading…
Cancel
Save