Skip to content

Commit 748ca64

Browse files
authored
Merge pull request #175 from timunie/housekeeping/ascii-doc-pdf-creator
Added a basic script to create pdf-files from ascii-doc ReadMe
2 parents 3602d51 + 1bbe11f commit 748ca64

File tree

4 files changed

+109
-0
lines changed

4 files changed

+109
-0
lines changed

_docs/avalonia-docs-theme.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
extends: default
2+
base:
3+
font-color: #222222
4+
background-color: #ffffff
5+
line-height: 1.5
6+
paragraph-margin-bottom: 12
7+
heading:
8+
font-color: #0063b1
9+
font-style: bold
10+
h1-font-size: 22
11+
h2-font-size: 17
12+
h3-font-size: 13
13+
h4-font-size: 11
14+
link:
15+
font-color: #0063b1
16+
font-style: underline
17+
font-weight: bold
18+
role:
19+
hover:
20+
font-color: #40bfff
21+
code:
22+
font-color: #2d7d46
23+
background-color: #f3f3f3
24+
border-radius: 4
25+
quote:
26+
font-color: #3a4a5a
27+
background-color: #f6f7fa
28+
border-color: #0063b1
29+
border-width: 4
30+
border-style: solid
31+
table:
32+
head-background-color: #f0f2f5
33+
border-color: #d1d5db
34+
background-color: #f6f7fa
35+
admonition:
36+
border-color: #0063b1
37+
background-color: #f6f7fa
38+
title-font-color: #0063b1
39+
title-font-weight: bold

scripts/Ascii-doc-pdf_creator.ps1

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Compiles each .adoc file in all subdirectories (recursively) into a PDF using Asciidoctor-pdf.
2+
# If specific files are provided as arguments, only those files will be processed.
3+
4+
param(
5+
[Parameter(Mandatory=$false, ValueFromRemainingArguments=$true)]
6+
[string[]]$InputFiles
7+
)
8+
9+
# Find all .adoc files recursively
10+
if ($InputFiles -and $InputFiles.Count -gt 0) {
11+
$adocFiles = $InputFiles | ForEach-Object { Get-Item $_ }
12+
} else {
13+
$adocFiles = Get-ChildItem -Path ../. -Filter *.adoc -Recurse
14+
}
15+
16+
$themePath = Join-Path -Path (Resolve-Path ../_docs) -ChildPath "avalonia-docs-theme.yml"
17+
18+
foreach ($file in $adocFiles) {
19+
$pdfPath = [System.IO.Path]::ChangeExtension($file.FullName, ".pdf")
20+
Write-Host "Compiling $($file.FullName) to $pdfPath"
21+
22+
asciidoctor-pdf "$($file.FullName)" -r asciidoctor-diagram -a pdf-theme="$themePath" -a allow-uri-read=true -a source-highlighter=rouge -o "$pdfPath" --trace
23+
}

scripts/Setup_helper_asciidoc.ps1

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Ensure Ruby is installed
2+
if (-not (Get-Command "ruby" -ErrorAction SilentlyContinue)) {
3+
Write-Error "Ruby is not installed. Please install Ruby first."
4+
exit 1
5+
6+
7+
# Ensure asciidoctor-pdf is installed
8+
if (-not (Get-Command "asciidoctor-pdf" -ErrorAction SilentlyContinue)) {
9+
Write-Host "Installing asciidoctor-pdf gem..."
10+
& gem install asciidoctor-pdf | Out-Host
11+
# Wait for the installation to complete before proceeding
12+
if (-not (Get-Command "asciidoctor-pdf" -ErrorAction SilentlyContinue)) {
13+
Write-Error "asciidoctor-pdf installation failed."
14+
exit 1
15+
}
16+
}
17+
18+
# Ensure asciidoctor-diagram is installed
19+
if (-not (gem list asciidoctor-diagram -i | Select-String "true")) {
20+
Write-Host "Installing asciidoctor-diagram gem..."
21+
& gem install asciidoctor-diagram | Out-Host
22+
# Wait for the installation to complete before proceeding
23+
if (-not (gem list asciidoctor-diagram -i | Select-String "true")) {
24+
Write-Error "asciidoctor-diagram installation failed."
25+
exit 1
26+
}
27+
}
28+
29+
# Ensure ImageMagick is installed for prawn-gmagick to work
30+
if (-not (Get-Command "magick" -ErrorAction SilentlyContinue)) {
31+
Write-Host "ImageMagick is not installed. Please install ImageMagick (https://imagemagick.org/script/download.php) and ensure 'magick' is in your PATH."
32+
}
33+
34+
# Ensure prawn-gmagick is installed for image format support
35+
if (-not (gem list prawn-gmagick -i | Select-String "true")) {
36+
Write-Host "Installing prawn-gmagick gem for image format support..."
37+
& gem install prawn-gmagick | Out-Host
38+
}
39+
40+
# Ensure rouge is installed for syntax highlighting
41+
if (-not (gem list rouge -i | Select-String "true")) {
42+
Write-Host "Installing rouge gem for syntax highlighting..."
43+
& gem install rouge | Out-Host
44+
}

src/Avalonia.Samples/CompleteApps/SimpleToDoList/README.adoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22
// --- D O N ' T T O U C H T H I S S E C T I O N ---
33
:toc:
44
:toc-placement!:
5+
6+
ifdef::env-github[]
57
:tip-caption: :bulb:
68
:note-caption: :information_source:
79
:important-caption: :heavy_exclamation_mark:
810
:caution-caption: :fire:
911
:warning-caption: :warning:
12+
endif::[]
1013
// ----------------------------------------------------------
1114

1215

0 commit comments

Comments
 (0)