File tree Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -40,7 +40,19 @@ public static HelpItems ConvertCommandHelpToMamlHelpItems(List<CommandHelp> comm
40
40
var helpItems = new HelpItems ( ) ;
41
41
foreach ( var command in commandHelp )
42
42
{
43
- helpItems . Commands . Add ( ConvertCommandHelpToMamlCommand ( command ) ) ;
43
+ if ( command is not null )
44
+ {
45
+ var onlineHelpUri = command . Metadata ? [ "HelpUri" ] ? . ToString ( ) ;
46
+
47
+ var mamlCommand = ConvertCommandHelpToMamlCommand ( command ) ;
48
+
49
+ if ( onlineHelpUri is not null )
50
+ {
51
+ mamlCommand . RelatedLinks . Insert ( 0 , new NavigationLink { LinkText = "Online Version" , Uri = onlineHelpUri } ) ;
52
+ }
53
+
54
+ helpItems . Commands . Add ( mamlCommand ) ;
55
+ }
44
56
}
45
57
return helpItems ;
46
58
}
Original file line number Diff line number Diff line change @@ -112,7 +112,7 @@ Describe "Export-MamlCommandHelp tests" {
112
112
}
113
113
114
114
It " Should have the proper number of relatedLinks" {
115
- $xml2.SelectNodes (' //command:command' , $ns2 ).Where ({$_.details.name -eq " Get-Date" }).relatedLinks.navigationLink.Count | Should - Be 6
115
+ $xml2.SelectNodes (' //command:command' , $ns2 ).Where ({$_.details.name -eq " Get-Date" }).relatedLinks.navigationLink.Count | Should - Be 7
116
116
}
117
117
118
118
It " Should have the same content for the description" {
@@ -135,5 +135,13 @@ Describe "Export-MamlCommandHelp tests" {
135
135
$mamlFie = $m | Export-MamlCommandHelp - OutputFolder $outputDirectory - Force
136
136
$mamlFie | Should - FileContentMatch ' <maml:para>€</maml:para>'
137
137
}
138
+
139
+ It " Should have online help uri" {
140
+ $m = Import-MarkdownCommandHelp - Path (Join-Path $assetDir ' Get-Date.V2.md' )
141
+ $mamlFile = $m | Export-MamlCommandHelp - OutputFolder " $outputDirectory /helpuri" - Force
142
+ $mamlFile | Should - Exist
143
+ $maml = Get-Content - Path $mamlFile - Raw
144
+ $maml | Should - BeLike ' *<command:uri>https://learn.microsoft.com/powershell/module/microsoft.powershell.utility/get-date?view=powershell-7.4&WT.mc_id=ps-gethelp</command:uri>*'
145
+ }
138
146
}
139
147
}
You can’t perform that action at this time.
0 commit comments