Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

## Unreleased

What's changed since pre-release v0.9.0-B2107010:

- Bug fixes:
- Fixed failed to get document definitions with selectors. [#174](https://github.com/Microsoft/PSDocs/issues/174)
- Fixed PowerShell command completion `Document` keyword. [#175](https://github.com/Microsoft/PSDocs/issues/175)

## v0.9.0-B2107010 (pre-release)

What's changed since pre-release v0.9.0-B2107002:
Expand Down
2 changes: 1 addition & 1 deletion src/PSDocs/PSDocs.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ function Document {
[ScriptBlock]$If,

[Parameter(Mandatory = $False)]
[String[]]$When
[String[]]$With
)
begin {
# This is just a stub to improve authoring and discovery
Expand Down
1 change: 1 addition & 0 deletions src/PSDocs/Pipeline/GetPipeline.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ internal GetPipeline(PipelineContext context, Source[] source)
: base(context, source)
{
_Runspace = new RunspaceContext(Context);
HostHelper.ImportResource(Source, _Runspace);
}

public override void End()
Expand Down
20 changes: 19 additions & 1 deletion tests/PSDocs.Tests/PSDocs.Selector.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,32 @@ Describe 'PSDocs selectors' -Tag 'Selector' {
$docFilePath = Join-Path -Path $here -ChildPath 'FromFile.Selector.Doc.ps1';
$selectorFilePath = Join-Path -Path $here -ChildPath 'Selectors.Doc.yaml';

Context 'With -InputObject' {
Context 'Invoke definitions' {
$invokeParams = @{
Path = @($docFilePath, $selectorFilePath)
}

It 'Generates documentation for matching objects' {
$result = @($dummyObject | Invoke-PSDocument @invokeParams -Name 'Selector.WithInputObject' -PassThru);
$result | Should -Not -BeNullOrEmpty;
$result | Should -Not -Be 'Name: HashName';
}
}

Context 'Get definitions' {
It 'With selector' {
$getParams = @{
Path = @($docFilePath, $selectorFilePath)
}
$result = @(Get-PSDocument @getParams)
$result | Should -Not -BeNullOrEmpty;
}

It 'Missing selector' {
$getParams = @{
Path = @($docFilePath)
}
{ Get-PSDocument @getParams -ErrorAction Stop } | Should -Throw -ErrorId 'PSDocs.Parse.SelectorNotFound';
}
}
}
13 changes: 13 additions & 0 deletions tests/PSDocs.Tests/TestModule/docs/Selector.Doc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

---
# Synopsis: A selector for unit testing.
apiVersion: github.com/microsoft/PSDocs/v1
kind: Selector
metadata:
name: AlwaysTrue
spec:
if:
field: '__not_value__'
exists: false
2 changes: 1 addition & 1 deletion tests/PSDocs.Tests/TestModule/docs/Test.Doc.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ Document 'TestDocument1' {
"Culture=$($LocalizedData.Culture)";
}

Document 'TestDocument2' {
Document 'TestDocument2' -With 'AlwaysTrue' {

}