Skip to content

Commit f06d529

Browse files
committed
New: First pass of building automatic list of commands to markdown
1 parent 0511b7c commit f06d529

2 files changed

Lines changed: 84 additions & 0 deletions

File tree

source/readme.build.ps1

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
#Requires -Version 7
2+
'Running: {0}' -f $PSCommandPath | Write-host -fore 'gray50'
3+
Import-Module Pansies -ea 'stop'
4+
5+
$Config = @{
6+
AppRoot = gi $PSScriptRoot
7+
ExportMd = Join-Path $PSScriptRoot 'readme.md'
8+
}
9+
$Config | Ft -auto
10+
11+
function FormatPqSourceItem {
12+
<#
13+
.SYNOPSIS
14+
build metadata on the objects, making source generation easier
15+
.NOTES
16+
if already is formatted, don't mutate it again, return as a no-op.
17+
#>
18+
[CmdletBinding()]
19+
param( [Parameter(Mandatory, ValueFromPipeline)] $InObj )
20+
process {
21+
22+
if( $InObj.pstypenames -contains 'PqLibSourceItem' ) {
23+
return $InObj
24+
}
25+
26+
$renderRelativePath = $InObj.FullName -replace [Regex]::escape( $Config.AppRoot.FullName + '\' ), ''
27+
[pscustomobject]@{
28+
PSTypeName = 'PqLibSourceItem'
29+
RelativePath = $renderRelativePath
30+
Name = $InObj.Name
31+
IsModule = ($InObj.fullName -match '\.module\.pq$'
32+
) ? $true :
33+
$false
34+
35+
# future: $q.IsTag.GetEnumerator() | ?{ $_.Value -eq $true }
36+
# IsTag = [PSCustomObject]@{
37+
IsTag = @{
38+
Assert = $InObj.Name -match '\bAssert\b'
39+
Text = $InObj.Name -match '\bText\b'
40+
Replace = $InObj.Name -match 'Replace'
41+
Coerce = $InObj.Name -match '\bCoerce\b'
42+
Convert = $InObj.Name -match '\bConvert(to)?\b'
43+
Table = $InObj.Name -match '\bTable\b'
44+
Column = $InObj.Name -match '\bColumn\b'
45+
Number = $InObj.Name -match '\bNumber\b'
46+
Binary = $InObj.Name -match '\bBinary\b'
47+
Web = $InObj.Name -match '\bWeb\b'
48+
Transform = $InObj.Name -match '\bTransform\b'
49+
List = $InObj.Name -match '\bList\b'
50+
Date = $InObj.Name -match '\bDate\b'
51+
DateTime = $InObj.Name -match '\bDateTime\b'
52+
}
53+
BaseName = $InObj.BaseName
54+
Directory = $InObj.Directory
55+
DirectoryBaseName = $InObj.Directory.Name
56+
FullName = $InObj.FullName
57+
Object = $InObj
58+
}
59+
}
60+
}
61+
62+
$find_pq_modules = fd -e module.pq --base-directory (gi $Config.AppRoot )
63+
| Get-Item
64+
| FormatPQSourceItem
65+
66+
$find_pq = fd -e pq --base-directory (gi $Config.AppRoot )
67+
| Get-Item
68+
| FormatPQSourceItem
69+
70+
71+
72+
'found: {{ modules: {0}, functions: {1}, root: {2} }}' -f @(
73+
$find_pq_modules.count
74+
$find_pq.count
75+
$Config.AppRoot
76+
)
77+
# drop files not commited
78+
79+
80+
$find_pq | Select -First 7 # | FormatPqSourceItem
81+
| ft -auto
82+
$find_pq | Select -First 2 # | FormatPqSourceItem
83+
| fl
84+
write-warning 'todo: make filter test if files are untracked or not'

source/readme.md

Whitespace-only changes.

0 commit comments

Comments
 (0)