Public/Get-PsModuleFunctions.ps1

function Get-PsModuleFunctions {
  param (
    $path,
    [switch]$PublicOnly
  )

  if ($PublicOnly) {
    $path = Join-Path $path "Public"
  }
  
  $files = (Get-ChildItem -Path $path -Filter "*.ps1" -Recurse) | Select-Object -ExpandProperty FullName  # | Select-String -Pattern "function" ) | ForEach-Object { $_.Line.Substring(9) }

  [string[]]$result = @();

  foreach ($file in $files) {
    # Get the AST of the file
    $tokens = $errors = $null
    $ast = [System.Management.Automation.Language.Parser]::ParseFile(
      $file,
      [ref]$tokens,
      [ref]$errors)

    # Get only function definition ASTs
    $functionDefinitions = $ast.FindAll( {
        param([System.Management.Automation.Language.Ast] $Ast)

        $Ast -is [System.Management.Automation.Language.FunctionDefinitionAst] -and
        # Class methods have a FunctionDefinitionAst under them as well, but we don't want them.
        ($PSVersionTable.PSVersion.Major -lt 5 -or
          $Ast.Parent -isnot [System.Management.Automation.Language.FunctionMemberAst])

      }, $true) | Select-Object -ExpandProperty Name

    $result += $functionDefinitions;    
  }
  $result;
}