@@ -40,146 +40,18 @@ jobs:
4040 path : ${{ fromJson(inputs.Settings).WorkingDirectory }}/outputs/docs
4141
4242 - name : Install Zensical
43- shell : pwsh
44- run : |
45- pip install zensical
43+ uses : ./_wf/.github/actions/Install-Zensical
4644
4745 - name : Structure site
48- uses : PSModule/GitHub-Script@8083ec1f733f00357ee4d0db0c6056686e483bc0 # v1.9.0
46+ uses : ./_wf/.github/actions/Structure-Site
4947 with :
50- Debug : ${{ fromJson(inputs.Settings).Debug }}
51- Prerelease : ${{ fromJson(inputs.Settings).Prerelease }}
52- Verbose : ${{ fromJson(inputs.Settings).Verbose }}
53- Version : ${{ fromJson(inputs.Settings).Version }}
5448 WorkingDirectory : ${{ fromJson(inputs.Settings).WorkingDirectory }}
55- Script : |
56- LogGroup "Get folder structure" {
57- $functionDocsFolder = New-Item -Path "outputs/site/docs/Functions" -ItemType Directory -Force
58- Copy-Item -Path "outputs/docs/*" -Destination "outputs/site/docs/Functions" -Recurse -Force
59- $moduleName = [string]::IsNullOrEmpty('${{ fromJson(inputs.Settings).Name }}') ? $env:GITHUB_REPOSITORY_NAME : '${{ fromJson(inputs.Settings).Name }}'
60- $ModuleSourcePath = Resolve-Path 'src' | Select-Object -ExpandProperty Path
61- $SiteOutputPath = Resolve-Path 'outputs/site' | Select-Object -ExpandProperty Path
62-
63- Write-Host "Function Docs Folder: $functionDocsFolder"
64- Write-Host "Module Name: $moduleName"
65- Write-Host "Module Source Path: $ModuleSourcePath"
66- Write-Host "Site Output Path: $SiteOutputPath"
67- }
68-
69- LogGroup "Get folder structure" {
70- Get-ChildItem -Recurse | Select-Object -ExpandProperty FullName | Sort-Object | Format-List
71- }
72-
73- Get-ChildItem -Path $functionDocsFolder -Recurse -Force -Include '*.md' | ForEach-Object {
74- $fileName = $_.Name
75- LogGroup " - $fileName" {
76- Show-FileContent -Path $_
77- }
78- }
79-
80- LogGroup 'Build docs - Process about topics' {
81- $aboutDocsFolderPath = Join-Path -Path $SiteOutputPath -ChildPath 'docs/About'
82- $aboutDocsFolder = New-Item -Path $aboutDocsFolderPath -ItemType Directory -Force
83- $aboutSourceFolder = Get-ChildItem -Path $ModuleSourcePath -Directory | Where-Object { $_.Name -eq 'en-US' }
84- Get-ChildItem -Path $aboutSourceFolder -Filter *.txt | Copy-Item -Destination $aboutDocsFolder -Force -Verbose -PassThru |
85- Rename-Item -NewName { $_.Name -replace '.txt', '.md' }
86-
87- Write-Host "About Docs Folder: $aboutDocsFolder"
88- Write-Host "About Source Folder: $aboutSourceFolder"
89- }
90-
91- LogGroup 'Build docs - Copy icon to assets' {
92- $assetsFolderPath = Join-Path -Path $SiteOutputPath -ChildPath 'docs/Assets'
93- $assetsFolder = New-Item -Path $assetsFolderPath -ItemType Directory -Force
94- $rootPath = Split-Path -Path $ModuleSourcePath -Parent
95- $iconPath = Resolve-Path 'icon\icon.png' | Select-Object -ExpandProperty Path
96- Copy-Item -Path $iconPath -Destination $assetsFolder -Force -Verbose
97-
98- Write-Host "Assets Folder: $assetsFolder"
99- Write-Host "Icon Path: $iconPath"
100- }
101-
102- LogGroup 'Build docs - Copy readme.md' {
103- $readmePath = Resolve-Path 'README.md' | Select-Object -ExpandProperty Path
104- $readmeTargetPath = Join-Path -Path $SiteOutputPath -ChildPath 'docs/README.md'
105- Copy-Item -Path $readmePath -Destination $readmeTargetPath -Force -Verbose
106-
107- Write-Host "Readme Path: $readmePath"
108- Write-Host "Readme Target Path: $readmeTargetPath"
109- }
110-
111- LogGroup 'Build docs - Create docs config' {
112- $rootPath = Split-Path -Path $ModuleSourcePath -Parent
113- $possiblePaths = @(
114- '.github/zensical.toml',
115- 'docs/zensical.toml',
116- 'zensical.toml'
117- )
118-
119- $docsConfigSourcePath = $null
120- foreach ($path in $possiblePaths) {
121- $candidatePath = Join-Path -Path $rootPath -ChildPath $path
122- if (Test-Path -Path $candidatePath) {
123- $docsConfigSourcePath = $candidatePath
124- break
125- }
126- }
127-
128- if (-not $docsConfigSourcePath) {
129- throw "Documentation config file not found. Expected one of: $($possiblePaths -join ', ')"
130- }
131-
132- $docsConfigFileName = [System.IO.Path]::GetFileName($docsConfigSourcePath)
133- $docsConfigTargetPath = Join-Path -Path $SiteOutputPath -ChildPath $docsConfigFileName
134-
135- Write-Host "Docs Config Source: $docsConfigSourcePath"
136- Write-Host "Docs Config Target: $docsConfigTargetPath"
137-
138- $docsConfigContent = Get-Content -Path $docsConfigSourcePath -Raw
139- $docsConfigContent = $docsConfigContent.Replace('-{{ REPO_NAME }}-', $ModuleName)
140- $docsConfigContent = $docsConfigContent.Replace('-{{ REPO_OWNER }}-', $env:GITHUB_REPOSITORY_OWNER)
141- if ($docsConfigFileName -eq 'zensical.toml') {
142- if ($docsConfigContent -match '(?m)^\s*site_dir\s*=') {
143- $docsConfigContent = $docsConfigContent -replace '(?m)^\s*site_dir\s*=.*$', 'site_dir = "_site"'
144- } else {
145- $docsConfigContent = $docsConfigContent -replace '(?m)^\[project\]\s*$', "[project]`nsite_dir = ""_site"""
146- }
147- }
148- $docsConfigContent | Set-Content -Path $docsConfigTargetPath -Force
149-
150- Write-Host "Build Config Type: $docsConfigFileName"
151- Show-FileContent -Path $docsConfigTargetPath
152- }
49+ Name : ${{ fromJson(inputs.Settings).Name }}
15350
15451 - name : Build documentation site with Zensical
155- working-directory : ${{ fromJson(inputs.Settings).WorkingDirectory }}/outputs/site
156- shell : pwsh
157- run : |
158- if (-not (Test-Path -Path 'zensical.toml')) {
159- throw "No documentation config file found in outputs/site. Expected zensical.toml."
160- }
161- $configFile = 'zensical.toml'
162-
163- LogGroup 'Build docs - Zensical config content' {
164- Write-Host "Using config: $configFile"
165- Show-FileContent -Path $configFile
166- }
167-
168- LogGroup 'Build docs - Zensical build' {
169- zensical build --config-file $configFile
170- }
171-
172- LogGroup 'Build docs - verify output' {
173- if (Test-Path -Path '_site') {
174- if (Test-Path -Path '../../_site') {
175- Remove-Item -Path '../../_site' -Recurse -Force
176- }
177- Move-Item -Path '_site' -Destination '../../_site' -Force
178- }
179- if (-not (Test-Path -Path '../../_site')) {
180- throw "Expected Zensical output at ../../_site but it was not created."
181- }
182- }
52+ uses : ./_wf/.github/actions/Build-ZensicalSite
53+ with :
54+ WorkingDirectory : ${{ fromJson(inputs.Settings).WorkingDirectory }}
18355
18456 - name : Inject shared site scripts
18557 uses : ./_wf/.github/actions/Inject-SiteScripts
0 commit comments