Skip to content

Commit 751e17f

Browse files
authored
Merge pull request #700 from Icinga:feature/improve_docs_with_multiline_and_pipe_support
Feature: Adds support to use pipes and multi lines for plugin documentation
2 parents 7a8a138 + c615909 commit 751e17f

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

doc/100-General/10-Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
3535
* [#693](https://github.com/Icinga/icinga-powershell-framework/pull/693) Adds new command `Restart-Icinga` to restart both, the Icinga Agent and Icinga for Windows
3636
* [#694](https://github.com/Icinga/icinga-powershell-framework/pull/694) Adds support for check objects not being added to summary header
3737
* [#695](https://github.com/Icinga/icinga-powershell-framework/pull/695) Adds security hardening to JEA profiles by always prohibit certain cmdlets
38+
* [#700](https://github.com/Icinga/icinga-powershell-framework/pull/700) Adds feature to support using pipes and multi lines for plugin documentation
3839

3940
## 1.11.1 (2023-11-07)
4041

lib/core/framework/Publish-IcingaPluginDocumentation.psm1

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,17 @@ function Publish-IcingaPluginDocumentation()
126126
foreach ($parameter in $PluginHelp.parameters.parameter) {
127127
[string]$ParamDescription = $parameter.description.Text;
128128
if ([string]::IsNullOrEmpty($ParamDescription) -eq $FALSE) {
129-
$ParamDescription = $ParamDescription.Replace("`r`n", ' ');
130-
$ParamDescription = $ParamDescription.Replace("`r", ' ');
131-
$ParamDescription = $ParamDescription.Replace("`n", ' ');
129+
$ReplacementString = '<br /> ';
130+
131+
$ParamDescription = $ParamDescription.Replace("`r`n", $ReplacementString);
132+
$ParamDescription = $ParamDescription.Replace("`r", $ReplacementString);
133+
$ParamDescription = $ParamDescription.Replace("`n", $ReplacementString);
134+
135+
if ($ParamDescription.Contains('|')) {
136+
$ParamDescription = $ParamDescription.Replace('|', '&#124;');
137+
}
132138
}
139+
133140
[string]$TableContent = [string]::Format(
134141
'| {0} | {1} | {2} | {3} | {4} |',
135142
$parameter.name,

lib/core/tools/Get-IcingaCheckCommandConfig.psm1

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,11 +376,19 @@ function Get-IcingaCheckCommandConfig()
376376
$IcingaDataType = [string]::Format('Icinga\Module\Director\DataType\DataType{0}', $IcingaDataType)
377377

378378
if ($Basket.Datafield.Values.varname -ne $IcingaCustomVariable) {
379+
$DataFieldDescription = $parameter.Description.Text;
380+
381+
# Remove HTML code tags and replace them with markdown tags
382+
if ([string]::IsNullOrEmpty($DataFieldDescription) -eq $FALSE) {
383+
$DataFieldDescription = $DataFieldDescription.Replace('<pre>', '```');
384+
$DataFieldDescription = $DataFieldDescription.Replace('</pre>', '```');
385+
}
386+
379387
$Basket.Datafield.Add(
380388
[string]$FieldID, @{
381389
'varname' = $IcingaCustomVariable;
382390
'caption' = $parameter.Name;
383-
'description' = $parameter.Description.Text;
391+
'description' = $DataFieldDescription;
384392
'datatype' = $IcingaDataType;
385393
'format' = $NULL;
386394
'originalId' = [string]$FieldID;

0 commit comments

Comments
 (0)