Skip to content

Commit 074f151

Browse files
tools to build and deploy static HTML and initial version of PDF
1 parent 4fab155 commit 074f151

File tree

5 files changed

+119
-0
lines changed

5 files changed

+119
-0
lines changed

docker/Dockerfile

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
FROM ubuntu:18.04
2+
3+
LABEL maintainer="philipp.salvisberg@trivadis.com"
4+
LABEL description="Tools to generate website, pdf and ebook using Materials for MkDocs."
5+
LABEL build.command="docker build . --tag trivadis/mktools:latest"
6+
7+
RUN apt-get update
8+
RUN apt-get upgrade -y
9+
RUN apt-get install -y build-essential \
10+
python3-dev \
11+
python3-pip \
12+
python3-setuptools \
13+
python3-wheel \
14+
python3-cffi \
15+
libcairo2 \
16+
libpango-1.0-0 \
17+
libpangocairo-1.0-0 \
18+
libgdk-pixbuf2.0-0 \
19+
libffi-dev \
20+
shared-mime-info
21+
RUN apt-get install -y git
22+
RUN pip3 install --upgrade pip
23+
RUN pip3 install mkdocs \
24+
mkdocs-material \
25+
mkdocs-awesome-pages-plugin \
26+
pymdown-extensions \
27+
mike \
28+
weasyprint
29+
30+
ENV LC_ALL=C.UTF-8
31+
ENV LANG=C.UTF-8
32+
33+
# volume for GitHub project's root folder containing docs folder
34+
RUN mkdir /data
35+
VOLUME ["/data"]
36+
37+
# port for mkdocs serve
38+
EXPOSE 8000

genpdf-in-container.sh

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#/bin/bash
2+
3+
function create_target_dir(){
4+
rm -Rf ${TARGET_DIR}
5+
mkdir -p ${TARGET_DIR}/docs
6+
}
7+
8+
function copy_resources() {
9+
cp ./mkdocs.yml ${TARGET_DIR}/mkdocs.yml
10+
cp -r docs/images ${TARGET_DIR}/docs
11+
cp -r docs/stylesheets ${TARGET_DIR}/docs/stylesheets
12+
}
13+
14+
function write_file(){
15+
FILE=$1
16+
echo "" >> ${TARGET_DIR}/docs/index.md
17+
sed -e 's/..\/image/image/g' docs/${FILE} | sed -e 's/✘/X/g' >> ${TARGET_DIR}/docs/index.md
18+
}
19+
20+
function write_text(){
21+
TEXT=$1
22+
echo "" >> ${TARGET_DIR}/docs/index.md
23+
echo "${TEXT}" >> ${TARGET_DIR}/docs/index.md
24+
}
25+
26+
function write_guidelines(){
27+
DIR=$1
28+
FIRST_HEADER=$2
29+
for f in docs/${DIR}/g-*.md
30+
do
31+
echo "" >> ${TARGET_DIR}/docs/index.md
32+
sed -e "s|# |${FIRST_HEADER} |g" $f >> ${TARGET_DIR}/docs/index.md
33+
done
34+
}
35+
36+
function convert_to_pdf(){
37+
cd ${TARGET_DIR}
38+
mkdocs build
39+
cd site
40+
weasyprint index.html ../../plsql.pdf
41+
}
42+
43+
TARGET_DIR=work-pdf
44+
45+
create_target_dir
46+
copy_resources
47+
write_file "index.md"
48+
write_file "1-introduction/introduction.md"
49+
write_file "2-naming-conventions/naming-conventions.md"
50+
write_file "3-coding-style/coding-style.md"
51+
write_text "# Language Usage"
52+
write_text "## General"
53+
write_guidelines "4-language-usage/1-general" "###"
54+
write_text "## Numeric Data Types"
55+
write_text "### General"
56+
write_guidelines "4-language-usage/2-variables-and-types/1-general" "####"
57+
write_text "### Numeric Data Types"
58+
write_guidelines "4-language-usage/2-variables-and-types/2-numeric-data-types" "####"
59+
write_text "### Character Data Types"
60+
write_guidelines "4-language-usage/2-variables-and-types/3-character-data-types" "####"
61+
write_text "### Boolean Data Types"
62+
write_guidelines "4-language-usage/2-variables-and-types/4-boolean-data-types" "####"
63+
write_text "### Large Objects"
64+
write_guidelines "4-language-usage/2-variables-and-types/5-large-objects" "####"
65+
write_text "## DML & SQL"
66+
write_text "### General"
67+
write_guidelines "4-language-usage/3-dml-and-sql/1-general" "####"
68+
write_file "5-complexity-analysis/complexity-analysis.md"
69+
write_file "6-code-reviews/code-reviews.md"
70+
write_file "7-tool-support/tool-support.md"
71+
write_file "9-appendix/appendix.md"
72+
convert_to_pdf

genpdf.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#/bin/bash
2+
3+
docker run -v $(pwd):/data --rm -it trivadis/mktools bash -c "cd /data; ./genpdf-in-container.sh"

gh-deploy.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#/bin/bash
2+
3+
docker run -v $(pwd):/data -p 8000:8000 --rm -it trivadis/mktools bash -c "cd /data; mkdocs gh-deploy"

serve.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#/bin/bash
2+
3+
docker run -v $(pwd):/data -p 8000:8000 --rm -it trivadis/mktools bash -c "cd /data; mkdocs serve -a 0.0.0.0:8000"

0 commit comments

Comments
 (0)