From 1faa843ab778d9d1b7dd542710ebe1a4d72f126c Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 6 Oct 2025 14:05:20 +0200 Subject: [PATCH 1/2] Fix docs --- README.md | 8 ++--- tests/AST.Tests.ps1 | 72 ++++++++++++++++++------------------- tests/src/Test-Function.ps1 | 2 +- 3 files changed, 41 insertions(+), 41 deletions(-) diff --git a/README.md b/README.md index 528a5c2..0908883 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# AST +# Ast A PowerShell module for using the Abstract Syntax Tree (AST) on any PowerShell code. @@ -12,8 +12,8 @@ This uses the following external resources: To install the module from the PowerShell Gallery, you can use the following command: ```powershell -Install-PSResource -Name AST -Import-Module -Name AST +Install-PSResource -Name Ast +Import-Module -Name Ast ``` ## Usage @@ -25,7 +25,7 @@ Here is a list of example that are typical use cases for the module. This example shows how to get the function name from a script. ```powershell -Get-ASTFunctionName -Path 'Test-Me.ps1' +Get-AstFunctionName -Path 'Test-Me.ps1' Test-Me ``` diff --git a/tests/AST.Tests.ps1 b/tests/AST.Tests.ps1 index 6c1b09a..bd3aed9 100644 --- a/tests/AST.Tests.ps1 +++ b/tests/AST.Tests.ps1 @@ -1,26 +1,26 @@ #Requires -Modules @{ ModuleName = 'Pester'; RequiredVersion = '5.7.1' } Describe 'Core' { - Context "Function: 'Get-ASTScript'" { - It 'Get-ASTScript gets the script AST' { + Context "Function: 'Get-AstScript'" { + It 'Get-AstScript gets the script Ast' { $path = Join-Path $PSScriptRoot 'src\Test-Function.ps1' - $script = Get-ASTScript -Path $path + $script = Get-AstScript -Path $path $script | Should -Not -BeNullOrEmpty $script.Ast | Should -BeOfType [System.Management.Automation.Language.ScriptBlockAst] } } - Context "Function: 'Get-ASTFunction'" { - It 'Get-ASTFunction gets the function AST' { + Context "Function: 'Get-AstFunction'" { + It 'Get-AstFunction gets the function Ast' { $path = Join-Path $PSScriptRoot 'src\Test-Function.ps1' - $function = Get-ASTFunction -Path $path + $function = Get-AstFunction -Path $path $function | Should -Not -BeNullOrEmpty $function.Ast | Should -BeOfType [System.Management.Automation.Language.FunctionDefinitionAst] } } - Context "Function: 'Get-ASTCommand'" { - It 'Get-ASTCommand gets the command AST' { + Context "Function: 'Get-AstCommand'" { + It 'Get-AstCommand gets the command Ast' { $path = Join-Path $PSScriptRoot 'src\Test-Function.ps1' - $command = Get-ASTCommand -Path $path + $command = Get-AstCommand -Path $path $command | Should -Not -BeNullOrEmpty $command.Ast | Should -BeOfType [System.Management.Automation.Language.CommandAst] } @@ -28,24 +28,24 @@ Describe 'Core' { } Describe 'Functions' { - Context "Function: 'Get-ASTFunctionType'" { - It 'Get-ASTFunctionType gets the function type' { + Context "Function: 'Get-AstFunctionType'" { + It 'Get-AstFunctionType gets the function type' { $path = Join-Path $PSScriptRoot 'src\Test-Function.ps1' - $functionType = Get-ASTFunctionType -Path $path + $functionType = Get-AstFunctionType -Path $path $functionType.Type | Should -Be 'Function' } } - Context "Function: 'Get-ASTFunctionName'" { - It 'Get-ASTFunctionName gets the function name' { + Context "Function: 'Get-AstFunctionName'" { + It 'Get-AstFunctionName gets the function name' { $path = Join-Path $PSScriptRoot 'src\Test-Function.ps1' - $functionName = Get-ASTFunctionName -Path $path + $functionName = Get-AstFunctionName -Path $path $functionName | Should -Be 'Test-Function' } } - Context "Function: 'Get-ASTFunctionAlias'" { - It 'Get-ASTFunctionAlias gets the function alias' { + Context "Function: 'Get-AstFunctionAlias'" { + It 'Get-AstFunctionAlias gets the function alias' { $path = Join-Path $PSScriptRoot 'src\Test-Function.ps1' - $functionAlias = Get-ASTFunctionAlias -Path $path + $functionAlias = Get-AstFunctionAlias -Path $path $functionAlias.Alias | Should -Contain 'Test' $functionAlias.Alias | Should -Contain 'TestFunc' $functionAlias.Alias | Should -Contain 'Test-Func' @@ -54,34 +54,34 @@ Describe 'Functions' { } Describe 'Lines' { - Context 'Function: Get-ASTLineComment' { - It 'Get-ASTLineComment gets the line comment' { + Context 'Function: Get-AstLineComment' { + It 'Get-AstLineComment gets the line comment' { $line = '# This is a comment' - $line = Get-ASTLineComment -Line $line + $line = Get-AstLineComment -Line $line $line | Should -Be '# This is a comment' } - It 'Get-ASTLineComment gets the line comment without leading whitespace' { + It 'Get-AstLineComment gets the line comment without leading whitespace' { $line = ' # This is a comment' - $line = Get-ASTLineComment -Line $line + $line = Get-AstLineComment -Line $line $line | Should -Be '# This is a comment' } - It 'Get-ASTLineComment gets the line comment but not the command' { + It 'Get-AstLineComment gets the line comment but not the command' { $line = ' Get-Command # This is a comment ' - $line = Get-ASTLineComment -Line $line + $line = Get-AstLineComment -Line $line $line | Should -Be '# This is a comment ' } - It 'Get-ASTLineComment returns nothing when no comment is present' { + It 'Get-AstLineComment returns nothing when no comment is present' { $line = 'Get-Command' - $line | Get-ASTLineComment | Should -BeNullOrEmpty + $line | Get-AstLineComment | Should -BeNullOrEmpty } } } Describe 'Scripts' { - Context "Function: 'Get-ASTScriptCommands'" { - It 'Get-ASTScriptCommands gets the script commands' { + Context "Function: 'Get-AstScriptCommands'" { + It 'Get-AstScriptCommands gets the script commands' { $path = Join-Path $PSScriptRoot 'src\Test-Function.ps1' - $commands = Get-ASTScriptCommand -Path $path + $commands = Get-AstScriptCommand -Path $path $commands | Should -Not -BeNullOrEmpty $commands | Should -BeOfType [pscustomobject] $commands.Name | Should -Not -Contain 'ForEach-Object' @@ -91,9 +91,9 @@ Describe 'Scripts' { $commands.Name | Should -Not -Contain '.' $commands.Name | Should -Not -Contain '&' } - It 'Get-ASTScriptCommands gets the script commands (recursive)' { + It 'Get-AstScriptCommands gets the script commands (recursive)' { $path = Join-Path $PSScriptRoot 'src\Test-Function.ps1' - $commands = Get-ASTScriptCommand -Path $path -Recurse + $commands = Get-AstScriptCommand -Path $path -Recurse $commands | Should -Not -BeNullOrEmpty $commands | Should -BeOfType [pscustomobject] $commands.Name | Should -Contain 'ForEach-Object' @@ -103,9 +103,9 @@ Describe 'Scripts' { $commands.Name | Should -Not -Contain '.' $commands.Name | Should -Not -Contain '&' } - It 'Get-ASTScriptCommands gets the script commands with call operators' { + It 'Get-AstScriptCommands gets the script commands with call operators' { $path = Join-Path $PSScriptRoot 'src\Test-Function.ps1' - $commands = Get-ASTScriptCommand -Path $path -IncludeCallOperators + $commands = Get-AstScriptCommand -Path $path -IncludeCallOperators $commands | Should -Not -BeNullOrEmpty $commands | Should -BeOfType [pscustomobject] $commands.Name | Should -Not -Contain 'ForEach-Object' @@ -115,9 +115,9 @@ Describe 'Scripts' { $commands.Name | Should -Not -Contain '.' $commands.Name | Should -Not -Contain '&' } - It 'Get-ASTScriptCommands gets the script commands with call operators (recursive)' { + It 'Get-AstScriptCommands gets the script commands with call operators (recursive)' { $path = Join-Path $PSScriptRoot 'src\Test-Function.ps1' - $commands = Get-ASTScriptCommand -Path $path -Recurse -IncludeCallOperators + $commands = Get-AstScriptCommand -Path $path -Recurse -IncludeCallOperators $commands | Should -Not -BeNullOrEmpty $commands | Should -BeOfType [pscustomobject] $commands.Name | Should -Contain 'ForEach-Object' diff --git a/tests/src/Test-Function.ps1 b/tests/src/Test-Function.ps1 index 8c7d6e9..5b81656 100644 --- a/tests/src/Test-Function.ps1 +++ b/tests/src/Test-Function.ps1 @@ -12,7 +12,7 @@ [Alias('Test-Func')] [Diagnostics.CodeAnalysis.SuppressMessageAttribute( 'PSAvoidUsingCmdletAliases', - Justification = 'Want to see that ASTCommand actually can get aliases.' + Justification = 'Want to see that AstCommand actually can get aliases.' )] [CmdletBinding()] param ( From 4a93630e784186e61e9b6aa82d10ed29eb1d38e4 Mon Sep 17 00:00:00 2001 From: Marius Storhaug Date: Mon, 6 Oct 2025 22:37:30 +0200 Subject: [PATCH 2/2] Fix Docs --- .github/PSModule.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/PSModule.yml b/.github/PSModule.yml index 96c0cd8..3f5a777 100644 --- a/.github/PSModule.yml +++ b/.github/PSModule.yml @@ -19,6 +19,7 @@ Test: # Build: # Docs: # Skip: true + Linter: env: VALIDATE_BIOME_FORMAT: false