From c6159090e53f3cb34fcd2bf640e37c611946f71a Mon Sep 17 00:00:00 2001 From: Lord Hepipud Date: Fri, 22 Mar 2024 11:40:27 +0100 Subject: [PATCH] Adds feature to use pipes and multi lines for plugin documentation --- doc/100-General/10-Changelog.md | 1 + .../Publish-IcingaPluginDocumentation.psm1 | 13 ++++++++++--- lib/core/tools/Get-IcingaCheckCommandConfig.psm1 | 10 +++++++++- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/doc/100-General/10-Changelog.md b/doc/100-General/10-Changelog.md index 9df028f..6f97842 100644 --- a/doc/100-General/10-Changelog.md +++ b/doc/100-General/10-Changelog.md @@ -35,6 +35,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic * [#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 * [#694](https://github.com/Icinga/icinga-powershell-framework/pull/694) Adds support for check objects not being added to summary header * [#695](https://github.com/Icinga/icinga-powershell-framework/pull/695) Adds security hardening to JEA profiles by always prohibit certain cmdlets +* [#700](https://github.com/Icinga/icinga-powershell-framework/pull/700) Adds feature to support using pipes and multi lines for plugin documentation ## 1.11.1 (2023-11-07) diff --git a/lib/core/framework/Publish-IcingaPluginDocumentation.psm1 b/lib/core/framework/Publish-IcingaPluginDocumentation.psm1 index b22f8c5..d42c6fd 100644 --- a/lib/core/framework/Publish-IcingaPluginDocumentation.psm1 +++ b/lib/core/framework/Publish-IcingaPluginDocumentation.psm1 @@ -126,10 +126,17 @@ function Publish-IcingaPluginDocumentation() foreach ($parameter in $PluginHelp.parameters.parameter) { [string]$ParamDescription = $parameter.description.Text; if ([string]::IsNullOrEmpty($ParamDescription) -eq $FALSE) { - $ParamDescription = $ParamDescription.Replace("`r`n", ' '); - $ParamDescription = $ParamDescription.Replace("`r", ' '); - $ParamDescription = $ParamDescription.Replace("`n", ' '); + $ReplacementString = '
'; + + $ParamDescription = $ParamDescription.Replace("`r`n", $ReplacementString); + $ParamDescription = $ParamDescription.Replace("`r", $ReplacementString); + $ParamDescription = $ParamDescription.Replace("`n", $ReplacementString); + + if ($ParamDescription.Contains('|')) { + $ParamDescription = $ParamDescription.Replace('|', '|'); + } } + [string]$TableContent = [string]::Format( '| {0} | {1} | {2} | {3} | {4} |', $parameter.name, diff --git a/lib/core/tools/Get-IcingaCheckCommandConfig.psm1 b/lib/core/tools/Get-IcingaCheckCommandConfig.psm1 index 7eb4c53..c558b4f 100644 --- a/lib/core/tools/Get-IcingaCheckCommandConfig.psm1 +++ b/lib/core/tools/Get-IcingaCheckCommandConfig.psm1 @@ -376,11 +376,19 @@ function Get-IcingaCheckCommandConfig() $IcingaDataType = [string]::Format('Icinga\Module\Director\DataType\DataType{0}', $IcingaDataType) if ($Basket.Datafield.Values.varname -ne $IcingaCustomVariable) { + $DataFieldDescription = $parameter.Description.Text; + + # Remove HTML code tags and replace them with markdown tags + if ([string]::IsNullOrEmpty($DataFieldDescription) -eq $FALSE) { + $DataFieldDescription = $DataFieldDescription.Replace('
', '```');
+                    $DataFieldDescription = $DataFieldDescription.Replace('
', '```'); + } + $Basket.Datafield.Add( [string]$FieldID, @{ 'varname' = $IcingaCustomVariable; 'caption' = $parameter.Name; - 'description' = $parameter.Description.Text; + 'description' = $DataFieldDescription; 'datatype' = $IcingaDataType; 'format' = $NULL; 'originalId' = [string]$FieldID;