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:
#### 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
--- /dev/null
+/*
+ * 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
+`);
+});
}
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);
exports.createFilePath = createFilePath;
exports.createRemoteFileNode = createRemoteFileNode;
exports.loadNodeContent = loadNodeContent;
+exports.cleanContent = cleanContent;
+exports.cutAdditionalContent = cutAdditionalContent;
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:
```
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.
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.
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.
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.
---
<!-- 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 -->
[[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/).
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.
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';
? 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
}
});
* 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 = `
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} />);
}