-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdefault.nix
63 lines (57 loc) · 1.73 KB
/
default.nix
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
{ pkgs ? import <nixpkgs> {} }:
pkgs.stdenv.mkDerivation {
name = "build-docs";
src = ./.;
buildInputs = [
pkgs.pandoc
pkgs.texlive.combined.scheme-medium
pkgs.nodejs
pkgs.gnumake
pkgs.mermaid-cli
];
shellHook = ''
# Variables
OUTPUT_DIR="docs"
OUTPUT_FILE="documentation.pdf"
DIAGRAMS_DIR="docs/diagrams"
IMAGE_DIR="docs/tmp"
# Create the images directory if it doesn't exist
mkdir -p "$IMAGE_DIR"
# Find Mermaid files and convert them to images
for file in "$DIAGRAMS_DIR"/*.md; do
basename=$(basename "$file" .md)
mmdc -i "$file" -o "$IMAGE_DIR/$basename.png"
# Since we know the pattern, directly rename each file
mv "$IMAGE_DIR/$basename-1.png" "$IMAGE_DIR/$basename.png"
echo "renamed file to: $IMAGE_DIR/$basename.png"
done
# Generate the PDF using Pandoc
pandoc docs/index.md \
docs/motivation.md \
docs/verwendungszweck.md \
docs/zieluser.md \
docs/installation.md \
docs/technologien.md \
docs/komponenten.md \
docs/databaseDesign.md \
docs/useCases.md \
docs/bilder.md \
--pdf-engine=xelatex \
-V geometry:margin=2cm \
-V table-use-row-colors=true \
--from markdown+pipe_tables+raw_attribute \
--include-in-header=docs/header.tex \
-o "$OUTPUT_DIR/$OUTPUT_FILE"
# Check if the PDF was successfully created
if [ $? -eq 0 ]; then
echo "The PDF was successfully created: $OUTPUT_DIR/$OUTPUT_FILE"
# Remove temporary images
rm -rf "$IMAGE_DIR"
else
echo "Error creating the PDF"
exit 1
fi
# Exit the shell
exit
'';
}