58 lines
1.7 KiB
PowerShell
58 lines
1.7 KiB
PowerShell
[CmdletBinding()]
|
||
param(
|
||
[string]$OutputPath = (Join-Path $PSScriptRoot 'build\protocol.html')
|
||
)
|
||
|
||
$ErrorActionPreference = 'Stop'
|
||
$documents = @(
|
||
'README.md',
|
||
'PROTOCOL.md',
|
||
'BOOTLOADER.md',
|
||
'OAP.md',
|
||
'CHANGELOG.md'
|
||
)
|
||
|
||
$sections = foreach ($document in $documents) {
|
||
$path = Join-Path $PSScriptRoot $document
|
||
$markdown = Get-Content -Raw -LiteralPath $path
|
||
(ConvertFrom-Markdown -InputObject $markdown).Html
|
||
}
|
||
|
||
$style = @'
|
||
body { max-width: 1180px; margin: 32px auto; padding: 0 24px;
|
||
color: #111827; background: #fff; font: 15px/1.55 Arial, sans-serif; }
|
||
h1, h2, h3 { line-height: 1.25; }
|
||
h1 { margin-top: 48px; border-bottom: 2px solid #334155; padding-bottom: 8px; }
|
||
h2 { margin-top: 32px; }
|
||
a { color: #1155cc; }
|
||
code { font-family: Consolas, "Courier New", monospace; }
|
||
pre { overflow: auto; padding: 12px; border: 1px solid #cbd5e1; background: #f8fafc; }
|
||
table { width: 100%; border-collapse: collapse; margin: 12px 0 24px; }
|
||
th, td { border: 1px solid #94a3b8; padding: 6px 9px; vertical-align: top; }
|
||
th { background: #e2e8f0; }
|
||
tr:nth-child(even) td { background: #f8fafc; }
|
||
'@
|
||
|
||
$outputDirectory = Split-Path -Parent $OutputPath
|
||
if (-not (Test-Path -LiteralPath $outputDirectory)) {
|
||
New-Item -ItemType Directory -Path $outputDirectory | Out-Null
|
||
}
|
||
|
||
$html = @"
|
||
<!doctype html>
|
||
<html lang="ru">
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||
<title>ProtoCAN — спецификация</title>
|
||
<style>$style</style>
|
||
</head>
|
||
<body>
|
||
$($sections -join "`n<hr>`n")
|
||
</body>
|
||
</html>
|
||
"@
|
||
|
||
Set-Content -LiteralPath $OutputPath -Value $html -Encoding utf8
|
||
Write-Host "Создан $OutputPath"
|