Skip to content

Commit 821c024

Browse files
Fix markdown generation and module determination (#12)
- Fixed an issue where ConvertTo-MarkdownHelp would not add `blob/master` to online help URI path. Closes #10 - Fixed an issue where ConvertTo-MarkdownHelp would not create the docs folder if it did not already exist. Closes #8 - Fixed an issue where Add-ModuleQualification could not determine the module if the current workspace did not have a manifest. Closes #9 - Fixed an issue where Add-ModuleQualification would insert the wrong module and command name if multiple versions of the same module were loaded into the current session.
1 parent de7e42e commit 821c024

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

module/Public/Add-ModuleQualification.ps1

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,25 @@ function Add-ModuleQualification {
2525
GetProperty('TopLevelSessionState', $flags).
2626
GetValue($context)
2727

28-
$getCommand = { $ExecutionContext.InvokeCommand.GetCommand($commandName, 'All') }
28+
$getCommand = { $ExecutionContext.InvokeCommand.GetCommand($args[0], 'All') }
2929

3030
$null = [scriptblock].
3131
GetProperty('SessionStateInternal', $flags).
3232
SetValue($getCommand, $globalState)
3333

3434
$PSCmdlet.WriteVerbose($Strings.InferringFromSession)
3535

36-
$command = $getCommand.InvokeReturnAsIs()
36+
$command = $getCommand.InvokeReturnAsIs($commandName)
3737

3838
if ($command) { return $command }
3939

4040
$PSCmdlet.WriteVerbose($Strings.InferringFromWorkspace)
4141
try {
4242
$manifest = GetInferredManifest
4343
if (($moduleInfo = Get-Module $manifest.Name -ErrorAction Ignore)) {
44-
return $moduleInfo.Invoke(
45-
{ $ExecutionContext.SessionState.InvokeCommand.GetCommand($args[0], 'All') },
46-
$commandName)
44+
# Retrieve command info from the first returned module incase multiple versions
45+
# are loaded into the session.
46+
return $moduleInfo[0].Invoke($getCommand, $commandName)
4747
}
4848
$isExport = $manifest.FunctionsToExport -contains $commandName -or
4949
$manifest.CmdletsToExport -contains $commandName

module/Public/ConvertTo-MarkdownHelp.ps1

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@ function ConvertTo-MarkdownHelp {
2424
$docsPath,
2525
$psEditor.Workspace.Path)
2626

27-
$onlineUri = $projectUri, $normalizedDocs, ($Ast.Name + '.md') -join '/' -replace '\\', '/'
27+
$onlineUri = $projectUri,
28+
'blob/master',
29+
$normalizedDocs,
30+
($Ast.Name + '.md') -join '/' -replace '\\', '/'
2831
}
2932

3033
# Wrap this whole thing in a try/finally so we can dispose of temp files and PowerShell
@@ -85,6 +88,10 @@ function ConvertTo-MarkdownHelp {
8588

8689
Start-Sleep -Milliseconds 50
8790

91+
if (-not (Test-Path $docsPath)) {
92+
$null = New-Item $docsPath -ItemType Directory
93+
}
94+
8895
$targetMarkdownPath = '{0}\{1}.md' -f $docsPath, $Ast.Name
8996
if (-not (Test-Path $targetMarkdownPath)) {
9097
$null = New-Item $targetMarkdownPath -ItemType File

0 commit comments

Comments
 (0)