Skip to content

Commit 8cdddbd

Browse files
v2.27.0
1 parent 04e4e8f commit 8cdddbd

File tree

89 files changed

+2599
-2971
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+2599
-2971
lines changed

ModuleCommands.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Module Commands
2+
3+
This section contains the same help content you would get from a PowerShell prompt using `Get-Help`. Note that code examples have been formatted to fit the 80 character page width. Don't assume you can run examples exactly as they are shown. Some of the help examples use special or custom characters which might not render properly in the PDF.
4+
5+
Remember, you can also view the online help for each command:
6+
7+
```powershell
8+
Help Convertto-WPFGrid -online
9+
```
10+
11+
If you can't remember what commands are in this module, you can always ask PowerShell.
12+
13+
```powershell
14+
Get-Command -module PSScriptTools
15+
```
16+
17+
Or use `Get-PSScriptTools`.

PSScriptTools.psd1

242 Bytes
Binary file not shown.

PSScriptToolsHelp.md

Lines changed: 0 additions & 1612 deletions
This file was deleted.

PSScriptToolsManual.pdf

2.78 MB
Binary file not shown.

PrepAdoc.ps1

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
[cmdletbinding(SupportsShouldProcess)]
2+
Param(
3+
[Parameter(Position = 0)]
4+
[ValidateNotNullOrEmpty()]
5+
[ValidateScript( {Test-Path $_})]
6+
[string]$Path = ".",
7+
[Parameter(HelpMessage = "The path to a json file with the processing data for the folder.")]
8+
[ValidateNotNullOrEmpty()]
9+
[ValidateScript( {Test-Path $_})]
10+
[string]$DataPath = ".\adoc-data.json"
11+
)
12+
13+
$prog = @{
14+
Activity = "Prepare ADOC files"
15+
Status = "Initializing"
16+
CurrentOperation = ""
17+
PercentComplete = 0
18+
}
19+
20+
Write-Progress @prog
21+
22+
$ModulePath = Convert-Path $Path
23+
Write-Verbose "[$(Get-Date)] Working from $modulePath"
24+
25+
Write-Verbose "[$(Get-Date)] Importing ruby-related functions"
26+
. C:\scripts\rubydocs.ps1
27+
28+
Write-Verbose "[$(Get-Date)] Importing adoc data from json"
29+
<#
30+
{
31+
"Name" : "PSScriptToolsManual",
32+
"Title": "PSScriptTools Manual",
33+
"CodeTheme": "githubcustom",
34+
"CodeThemePath": "c:\\scripts\\githubcustom.rb",
35+
"Theme": "pdf-theme.yml",
36+
"Files": [
37+
{
38+
"Name": "Intro.md",
39+
"Lines": ""
40+
},
41+
{
42+
"Name": "README.md",
43+
"Lines": "1;13..15;33..-1"
44+
},
45+
{
46+
"Name": "ModuleCommands.md",
47+
"Lines": ""
48+
}
49+
]
50+
}#>
51+
52+
$data = Get-Content $DataPath | ConvertFrom-Json
53+
54+
Write-Verbose "[$(Get-Date)] Get the module version"
55+
$ver = (Import-PowerShellDataFile $ModulePath\*.psd1).moduleversion
56+
Write-Verbose "[$(Get-Date)] Found version $ver"
57+
58+
#define a here-string for the main document in Asciidoctor format
59+
$Main = @"
60+
= $($data.title) v$Ver
61+
:allow-uri-read:
62+
:autofit-option:
63+
:data-uri:
64+
:icons: font
65+
:iconset: fa
66+
:linkattrs:
67+
:rouge-style: $($data.codeTheme)
68+
:source-highlighter: rouge
69+
70+
"@
71+
72+
$files = $data.files
73+
$prog.status = "Processing main files"
74+
$i = 0
75+
foreach ($file in $files) {
76+
$i++
77+
$prog.CurrentOperation = $file.name
78+
$prog.percentComplete = ($i/$files.count)*100
79+
Write-Progress @prog
80+
$item = Join-Path -Path $Modulepath -ChildPath $file.name
81+
Write-Verbose "[$(Get-Date)] Converting $item"
82+
Get-Item -path $item |
83+
ConvertTo-Adoc -Codetheme $data.codeTheme
84+
85+
$adoc = $item -replace "md", "adoc"
86+
$c = Get-Content $adoc
87+
88+
Write-Verbose "[$(Get-Date)] Adjustings links and xrefs"
89+
[regex]$lx = "xref:(?<link>\S+)\.adoc\[(?<display>((\w+[\s-]\w+))+)\]"
90+
$matches = $lx.matches($c)
91+
foreach ($item in $matches) {
92+
$link = $item.groups.where( {$_.name -eq 'link'}).value
93+
$display = $item.groups.where( {$_.name -eq 'display'}).value
94+
95+
#split off the command name from the link to build the
96+
#correct cross-reference in the PDF
97+
$cmdName = $link.split("/")[-1]
98+
$xlink = "$cmdName-Help"
99+
$xref = "<<{0},{1}>>" -f $xlink, $display
100+
#use the method because the value has regex characters
101+
$c = $c.replace($item.value, $xref)
102+
}
103+
104+
Write-Verbose "[$(Get-Date)] Updating $adoc"
105+
$c | Out-File -FilePath $adoc -Encoding utf8
106+
107+
Write-Verbose "[$(Get-Date)] Adding to Main"
108+
#include line subsets if defined
109+
if ($file.lines) {
110+
$trim = "lines=$($file.lines)"
111+
}
112+
else {
113+
$trim = ""
114+
}
115+
$main += @"
116+
117+
include::$($adoc)[$trim]
118+
119+
"@
120+
}
121+
122+
Write-Verbose "[$(Get-Date)] Creating adoc help files. You may need to press Enter to force the process to continue."
123+
124+
#create the adoc files and then edit them.
125+
$prog.Status = "Converting markdown to adoc files"
126+
$prog.CurrentOperation =
127+
$i = 0
128+
$helpMD = Get-ChildItem $ModulePath\docs\*-*.md
129+
130+
$helpmd | ForEach-Object {
131+
$i++
132+
$prog.CurrentOperation = $_.FullName
133+
$prog.percentComplete = ($i/$helpmd.count)*100
134+
Write-Progress @prog
135+
ConvertTo-Adoc -Fullname $_.fullname -passthru -theme $data.codeTheme | Edit-Adoc
136+
}
137+
138+
$prog.status = "Building main document"
139+
Write-Verbose "[$(Get-Date)] Add include links to the main document"
140+
$adocs = Get-ChildItem $ModulePath\docs\*.adoc -OutVariable ov | Sort-Object -property Name
141+
142+
$i = 0
143+
ForEach ($item in $adocs) {
144+
$i++
145+
$prog.CurrentOperation = $item.name
146+
$prog.percentComplete = ($i/$adocs.count)*100
147+
Write-Progress @prog
148+
Write-Verbose "[$(Get-Date)] Adding $($item.name)"
149+
$main += @"
150+
151+
include::docs\$($item.name)[]
152+
153+
"@
154+
}
155+
156+
$out = Join-Path -path $ModulePath -child "$($data.name).adoc"
157+
$prog.status = "Finalizing"
158+
$prog.CurrentOperation = $out
159+
Write-Progress @prog
160+
Write-Verbose "[$(Get-Date)] Saving document to $out"
161+
$main | Out-File -FilePath $out -Encoding utf8
162+
163+
Write-Progress -Activity $prog.Activity -Completed
164+
Write-Host
165+
$msg = "Edit and review the adoc files and then run makepdf.ps1"
166+
Write-Host $msg -ForegroundColor Cyan
167+
168+
Write-Verbose "[$(Get-Date)] Finished."

0 commit comments

Comments
 (0)