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
4040 var helpItems = new HelpItems ( ) ;
4141 foreach ( var command in commandHelp )
4242 {
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+ }
4456 }
4557 return helpItems ;
4658 }
Original file line number Diff line number Diff line change @@ -112,7 +112,7 @@ Describe "Export-MamlCommandHelp tests" {
112112 }
113113
114114 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
116116 }
117117
118118 It " Should have the same content for the description" {
@@ -135,5 +135,13 @@ Describe "Export-MamlCommandHelp tests" {
135135 $mamlFie = $m | Export-MamlCommandHelp - OutputFolder $outputDirectory - Force
136136 $mamlFie | Should - FileContentMatch ' <maml:para>€</maml:para>'
137137 }
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+ }
138146 }
139147}
You can’t perform that action at this time.
0 commit comments