Closed Trenly closed 2 weeks ago
Legend! Wanna add Markdownlint to it as well? To help you out, maybe some helpful code snippets I had laying down (from my Docs as Code series):
Function Get-OutputName {
[CmdletBinding()]
param (
[Parameter(Mandatory = $false)]
[string]
$RootProject = (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent),
[Parameter(Mandatory = $false)]
[string]
$OutputFileName = 'markdownlint-result.xml'
)
begin {
Write-Debug ('{0} entered' -f $MyInvocation.MyCommand)
}
process {
if ([bool](Get-Module -Name powershell-yaml)) {
$MarkdownLintConfig = Join-Path $RepoRootPath '.markdownlint-cli2.yaml'
$Name = (Get-Content $MarkdownLintConfig -ErrorAction SilentlyContinue | ConvertFrom-Yaml).outputFormatters.name
if (-not $Name) {
Write-Verbose -Message ("Setting default name to '[ {0} ]'" -f $OutputFile)
$Name = $OutputFileName
}
}
else {
$Name = $OutputFileName
}
return $Name
}
end {
Write-Debug ('{0} ended' -f $MyInvocation.MyCommand)
}
}
Function Get-MarkdownLintResult {
[CmdletBinding()]
Param (
[Parameter(Mandatory = $false)]
[string]
$RootProject = (Split-Path (Split-Path $PSScriptRoot -Parent) -Parent)
)
begin {
Write-Debug ('{0} entered' -f $MyInvocation.MyCommand)
. (Join-Path $PSScriptRoot 'Get-NpmRequiredPackages.ps1')
}
process {
if (Get-NpmRequiredPackages -PackageName @('markdownlint-cli2', 'markdownlint-cli2-formatter-junit')) {
$Command = "markdownlint-cli2"
Write-Verbose -Message ("Executing command '[ {0} ]'" -f $Command)
$null = Invoke-Expression -Command $Command
$FileName = Get-OutputName -RootProject $RootProject
$File = Join-Path $RootProject $FileName
Write-Verbose -Message ("File output '[ {0} ]'" -f $File)
return $File
}
}
end {
Write-Debug ('{0} ended' -f $MyInvocation.MyCommand)
}
}
With:
# Default state for all rules
default: true
# Path to configuration file to extend
extends: null
MD007:
# Spaces for indent
indent: 4
# Whether to indent the first level of the list
start_indented: false
# Spaces for first level indent (when start_indented is set)
start_indent: 2
# MD013/line-length : Line length : https://github.com/DavidAnson/markdownlint/blob/v0.32.1/doc/md013.md
MD013:
# Number of characters
line_length: 500
# Number of characters for headings
heading_line_length: 120
# Number of characters for code blocks
code_block_line_length: 500
# Include code blocks
code_blocks: true
# Include tables
tables: true
# Include headings
headings: true
# Strict length checking
strict: false
# Stern length checking
stern: false
# MD033/no-inline-html : Inline HTML : https://github.com/DavidAnson/markdownlint/blob/v0.32.1/doc/md033.md
MD033:
# Allowed elements
allowed_elements: ["details", "summary", "li", "ul"]
# MD041/first-line-heading/first-line-h1 : First line in a file should be a top-level heading : https://github.com/DavidAnson/markdownlint/blob/v0.32.1/doc/md041.md
MD041: false
I'd like to keep each PR purpose built; If you want to add MarkdownLint, feel free to raise a separate PR!
I've also added the specified actions and reusable workflows.
@jsoref FYI