-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathREADME.md.ps1
More file actions
117 lines (88 loc) · 2.34 KB
/
Copy pathREADME.md.ps1
File metadata and controls
117 lines (88 loc) · 2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<#
.SYNOPSIS
README.md.ps1
.DESCRIPTION
README.md.ps1 makes README.md
This is a simple and helpful scripting convention for writing READMEs.
`./README.md.ps1 > ./README.md`
Feel free to copy and paste this code.
Please document your parameters, and add NOTES.
.NOTES
This README.md.ps1 is used to generate help for a module.
It:
* Outputs the name and description
* Provides installation instructions
.EXAMPLE
./README.md.ps1 > ./README.md
.EXAMPLE
Get-Help ./README.md.ps1
#>
param(
# The name of the module
[string]$ModuleName = $($PSScriptRoot | Split-Path -Leaf),
# The domains that serve git repositories.
# If the project uri links to this domain,
# installation instructions will show how to import the module locally.
[string[]]
$GitDomains = @(
'github.com', 'tangled.org', 'tangled.sh', 'codeberg.org'
),
[switch]
$NoLogo,
# If set, will not display gallery instructions or badges
[switch]
$NotOnGallery
)
Push-Location $PSScriptRoot
# Import the module
$module = Import-Module "./$ModuleName.psd1" -PassThru
$logoFiles = Get-ChildItem -Path "$($module)*.svg"
$logoImage = if (-not $NoLogo) {
if ($logoFiles -match '-animate') {
@($logoFiles -match '-animate')[0]
} else {
@($logoFiles)[0]
}
}
if ($logoImage) {
"
<div align='center'>
<img src='$($LogoImage.Name)' style='height:400px' />
</div>
"
}
# And output a header
"# $module"
# Show the module description
"## $($module.Description)"
# Show any intro section defined in the manifest
$module.PrivateData.PSData.PSIntro
#region Boilerplate installation instructions
if (-not $NotOnGallery) {
@"
## Installing and Importing
You can install $ModuleName from the [PowerShell gallery](https://powershellgallery.com/)
~~~PowerShell
Install-Module $($ModuleName) -Scope CurrentUser -Force
~~~
Once installed, you can import the module with:
~~~PowerShell
Import-Module $ModuleName -PassThru
~~~
"@
}
#endregion Gallery installation instructions
#region Git installation instructions
$projectUri = $module.PrivateData.PSData.ProjectURI -as [uri]
if ($projectUri.DnsSafeHost -in $GitDomains) {
@"
You can also clone the repo and import the module locally:
~~~PowerShell
git clone $projectUri
cd ./$ModuleName
Import-Module ./ -PassThru
~~~
"@
}
#endregion Git installation instructions
Pop-Location