Compare commits

...

12 commits

Author SHA1 Message Date
Glenn Y. Rolland a0279653f5 fix: make sure it runs
All checks were successful
continuous-integration/drone/push Build is passing
2024-09-23 01:39:46 +02:00
Glenn Y. Rolland 3cea2ba18d refactor: makefile & tasks 2024-09-23 01:03:29 +02:00
Glenn Y. Rolland 39d701f946 feat: add overlay testing script
All checks were successful
continuous-integration/drone/push Build is passing
2024-09-23 00:09:21 +02:00
Glenn Y. Rolland 55d808d43b fix: ignore mkdocs from docker build 2024-09-23 00:09:04 +02:00
Glenn Y. Rolland f2eeb554c8 fix: ignore deploy 2024-09-23 00:08:33 +02:00
Glenn Y. Rolland 7b17049512 fix: sort help output
All checks were successful
continuous-integration/drone/push Build is passing
2024-09-23 00:06:32 +02:00
Glenn Y. Rolland c4038b34cf fix: ignore md files in docs/ and slides/
All checks were successful
continuous-integration/drone/push Build is passing
2024-09-22 23:43:32 +02:00
Glenn Y. Rolland 18689043a4 fix: bump versions in pipfile 2024-09-22 23:43:02 +02:00
Glenn Y. Rolland acec55dfff refactor: move tasks in subfiles 2024-09-22 23:42:26 +02:00
Glenn Y. Rolland a58dcec4ca fix: switch to recent version of sass 2024-09-22 23:24:30 +02:00
Glenn Y. Rolland cf07f3b064 refactor: split Makefile into task files 2024-09-10 18:43:40 +02:00
Glenn Y. Rolland 1ebd4cbd4f refactor(make): split Makefile into sub-tasks files 2024-08-05 12:36:47 +02:00
16 changed files with 2046 additions and 4621 deletions

View file

@ -3,3 +3,7 @@ examples
exercises
node_modules
.drone.yml
docs/*.md
docs/**/*.md
slides/*.md
slides/**/*.md

1
.gitignore vendored
View file

@ -16,3 +16,4 @@ tmp*
\.vagrant
vendor/bundle
*.zip
mkdocs.yml

View file

@ -5,8 +5,10 @@ build: theme.css
%.css: %.scss
cd .. \
&& npx node-sass --output-style compressed .marp/$< > .marp/$@ \
&& npx sass --no-error-css --no-source-map .marp/$<:.marp/$@ \
|| ( rm -f .marp/$@ && exit 1 )
.PHONY: build
clean:
rm -f theme.css

172
Makefile
View file

@ -63,6 +63,7 @@ DOCS_IMAGES_ORA_PNG=$(patsubst $(IMAGES_DIR)/%.ora,$(BUILD_IMAGES_DIR)/%.ora.png
## Merge all lists
DOCS_IMAGES_SVG=$(DOCS_IMAGES_DOT_SVG) $(DOCS_IMAGES_CIRCO_SVG) $(DOCS_IMAGES_UML_SVG)
DOCS_IMAGES_PNG=$(DOCS_IMAGES_ORA_PNG)
export
all: help
@ -70,17 +71,8 @@ all: help
## Install prerequisites
##
prepare: prepare-slides prepare-docs ## install prerequisites
prepare-slides: ## install prerequisites for PDF slides only
npm install
npm rebuild node-sass
npx browserslist@latest --update-db
prepare-docs: ## install prerequisites for static docs site only
pipenv install
.PHONY: prepare prepare-slides prepare-docs
.PHONY: prepare
prepare:
images: $(DOCS_IMAGES_SVG) $(DOCS_IMAGES_PNG) ## build images
@echo "Source:"
@ -115,87 +107,13 @@ $(CACHE_SLIDES_DIR)/%.mdpp.md: $(SLIDES_DIR)/%.mdpp
m4 -d -I$(SLIDES_DIR) -I$(CACHE_SLIDES_DIR) $< > $@ \
|| ( rm -f $@ && exit 1 )
.marp/theme.css:
cd .marp && $(MAKE) theme.css
watch: ## run development server
$(MAKE) autoslide
pipenv run honcho start
autoslide: $(SLIDES_DIR)/autoslide.md | $(BUILD_SLIDES_DIR)
$(SLIDES_DIR)/autoslide.md: $(DOCS_MD)
find -L $(DOCS_DIR) -regextype sed \( -regex '.*/[0-9][^/]*\.md' ! -regex '.*/_.*' \) -print0 \
| sort -z \
| xargs -0 sed '/^---$$/,/^---$$/d' \
> $(SLIDES_DIR)/autoslide.md
watch-autoslide-internal:
# FIXME: use watchexec instead
while inotifywait -q -e move -e modify -e create -e attrib -e delete -e moved_to -r $(DOCS_DIR) ; do \
sleep 0.25 ; \
$(MAKE) autoslide ; \
done
watch-tocupdate-internal:
# FIXME: use watchexec instead
while inotifywait -q -e move -e modify -e create -e attrib -e delete -e moved_to -r $(DOCS_DIR) ; do \
sleep 2 ; \
$(MAKE) images ; \
done
watch-docs-internal:
pipenv run mkdocs serve --dev-addr 0.0.0.0:$(DOCS_PORT)
watch-slides-internal: .marp/theme.css
PORT=$(SLIDES_PORT) \
npx marp \
--allow-local-files \
--engine $$(pwd)/.marp/engine.js \
--html \
--theme $$(pwd)/.marp/theme.css \
-w $(SLIDES_DIR) \
-s
watch-slides: ## run development server for PDF slides
pipenv run honcho start slides autoslide
watch-docs: ## run development server for static docs site
pipenv run honcho start docs toc
serve: watch
serve-slides: watch-slides
serve-docs: watch-docs
.PHONY: watch watch-slides watch-docs watch-slides-internal watch-docs-internal serve serve-docs serve-slides
$(BUILD_SLIDES_DIR)/%.pdf: $(CACHE_SLIDES_DIR)/%.mdpp.md | $(BUILD_SLIDES_DIR) .marp/theme.css
npx marp --allow-local-files \
--engine $$(pwd)/.marp/engine.js \
--html \
--theme $$(pwd)/.marp/theme.css \
$< \
-o $@
$(BUILD_SLIDES_DIR)/%.pdf: $(SLIDES_DIR)/%.md | $(BUILD_SLIDES_DIR) .marp/theme.css
npx marp --allow-local-files \
--engine $$(pwd)/.marp/engine.js \
--html \
--theme $$(pwd)/.marp/theme.css \
$< \
-o $@
$(BUILD_SLIDES_DIR)/%.pptx: $(SLIDES_DIR)/%.md | $(BUILD_SLIDES_DIR) .marp/theme.css
npx marp --allow-local-files \
--engine $$(pwd)/.marp/engine.js \
--html \
--theme $$(pwd)/.marp/theme.css \
$< \
-o $@
$(BUILD_SLIDES_DIR):
mkdir -p $(BUILD_SLIDES_DIR)
.PHONY: watch serve
##
## Build final documents
@ -206,45 +124,11 @@ $(BUILD_SLIDES_DIR):
build: build-pdf build-html ## build all documents as PDF and HTML files
build-pptx: build-slides-pptx ## build slides as PPTX files
build-pptx: ## build both docs and slides as PPTX files
build-html: ## build both docs and slides as HTML files
build-pdf: ## build both docs and slides as PDF files
build-pdf: build-docs-pdf build-slides-pdf ## build both docs and slides as PDF files
build-html: build-docs-html build-slides-html ## build both docs and slides as HTML files
build-docs: build-docs-pdf build-docs-html ## build only docs as PDF and HTML
build-slides: build-slides-pdf build-slides-html ## build only slides as PDF and HTML
build-slides-pptx: $(SLIDES_PPTX_ALL) $(SLIDES_MD_ALL) ## build PPTX slides only
build-slides-pdf: $(SLIDES_PDF_ALL) $(SLIDES_MD_ALL) ## build PDF slides only
build-slides-html: $(SLIDES_HTML_ALL) ## build HTML slides only
merge-slides: $(SLIDES_MDPP_MD) $(SLIDES_MD_ALL)
build-docs-pdf: ## build pdf docs only
mkdir -p $(BUILD_DOCS_DIR)
rm -f $(BUILD_DOCS_DIR)/combined.pdf
PYTHONUTF8=1 \
ENABLE_PDF_EXPORT=1 \
pipenv run mkdocs build \
--site-dir $(BUILD_DOCS_DIR)
pdftk \
$$(find -L $(BUILD_DOCS_DIR) -name *.pdf -not -name index.pdf |sort ) \
cat output $(BUILD_DOCS_DIR)/docs.pdf
build-docs-html: ## build static docs site only
mkdir -p $(BUILD_DOCS_DIR)
pipenv run mkdocs build \
--site-dir $(BUILD_DOCS_DIR)
.PHONY: build build-slides
deploy-docs: ## deploy static docs site to github
git push $(DEPLOY_REPO)
pipenv run mkdocs gh-deploy $(DEPLOY_OPTS)
.PHONY: build
help: ## print this help
@echo "Usage: make <target>"
@ -255,7 +139,7 @@ help: ## print this help
/^[a-zA-Z_-]+:.*?## / \
{ sub("\\\\n",sprintf("\n%22c"," "), $$2); \
printf("\033[36m%-20s\033[0m %s\n", $$1, $$2); \
}' $(MAKEFILE_LIST)
}' $(MAKEFILE_LIST) | sort
@echo ""
@ -263,36 +147,14 @@ help: ## print this help
## Clean
##
clean: clean-slides clean-docs # remove generated documents
clean: # remove generated documents
clean-slides:
rm -fr $(BUILD_SLIDES_DIR) # remove generated PDF slides
.PHONY: clean
clean-docs:
rm -fr $(BUILD_DOCS_DIR) # remove generated static docs site
include tasks/docs.mk
include tasks/slides.mk
include tasks/docker.mk
include tasks/utils.mk
include tasks/images.mk
include tasks/shell.mk
.PHONY: clean clean-slides clean-docs
##
## Utilities
##
fixme:
@egrep --color -rni '(fixme)' $(DOCS_DIR) $(SLIDES_DIR)
.PHONY: fixme
docker-build: ## build docker image
docker build \
--file docker/Dockerfile \
--tag glenux/docmachine:$(BUILD_VERSION) \
.
docker tag \
glenux/docmachine:$(BUILD_VERSION) \
glenux/docmachine:latest
docker-push: ## push docker image
env docker push glenux/docmachine:latest
docker-pull: ## download docker image
env docker pull glenux/docmachine:latest

1253
Pipfile.lock generated

File diff suppressed because it is too large Load diff

View file

@ -1,5 +1,7 @@
docs: make watch-docs-internal
slides: make watch-slides-internal
toc: make watch-tocupdate-internal
autoslide: make watch-autoslide-internal
# src-docs: make sync-docs-internal
# src-slides: make sync-slides-internal
src-autoslide: make watch-autoslide-internal
watch-docs: make watch-docs-internal
watch-slides: make watch-slides-internal
watch-toc: make watch-tocupdate-internal
# proxy: caddy

View file

@ -29,6 +29,8 @@ chown -R "$EXT_UID:$EXT_GID" _cache
chown -R "$EXT_UID:$EXT_GID" _build
chown -R "$EXT_UID:$EXT_GID" .marp
chown -R "$EXT_UID:$EXT_GID" /home/appuser
chown -R "$EXT_UID:$EXT_GID" slides
chown -R "$EXT_UID:$EXT_GID" docs
# Patch mkdocs configuration
# set -x
@ -44,7 +46,7 @@ else
fi
# set +x
if [ "$1" = "shell" ]; then
if [ "$1" = "supershell" ]; then
exec bash
else
exec gosu "$EXT_UID:$EXT_GID" make "$@"

36
overlay.sh Normal file
View file

@ -0,0 +1,36 @@
#!/bin/sh
UID=$(id -u)
GID=$(id -g)
CURDIR=$(pwd)
set -u
set -e
echo "Umounting merge directory if it is mounted"
if mount | grep -q "${CURDIR}.merge"; then
sudo umount -lf "${CURDIR}.merge"
fi
# echo "Removing old upper directory"
# sudo rm -rf "${CURDIR}.upper"
echo "Creating directories"
sudo mkdir -p "${CURDIR}.upper"
sudo mkdir -p "${CURDIR}.workdir"
sudo mkdir -p "${CURDIR}.merge"
echo "Setting permissions"
sudo chown "$UID:$GID" "${CURDIR}.upper"
sudo chown "$UID:$GID" "${CURDIR}.workdir"
sudo chown "$UID:$GID" "${CURDIR}.merge"
echo "Mounting filesystem"
sudo mount -t overlay \
-o "lowerdir=${CURDIR},upperdir=${CURDIR}.upper,workdir=${CURDIR}.workdir" \
overlay \
"${CURDIR}.merge"
echo "Running shell"
cd "${CURDIR}.merge" || exit 1
exec $SHELL

4929
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -12,11 +12,11 @@
"author": "",
"license": "ISC",
"dependencies": {
"@marp-team/marp-cli": "^3.4.0",
"@marp-team/marp-cli": "^1.4.1",
"@marp-team/marp-core": "^3.9.0",
"foreman": "^3.0.1",
"markdown-it-footnote": "^3.0.2",
"markdown-it-highlight-lines": "^1.0.2",
"node-sass": "^7.0.0"
"sass": "^1.79.3"
}
}

17
tasks/docker.mk Normal file
View file

@ -0,0 +1,17 @@
# vim: set ft=make :
docker-build: ## build docker image
docker build \
--file docker/Dockerfile \
--tag glenux/docmachine:$(BUILD_VERSION) \
--output type=docker \
.
docker tag \
glenux/docmachine:$(BUILD_VERSION) \
glenux/docmachine:latest
docker-push: ## push docker image
env docker push glenux/docmachine:latest
docker-pull: ## download docker image
env docker pull glenux/docmachine:latest

70
tasks/docs.mk Normal file
View file

@ -0,0 +1,70 @@
# vim: set ft=make :
prepare-docs: ## install prerequisites for static docs site only
pipenv install
.PHONY: prepare-docs
prepare: prepare-docs
sync-docs-internal:
@>&2 echo "ERROR: not implemented"
exit 1
clean-docs: ## remove generated static docs site
rm -fr $(BUILD_DOCS_DIR)
.PHONY: clean-docs
clean: clean-docs
# deploy-docs: ## deploy static docs site to github
# git push $(DEPLOY_REPO)
# pipenv run mkdocs gh-deploy $(DEPLOY_OPTS)
# .PHONY: deploy-docs
# deploy: deploy-docs
build-docs-pdf: ## build pdf docs only
mkdir -p $(BUILD_DOCS_DIR)
rm -f $(BUILD_DOCS_DIR)/combined.pdf
PYTHONUTF8=1 \
ENABLE_PDF_EXPORT=1 \
pipenv run mkdocs build \
--site-dir $(BUILD_DOCS_DIR)
pdftk \
$$(find -L $(BUILD_DOCS_DIR) -name *.pdf -not -name index.pdf |sort ) \
cat output $(BUILD_DOCS_DIR)/docs.pdf
.PHONY: build-docs-pdf
build-docs: build-docs-pdf
build-docs-html: ## build static docs site only
mkdir -p $(BUILD_DOCS_DIR)
pipenv run mkdocs build \
--site-dir $(BUILD_DOCS_DIR)
.PHONY: build-docs-html
build-docs: build-docs-html
build: build-docs
watch-docs-internal:
pipenv run mkdocs serve --dev-addr 0.0.0.0:$(DOCS_PORT)
.PHONY: watch-docs-internal
watch-docs: ## run development server for static docs site
pipenv run honcho start watch-docs watch-toc
.PHONY: watch-docs
watch: watch-docs
build-pdf: build-docs-pdf ## build docs as PDF files
build-html: build-docs-html ## build docs as HTML files
build-docs: build-docs-pdf build-docs-html ## build only docs as PDF and HTML
serve-docs: watch-docs
.PHONY: watch-docs serve-docs
.PHONY: watch-docs-internal

0
tasks/images.mk Normal file
View file

9
tasks/shell.mk Normal file
View file

@ -0,0 +1,9 @@
.PHONY: supershell
supershell: shell
.PHONY: shell
shell:
@echo "Running shell..."
@bash

115
tasks/slides.mk Normal file
View file

@ -0,0 +1,115 @@
.PHONY: clean-slides
clean-slides:
rm -fr $(BUILD_SLIDES_DIR) # remove generated PDF slides
.PHONY: clean
clean: clean-slides
.PHONY: watch-slides-internal
watch-slides-internal: .marp/theme.css
PORT=$(SLIDES_PORT) \
npx marp \
--allow-local-files \
--engine $$(pwd)/.marp/engine.js \
--html \
--theme $$(pwd)/.marp/theme.css \
-w $(SLIDES_DIR) \
-s
.PHONY: watch-slides serve-slides
watch-slides: ## run development server for PDF slides
pipenv run honcho start watch-slides src-autoslide
.PHONY: prepare
prepare: prepare-slides
.PHONY: prepare-slides
prepare-slides: ## install prerequisites for PDF slides only
npm install
npm rebuild node-sass
npx browserslist@latest --update-db
$(BUILD_SLIDES_DIR)/%.pdf: $(CACHE_SLIDES_DIR)/%.mdpp.md | $(BUILD_SLIDES_DIR) .marp/theme.css
npx marp --allow-local-files \
--engine $$(pwd)/.marp/engine.js \
--html \
--theme $$(pwd)/.marp/theme.css \
$< \
-o $@
$(BUILD_SLIDES_DIR)/%.pdf: $(SLIDES_DIR)/%.md | $(BUILD_SLIDES_DIR) .marp/theme.css
npx marp --allow-local-files \
--engine $$(pwd)/.marp/engine.js \
--html \
--theme $$(pwd)/.marp/theme.css \
$< \
-o $@
$(BUILD_SLIDES_DIR)/%.pptx: $(SLIDES_DIR)/%.md | $(BUILD_SLIDES_DIR) .marp/theme.css
npx marp --allow-local-files \
--engine $$(pwd)/.marp/engine.js \
--html \
--theme $$(pwd)/.marp/theme.css \
$< \
-o $@
.marp/theme.css:
cd .marp && $(MAKE) theme.css
$(BUILD_SLIDES_DIR):
mkdir -p $(BUILD_SLIDES_DIR)
.PHONY: build-slides
build-slides: build-slides-pdf build-slides-html ## build only slides as PDF and HTML
.PHONY: build-slides-pptx
build-slides-pptx: $(SLIDES_PPTX_ALL) $(SLIDES_MD_ALL) ## build PPTX slides only
.PHONY: build-slides-pdf
build-slides-pdf: $(SLIDES_PDF_ALL) $(SLIDES_MD_ALL) ## build PDF slides only
.PHONY: build-slides-html
build-slides-html: $(SLIDES_HTML_ALL) ## build HTML slides only
.PHONY: merge-slides
merge-slides: $(SLIDES_MDPP_MD) $(SLIDES_MD_ALL)
.PHONY: watch-slides
serve-slides: watch-slides
.PHONY: autoslide
autoslide: $(SLIDES_DIR)/autoslide.md | $(BUILD_SLIDES_DIR)
$(SLIDES_DIR)/autoslide.md: $(DOCS_MD)
find -L $(DOCS_DIR) -regextype sed \( -regex '.*/[0-9][^/]*\.md' ! -regex '.*/_.*' \) -print0 \
| sort -z \
| xargs -0 sed '/^---$$/,/^---$$/d' \
> $(SLIDES_DIR)/autoslide.md
.PHONY: watch-autoslide-internal
watch-autoslide-internal:
# FIXME: use watchexec instead
while inotifywait -q -e move -e modify -e create -e attrib -e delete -e moved_to -r $(DOCS_DIR) ; do \
sleep 0.25 ; \
$(MAKE) autoslide ; \
done
.PHONY: watch-tocupdate-internal
watch-tocupdate-internal:
# FIXME: use watchexec instead
while inotifywait -q -e move -e modify -e create -e attrib -e delete -e moved_to -r $(DOCS_DIR) ; do \
sleep 2 ; \
$(MAKE) images ; \
done
.PHONY: build-slides-pdf
build-pdf: build-slides-pdf ## build slides as PDF files
.PHONY: build-slides-html
build-html: build-slides-html ## build slides as HTML files
.PHONY: build-slides-pptx
build-pptx: build-slides-pptx ## build slides as PPTX files

13
tasks/utils.mk Normal file
View file

@ -0,0 +1,13 @@
# vim: set ft=make :
##
## Utilities
##
fixme:
@egrep --color -rni '(fixme)' $(DOCS_DIR) $(SLIDES_DIR)
debug:
echo $(PWD)
.PHONY: fixme