mirror of
https://github.com/ldericher/autodoc.git
synced 2025-12-06 23:52:59 +00:00
Compare commits
No commits in common. "master" and "v0.1" have entirely different histories.
32 changed files with 163 additions and 654 deletions
35
.drone.yml
35
.drone.yml
|
|
@ -1,35 +0,0 @@
|
||||||
---
|
|
||||||
kind: pipeline
|
|
||||||
name: default
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: default
|
|
||||||
image: plugins/docker
|
|
||||||
settings:
|
|
||||||
repo: ldericher/autodoc
|
|
||||||
username:
|
|
||||||
from_secret: DOCKER_USERNAME
|
|
||||||
password:
|
|
||||||
from_secret: DOCKER_PASSWORD
|
|
||||||
auto_tag: true
|
|
||||||
dockerfile: Dockerfile.alpine
|
|
||||||
target: stage-base
|
|
||||||
|
|
||||||
- name: diagram
|
|
||||||
image: plugins/docker
|
|
||||||
settings:
|
|
||||||
repo: ldericher/autodoc
|
|
||||||
username:
|
|
||||||
from_secret: DOCKER_USERNAME
|
|
||||||
password:
|
|
||||||
from_secret: DOCKER_PASSWORD
|
|
||||||
auto_tag: true
|
|
||||||
auto_tag_suffix: diagram
|
|
||||||
dockerfile: Dockerfile.ubuntu
|
|
||||||
target: stage-diagram
|
|
||||||
|
|
||||||
- name: parallelism provider
|
|
||||||
image: alpine
|
|
||||||
depends_on:
|
|
||||||
- default
|
|
||||||
- diagram
|
|
||||||
1
.gitattributes
vendored
1
.gitattributes
vendored
|
|
@ -1 +0,0 @@
|
||||||
*.icc filter=lfs diff=lfs merge=lfs -text
|
|
||||||
|
|
@ -1,57 +0,0 @@
|
||||||
FROM pandoc/extra:latest AS stage-base
|
|
||||||
|
|
||||||
RUN set -ex; \
|
|
||||||
\
|
|
||||||
apk add --no-cache \
|
|
||||||
bash \
|
|
||||||
ghostscript \
|
|
||||||
inotify-tools \
|
|
||||||
make \
|
|
||||||
patch \
|
|
||||||
; \
|
|
||||||
\
|
|
||||||
tlmgr update --self; \
|
|
||||||
\
|
|
||||||
tlmgr install \
|
|
||||||
kpfonts \
|
|
||||||
lastpage \
|
|
||||||
latexmk \
|
|
||||||
twemojis \
|
|
||||||
;
|
|
||||||
|
|
||||||
COPY src/usr /usr
|
|
||||||
|
|
||||||
RUN set -ex; \
|
|
||||||
\
|
|
||||||
cp /usr/share/ghostscript/lib/PDFA_def.ps /usr/local/share/autodoc/; \
|
|
||||||
patch -d /usr/local/share/autodoc < /usr/local/share/autodoc/PDFA_def.ps.patch; \
|
|
||||||
rm /usr/local/share/autodoc/PDFA_def.ps.patch;
|
|
||||||
|
|
||||||
WORKDIR /docs
|
|
||||||
ENTRYPOINT ["autodoc"]
|
|
||||||
CMD ["-bw"]
|
|
||||||
|
|
||||||
FROM stage-base AS stage-diagram
|
|
||||||
|
|
||||||
ENV PUPPETEER_CACHE_DIR="/usr/local/share/puppeteer/cache" \
|
|
||||||
PUPPETEER_EXECUTABLE_PATH="/usr/bin/chromium-browser" \
|
|
||||||
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD="true"
|
|
||||||
|
|
||||||
COPY src/diagram.lua.patch /usr/local/src/autodoc/diagram.lua.patch
|
|
||||||
|
|
||||||
RUN set -ex; \
|
|
||||||
\
|
|
||||||
apk add --no-cache \
|
|
||||||
chromium \
|
|
||||||
npm \
|
|
||||||
; \
|
|
||||||
\
|
|
||||||
npm install --global @mermaid-js/mermaid-cli; \
|
|
||||||
# rm -rf /root/.cache/puppeteer; \
|
|
||||||
\
|
|
||||||
wget \
|
|
||||||
--output-document='/usr/local/share/pandoc/filters/diagram.lua' \
|
|
||||||
'https://raw.githubusercontent.com/pandoc-ext/diagram/refs/heads/main/_extensions/diagram/diagram.lua' \
|
|
||||||
; \
|
|
||||||
patch /usr/local/share/pandoc/filters/diagram.lua < /usr/local/src/autodoc/diagram.lua.patch; \
|
|
||||||
rm /usr/local/src/autodoc/diagram.lua.patch;
|
|
||||||
|
|
@ -1,64 +0,0 @@
|
||||||
FROM pandoc/extra:latest-ubuntu AS stage-base
|
|
||||||
|
|
||||||
RUN set -ex; \
|
|
||||||
\
|
|
||||||
deluser --remove-home ubuntu; \
|
|
||||||
\
|
|
||||||
apt-get update; apt-get install --no-install-recommends --yes \
|
|
||||||
ghostscript \
|
|
||||||
inotify-tools \
|
|
||||||
make \
|
|
||||||
patch \
|
|
||||||
; rm -rf /var/lib/apt/lists/*; \
|
|
||||||
\
|
|
||||||
tlmgr update --self; \
|
|
||||||
\
|
|
||||||
tlmgr install \
|
|
||||||
kpfonts \
|
|
||||||
lastpage \
|
|
||||||
latexmk \
|
|
||||||
twemojis \
|
|
||||||
;
|
|
||||||
|
|
||||||
COPY src/usr /usr
|
|
||||||
|
|
||||||
RUN set -ex; \
|
|
||||||
\
|
|
||||||
cp /usr/share/ghostscript/10.02.1/lib/PDFA_def.ps /usr/local/share/autodoc/; \
|
|
||||||
patch -d /usr/local/share/autodoc < /usr/local/share/autodoc/PDFA_def.ps.patch; \
|
|
||||||
rm /usr/local/share/autodoc/PDFA_def.ps.patch;
|
|
||||||
|
|
||||||
WORKDIR /docs
|
|
||||||
ENTRYPOINT ["autodoc"]
|
|
||||||
CMD ["-bw"]
|
|
||||||
|
|
||||||
FROM stage-base AS stage-diagram
|
|
||||||
|
|
||||||
ENV PUPPETEER_CACHE_DIR="/usr/local/share/puppeteer/cache"
|
|
||||||
|
|
||||||
COPY src/diagram.lua.patch /usr/local/src/autodoc/diagram.lua.patch
|
|
||||||
|
|
||||||
RUN set -ex; \
|
|
||||||
\
|
|
||||||
apt-get update; apt-get install --no-install-recommends --yes \
|
|
||||||
libasound2t64 \
|
|
||||||
libatk1.0-0t64 \
|
|
||||||
libatk-bridge2.0-0t64 \
|
|
||||||
libgbm1 \
|
|
||||||
libnss3 \
|
|
||||||
libxcomposite1 \
|
|
||||||
libxdamage1 \
|
|
||||||
libxfixes3 \
|
|
||||||
libxkbcommon0 \
|
|
||||||
libxrandr2 \
|
|
||||||
npm \
|
|
||||||
; rm -rf /var/lib/apt/lists/*; \
|
|
||||||
\
|
|
||||||
npm install --global @mermaid-js/mermaid-cli; \
|
|
||||||
\
|
|
||||||
wget \
|
|
||||||
--output-document='/usr/local/share/pandoc/filters/diagram.lua' \
|
|
||||||
'https://raw.githubusercontent.com/pandoc-ext/diagram/refs/heads/main/_extensions/diagram/diagram.lua' \
|
|
||||||
; \
|
|
||||||
patch /usr/local/share/pandoc/filters/diagram.lua < /usr/local/src/autodoc/diagram.lua.patch; \
|
|
||||||
rm /usr/local/src/autodoc/diagram.lua.patch;
|
|
||||||
103
README.md
103
README.md
|
|
@ -1,108 +1,71 @@
|
||||||
# autodoc
|
# autodoc
|
||||||
|
|
||||||
[](https://github.drone.yavook.de/ldericher/autodoc)
|
[`autodoc`](https://github.com/ldericher/autodoc) is a simple [CI](https://en.wikipedia.org/wiki/Continuous_integration) script, primarily aimed at document creation.
|
||||||
|
|
||||||
[`autodoc`](https://github.com/ldericher/autodoc) is a simple [CI](https://en.wikipedia.org/wiki/Continuous_integration) system optimized for document creation.
|
## Basics
|
||||||
|
|
||||||
In general, any file-sharing solution -- preferably on top of `docker-compose` -- can be made into an automatic document distribution system by adding an `autodoc` instance.
|
`autodoc` relies upon [inotify-tools](https://github.com/rvoicilas/inotify-tools) to recursively watch a Linux file system directory.
|
||||||
|
|
||||||
## Quick Start Guide using Docker
|
For each file change, `autodoc` searches corresponding build instruction files (Makefiles etc.) and kicks off build processes accordingly.
|
||||||
|
|
||||||
The `autodoc` image [available on Docker Hub](https://hub.docker.com/r/ldericher/autodoc) is based on [pandoc/extra](https://hub.docker.com/r/pandoc/extra) providing TeXlive `LaTeX` and `pandoc` in a container.
|
## Usage
|
||||||
|
|
||||||
01. Install [Docker CE](https://docs.docker.com/install/)
|
`autodoc` is designed to run in a server-side, containerized context.
|
||||||
|
|
||||||
01. Clone or download the `autodoc` repository, open a terminal inside the [examples](https://github.com/ldericher/autodoc/tree/master/examples) directory
|
### Deploy a container
|
||||||
|
|
||||||
01. Deploy an `autodoc` container:
|
`autodoc` can be pulled from the docker hub using `docker pull ldericher/autodoc`.
|
||||||
|
|
||||||
```bash
|
When deploying an `autodoc` container, mount your document root to `/docs`. You *should* also set the container's UID and GID.
|
||||||
docker run --rm -it \
|
|
||||||
--volume "${PWD}:/docs" \
|
|
||||||
--user "$(id -u):$(id -g)" \
|
|
||||||
ldericher/autodoc
|
|
||||||
```
|
|
||||||
|
|
||||||
The contents of the directory are now being watched by `autodoc`!
|
#### Included software
|
||||||
|
|
||||||
When deploying an `autodoc` container, just mount your document root to `/docs`. You *should* also set the container's UID and GID. These are seen above.
|
TODO `ldericher/autodoc` contains `pandoc`.
|
||||||
|
|
||||||
01. Edit some stuff, save -- and watch the magic happen (and the terminal output).
|
#### tl;dr
|
||||||
|
|
||||||
On each file change, `autodoc` searches relevant build instruction files (Makefiles etc.) and kicks off build processes accordingly.
|
Deploy an `autodoc` instance in your current working dir:
|
||||||
|
|
||||||
### How *not* to use `autodoc`
|
docker run --name autodoc -d -v "${PWD}":/docs --user "$(id -u):$(id -g)" ldericher/autodoc
|
||||||
|
|
||||||
`autodoc` is **not** a solution for Continuous Integration of large scale systems software! `autodoc` excels at building a large number of independent, small files.
|
### Automating builds
|
||||||
|
|
||||||
### Deploying without Docker
|
Example automated builds can be found [here](https://github.com/ldericher/autodoc/tree/master/example_docs).
|
||||||
|
|
||||||
`autodoc` only hard-depends on `inotifywait` from [inotify-tools](https://github.com/rvoicilas/inotify-tools) to recursively watch Linux file system directories.
|
In general, just put a build instruction file into any (sub-)directory watched by `autodoc` and add your source files.
|
||||||
|
|
||||||
You will usually want to install a `LaTeX` distribution and setup `pandoc`.
|
|
||||||
|
|
||||||
## Prime use case: Nextcloud
|
|
||||||
|
|
||||||
Nextcloud is a "safe home for all your data" that can [easily be deployed using docker-compose](https://hub.docker.com/_/nextcloud).
|
|
||||||
Add an `autodoc` container to create directories where PDFs are automatically held up to date for all your documents. This extends upon the "[Base version - apache](https://hub.docker.com/_/nextcloud#base-version---apache)" of the Nextcloud compose deployment.
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
version: '2'
|
|
||||||
|
|
||||||
volumes:
|
|
||||||
documents:
|
|
||||||
|
|
||||||
services:
|
|
||||||
app:
|
|
||||||
volumes:
|
|
||||||
- documents:/opt/autodoc
|
|
||||||
|
|
||||||
autodoc:
|
|
||||||
image: ldericher/autodoc
|
|
||||||
user: "UID:GID"
|
|
||||||
volumes:
|
|
||||||
- documents:/docs
|
|
||||||
```
|
|
||||||
|
|
||||||
The "user" key should be set to the same numeric IDs used for the nextcloud worker processes! To find the right IDs, issue `docker-compose exec app sh -c 'id -u www-data; id -g www-data'`.
|
|
||||||
For the apache containers, this should evaluate to "33:33".
|
|
||||||
|
|
||||||
To begin, add the mounted `/opt/autodoc` as a 'local type' external storage to your Nextcloud instance.
|
|
||||||
You might need to setup the permissions on your new volume using `docker-compose exec app chown -R www-data:www-data /opt/autodoc`.
|
|
||||||
|
|
||||||
## Concept: Source patterns
|
|
||||||
|
|
||||||
To avoid unnecessary rebuilds and self-triggering, `autodoc` uses "source patterns" to filter for the relevant build instructions.
|
|
||||||
A source pattern is a `bash` regular expression matching any filename that should be regarded as a "source file" to the build instruction file.
|
|
||||||
|
|
||||||
For instance, if a Makefile instructs how to build from Markdown source files, that Makefile's source pattern should likely be `\.md$`.
|
|
||||||
|
|
||||||
## Creating an automated build
|
|
||||||
|
|
||||||
In general, just put your source files into any (sub-)directory watched by `autodoc`. Add a build instruction file.
|
|
||||||
|
|
||||||
On each file change, its containing directory is searched for a build instruction file. Watched parent directories are also probed for further build instructions.
|
On each file change, its containing directory is searched for a build instruction file. Watched parent directories are also probed for further build instructions.
|
||||||
Every relevant instruction file will be executed as found.
|
Every relevant instruction file will be executed as found.
|
||||||
|
|
||||||
You may combine build instruction systems to your liking.
|
You may combine build instruction systems to your liking.
|
||||||
|
|
||||||
## Build instruction systems
|
#### SRCPAT concept, "relevant" build instructions
|
||||||
|
|
||||||
### GNU Make (Makefiles)
|
To avoid unnecessary rebuilds and self-triggering, `autodoc` uses "source patterns" to decide which build instructions are relevant.
|
||||||
|
|
||||||
`autodoc` supports GNU Makefiles.
|
For instance, if a build instruction file describes building anything from Markdown files, its source pattern should be something like `\.md$` to match files with ".md" as last extension. Source patterns are `bash` regular expressions.
|
||||||
However, Makefiles must contain a SRCPAT annotation comment as follows, where `<regex>` is a source pattern as above.
|
|
||||||
|
#### GNU Make (Makefiles)
|
||||||
|
|
||||||
|
`autodoc` supports standard Makefiles.
|
||||||
|
`Makefile`s must contain a SRCPAT annotation comment as follows, where `<regex>` is the source pattern as above.
|
||||||
|
|
||||||
```Makefile
|
```Makefile
|
||||||
#%SRCPAT% <regex>
|
#@SRCPAT <regex>
|
||||||
```
|
```
|
||||||
|
|
||||||
If there are multiple SRCPAT annotations, the lowermost one will be used.
|
If there are multiple SRCPAT annotations, the lowermost one will be used.
|
||||||
|
|
||||||
You *may* add a PHONY target "autodoc" which will be built *instead* of the default target. This is demonstrated in [examples/automatic directory listing/a directory in space/Makefile](https://github.com/ldericher/autodoc/blob/develop/examples/automatic%20directory%20listing/a%20directory%20in%20space/Makefile).
|
##### Advanced options
|
||||||
|
|
||||||
|
You may add a PHONY target "autodoc" which will be built *instead* of the default target.
|
||||||
|
|
||||||
```Makefile
|
```Makefile
|
||||||
.PHONY: autodoc
|
.PHONY: autodoc
|
||||||
autodoc:
|
autodoc:
|
||||||
@echo "Hello World!"
|
@echo "Hello World!"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## What not to use `autodoc` for
|
||||||
|
|
||||||
|
`autodoc` excels at building a large number of independent small files. It is **not** a solution for Continuous Integration of large scale software systems!
|
||||||
|
|
|
||||||
10
build/Dockerfile
Normal file
10
build/Dockerfile
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
FROM ldericher/pandocker:latest
|
||||||
|
|
||||||
|
RUN apt-get update && apt-get -y install \
|
||||||
|
inotify-tools \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
COPY autodoc.sh /usr/local/bin/autodoc
|
||||||
|
RUN chmod +x /usr/local/bin/autodoc
|
||||||
|
|
||||||
|
CMD ["autodoc"]
|
||||||
94
build/autodoc.sh
Executable file
94
build/autodoc.sh
Executable file
|
|
@ -0,0 +1,94 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# $1:WATCHROOT (default: ".")
|
||||||
|
g_watchroot="$(readlink -f "${1:-.}")"
|
||||||
|
|
||||||
|
# compile using bare make command
|
||||||
|
do_make() { # $1:DIR $2:OBJECT
|
||||||
|
# extract params
|
||||||
|
local dir="$1"
|
||||||
|
local object="$2"
|
||||||
|
|
||||||
|
# extract Makefile 'source pattern'
|
||||||
|
local srcpat="$(grep -E "^#@SRCPAT" "${dir}/Makefile" | tail -n 1 | sed -r "s/^#@SRCPAT\s+//")"
|
||||||
|
|
||||||
|
if [ -z "${srcpat}" ]; then
|
||||||
|
echo "Empty source pattern! Makefile needs '#@SRCPAT' annotation!"
|
||||||
|
|
||||||
|
elif [[ "${object}" =~ ${srcpat} ]]; then
|
||||||
|
# check for autodoc target
|
||||||
|
local target="$(grep -E "^autodoc:" "${dir}/Makefile" | sed -r "s/:.*$//")"
|
||||||
|
local target="${target:-all}"
|
||||||
|
|
||||||
|
echo "SRCPAT OK, building '${target}'."
|
||||||
|
make --no-print-directory -C "${dir}" -j "${target}"
|
||||||
|
|
||||||
|
else
|
||||||
|
echo "SRCPAT mismatch '${srcpat}'."
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# compile a directory
|
||||||
|
do_compile() { # $1:DIR $2:OBJECT $3:DONE
|
||||||
|
# extract params
|
||||||
|
local dir="$1"
|
||||||
|
local object="$2"
|
||||||
|
local done="${3:-0}"
|
||||||
|
|
||||||
|
# build systems
|
||||||
|
|
||||||
|
if [ -r "${dir}/Makefile" ]; then
|
||||||
|
# Makefile found
|
||||||
|
echo -n "Using '${dir}/Makefile'. "
|
||||||
|
do_make "${dir}" "${object}"
|
||||||
|
local done="1"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# search parent dir for more build instructions
|
||||||
|
if [ "${dir}" != "${g_watchroot}" ]; then
|
||||||
|
# never leave $g_watchroot
|
||||||
|
local dir="$(dirname "${dir}")"
|
||||||
|
do_compile "${dir}" "${object}" "${done}"
|
||||||
|
|
||||||
|
elif [ "${done}" == "0" ]; then
|
||||||
|
# hit $g_watchroot
|
||||||
|
echo "No build instructions found!"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# process an inotify event
|
||||||
|
do_handle() { # $1:FLAGS $2:OBJECT
|
||||||
|
# extract params
|
||||||
|
local flags="$1"
|
||||||
|
shift 1
|
||||||
|
local dir="$(dirname "$*")"
|
||||||
|
local object="$(basename "$*")"
|
||||||
|
|
||||||
|
if [[ "${flags}" =~ "ISDIR" ]]; then
|
||||||
|
# object refers to directory
|
||||||
|
local dir="${dir}/${object}"
|
||||||
|
local object="."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# start using toolchain
|
||||||
|
echo -n "'${object}': '${flags}' in '${dir}'. "
|
||||||
|
do_compile "${dir}" "${object}"
|
||||||
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# MAIN
|
||||||
|
#
|
||||||
|
|
||||||
|
echo "Booting ${0} in '${g_watchroot}'."
|
||||||
|
# setup inotify:
|
||||||
|
# -mrq monitor, recursive, quiet
|
||||||
|
# -e events
|
||||||
|
# --format %e eventlist csv, %w workdir, %f filename
|
||||||
|
inotifywait -mrq \
|
||||||
|
-e create -e delete -e moved_to -e close_write \
|
||||||
|
--format '%e %w%f' \
|
||||||
|
"${g_watchroot}" | \
|
||||||
|
\
|
||||||
|
while read FILE; do
|
||||||
|
do_handle ${FILE}
|
||||||
|
done
|
||||||
18
docker-compose.yml
Normal file
18
docker-compose.yml
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
version: "2"
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
phyLinux-home:
|
||||||
|
|
||||||
|
services:
|
||||||
|
autodoc:
|
||||||
|
restart: "no"
|
||||||
|
|
||||||
|
image: ldericher/autodoc
|
||||||
|
build:
|
||||||
|
context: ./build
|
||||||
|
|
||||||
|
command: "bash"
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
- "${PWD}/build/autodoc.sh:/usr/local/bin/autodoc:ro"
|
||||||
|
- "${PWD}/example_docs:/docs"
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#%SRCPAT% \.md$
|
#@SRCPAT \.md$
|
||||||
|
|
||||||
.PHONY: all
|
.PHONY: all
|
||||||
all: simple.pdf simple.html
|
all: simple.pdf simple.html
|
||||||
|
|
@ -15,7 +15,7 @@ Behold, for there is jumbled mess ahead!
|
||||||
|
|
||||||
With the default HTML template, this does not translate: \textsl{Have some \LaTeX, too!}
|
With the default HTML template, this does not translate: \textsl{Have some \LaTeX, too!}
|
||||||
Some math is fine with HTML: $x=5$, some other is not: $\sqrt{x}=2$.
|
Some math is fine with HTML: $x=5$, some other is not: $\sqrt{x}=2$.
|
||||||
However, both of these work with the `--webtex` switch for pandoc!
|
However, both of these are fixable!
|
||||||
|
|
||||||
Code blocks? Sure!
|
Code blocks? Sure!
|
||||||
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#%SRCPAT% (file|\.tex)$
|
#@SRCPAT (file|\.tex)$
|
||||||
|
|
||||||
.PHONY: all
|
.PHONY: all
|
||||||
all: files.txt
|
all: files.txt
|
||||||
5
example_docs/somedir/a directory in space/Makefile
Normal file
5
example_docs/somedir/a directory in space/Makefile
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
#@SRCPAT .*
|
||||||
|
|
||||||
|
.PHONY: all
|
||||||
|
all:
|
||||||
|
@echo "Hello World!"
|
||||||
|
|
@ -1,9 +0,0 @@
|
||||||
#%SRCPAT% .*
|
|
||||||
|
|
||||||
.PHONY: all
|
|
||||||
all:
|
|
||||||
@echo "Hello World!"
|
|
||||||
|
|
||||||
.PHONY: autodoc
|
|
||||||
autodoc:
|
|
||||||
@echo "Hello autodoc!"
|
|
||||||
1
examples/eisvogel/.gitignore
vendored
1
examples/eisvogel/.gitignore
vendored
|
|
@ -1 +0,0 @@
|
||||||
*.pdf
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
#%SRCPAT% \.url$
|
|
||||||
|
|
||||||
.PHONY: all
|
|
||||||
all: eisvogel.pdf
|
|
||||||
|
|
||||||
.PHONY: eisvogel.pdf
|
|
||||||
eisvogel.pdf: document.md.url
|
|
||||||
wget -O- '$(file < $<)' | pandoc -s -f markdown -t latex -o $@ --template eisvogel
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
https://raw.githubusercontent.com/Wandmalfarbe/pandoc-latex-template/master/examples/basic-example/document.md
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
--- diagram.lua
|
|
||||||
+++ diagram.lua
|
|
||||||
@@ -158,7 +158,7 @@
|
|
||||||
write_file(infile, code)
|
|
||||||
pipe(
|
|
||||||
self.execpath or 'mmdc',
|
|
||||||
- {"--pdfFit", "--input", infile, "--output", outfile},
|
|
||||||
+ {"--pdfFit", "--puppeteerConfigFile", "/usr/local/share/puppeteer/config.json", "--input", infile, "--output", outfile},
|
|
||||||
''
|
|
||||||
)
|
|
||||||
return read_file(outfile), mime_type
|
|
||||||
|
|
@ -1,45 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
#
|
|
||||||
# hard globals
|
|
||||||
#
|
|
||||||
|
|
||||||
g_bin="$(readlink -f "$(which "$0")")"
|
|
||||||
g_lib=${g_bin/"bin"/"lib"}
|
|
||||||
|
|
||||||
#
|
|
||||||
# load base program
|
|
||||||
#
|
|
||||||
|
|
||||||
source "${g_lib}/globals"
|
|
||||||
source "${g_lib}/logging"
|
|
||||||
source "${g_lib}/main"
|
|
||||||
|
|
||||||
for plugin in "${g_lib}/plugins/"*".sh"; do
|
|
||||||
source "${plugin}"
|
|
||||||
done
|
|
||||||
|
|
||||||
#
|
|
||||||
# MAIN
|
|
||||||
#
|
|
||||||
|
|
||||||
# show debug info
|
|
||||||
if [ ${g_verbose} -eq 1 ]; then
|
|
||||||
logline_append "Variables:"
|
|
||||||
logline_append "build:${g_build}"
|
|
||||||
logline_append "watch:${g_watch}"
|
|
||||||
logline_append "root:${g_root}"
|
|
||||||
logline_flush
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ${g_build} -eq 1 ]; then
|
|
||||||
echo "Building everything in '${g_root}'."
|
|
||||||
do_build_all
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ${g_watch} -eq 1 ]; then
|
|
||||||
echo "Watching '${g_root}'."
|
|
||||||
do_build_watch
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Done."
|
|
||||||
|
|
@ -1,68 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# array of available build systems
|
|
||||||
declare -a g_build_systems
|
|
||||||
|
|
||||||
# map of file globs for build systems
|
|
||||||
declare -A g_build_systems_glob
|
|
||||||
|
|
||||||
# map of annotation patterns for build systems
|
|
||||||
declare -A g_build_systems_annotations
|
|
||||||
|
|
||||||
# simple help page
|
|
||||||
do_show_help() {
|
|
||||||
echo "Usage: ${0} [-h?bwv] [-r ROOT] [ROOT]"
|
|
||||||
echo
|
|
||||||
echo "Options:"
|
|
||||||
echo " -h, -? Show this help and exit"
|
|
||||||
echo " -b Build ROOT directory on startup"
|
|
||||||
echo " -w Keep watching ROOT directory for changes"
|
|
||||||
echo " -v Verbose output"
|
|
||||||
echo " -r ROOT Set ROOT directory"
|
|
||||||
echo
|
|
||||||
echo "ROOT directory can be set via '-r' argument or positionally."
|
|
||||||
echo "If ROOT directory is undefined, it defaults to the current working directory."
|
|
||||||
exit 0
|
|
||||||
}
|
|
||||||
|
|
||||||
# reset in case getopts has been used previously in the shell
|
|
||||||
OPTIND=1
|
|
||||||
|
|
||||||
# initialize variables
|
|
||||||
g_build=0
|
|
||||||
g_watch=0
|
|
||||||
g_verbose=0
|
|
||||||
g_root=""
|
|
||||||
|
|
||||||
while getopts "h?bwvr:" opt; do
|
|
||||||
case "$opt" in
|
|
||||||
h|\?)
|
|
||||||
do_show_help
|
|
||||||
;;
|
|
||||||
b)
|
|
||||||
g_build=1
|
|
||||||
;;
|
|
||||||
w)
|
|
||||||
g_watch=1
|
|
||||||
;;
|
|
||||||
v)
|
|
||||||
g_verbose=1
|
|
||||||
;;
|
|
||||||
r)
|
|
||||||
g_root="${OPTARG}"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
# default to help
|
|
||||||
[ ${g_build} -eq 0 ] && [ ${g_watch} -eq 0 ] && [ ${g_verbose} -eq 0 ] && do_show_help
|
|
||||||
|
|
||||||
# shift off getopts parsed options
|
|
||||||
shift $((OPTIND-1))
|
|
||||||
[ "${1:-}" = "--" ] && shift
|
|
||||||
|
|
||||||
# if g_root undefined by getopt,
|
|
||||||
[ -z "${g_root:-}" ] && g_root="$1"
|
|
||||||
|
|
||||||
# get actual $ROOT directory (default: ".")
|
|
||||||
g_root="$(readlink -f "${g_root:-.}")"
|
|
||||||
|
|
@ -1,12 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
g_logline=""
|
|
||||||
|
|
||||||
logline_append() { # $STRING
|
|
||||||
g_logline="${g_logline}${1} "
|
|
||||||
}
|
|
||||||
|
|
||||||
logline_flush() {
|
|
||||||
echo "${g_logline}"
|
|
||||||
g_logline=""
|
|
||||||
}
|
|
||||||
|
|
@ -1,146 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# process an inotify event
|
|
||||||
do_handle_inotify() { # $FLAGS $OBJECT
|
|
||||||
# extract params
|
|
||||||
local flags="$1"
|
|
||||||
shift 1
|
|
||||||
local dir="$(dirname "$*")"
|
|
||||||
local object="$(basename "$*")"
|
|
||||||
|
|
||||||
if [[ "${flags}" =~ "ISDIR" ]]; then
|
|
||||||
# object refers to directory
|
|
||||||
local dir="${dir}/${object}"
|
|
||||||
local object="."
|
|
||||||
fi
|
|
||||||
|
|
||||||
# start using toolchain
|
|
||||||
logline_append "'${object}': '${flags}' in '${dir}'."
|
|
||||||
do_compile "${dir}" "${object}"
|
|
||||||
logline_flush
|
|
||||||
}
|
|
||||||
|
|
||||||
# compile an OBJECT using build instructions found in DIRectory
|
|
||||||
do_compile() { # $DIR $OBJECT $DONE
|
|
||||||
# extract params
|
|
||||||
local dir="$1"
|
|
||||||
local object="$2"
|
|
||||||
local done="${3:-0}"
|
|
||||||
|
|
||||||
# build systems
|
|
||||||
for build_system in ${g_build_systems[@]}; do
|
|
||||||
do_build_system "${dir}" "${build_system}" "${object}" \
|
|
||||||
&& local done="1"
|
|
||||||
done
|
|
||||||
|
|
||||||
# never leave $g_root
|
|
||||||
if [ "${dir}" != "${g_root}" ]; then
|
|
||||||
# search parent dir for more build instructions
|
|
||||||
do_compile "$(dirname "${dir}")" "${object}" "${done}"
|
|
||||||
|
|
||||||
elif [ "${done}" == "0" ]; then
|
|
||||||
# hit $g_root
|
|
||||||
logline_append "Not a source file."
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# check if defined source pattern matches OBJECT
|
|
||||||
do_check_srcpat() { # $DIR $BUILD_DESC $ANNOTATION $OBJECT
|
|
||||||
# extract params
|
|
||||||
local dir="$1"
|
|
||||||
local build_desc="$2"
|
|
||||||
local annotation="$3"
|
|
||||||
local object="$4"
|
|
||||||
|
|
||||||
# check 'source pattern'
|
|
||||||
local srcpat="$(grep -E "^${annotation}" "${dir}/${build_desc}" | tail -n 1 | sed -r "s/^${annotation}\s+//")"
|
|
||||||
|
|
||||||
if [ -z "${srcpat}" ]; then
|
|
||||||
# empty srcpat => fail
|
|
||||||
logline_append "Empty source pattern, check for '${annotation}' annotation!"
|
|
||||||
return 1
|
|
||||||
|
|
||||||
elif [ -z "${object}" ]; then
|
|
||||||
# empty object = "no specific object" => success
|
|
||||||
return 0
|
|
||||||
|
|
||||||
elif [[ "${object}" =~ ${srcpat} ]]; then
|
|
||||||
# nonempty object matches srcpat => success
|
|
||||||
return 0
|
|
||||||
|
|
||||||
else
|
|
||||||
# nonempty object does not match srcpat => fail
|
|
||||||
logline_append "SRCPAT '${srcpat}' mismatch."
|
|
||||||
return 1
|
|
||||||
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# use given BUILD_SYSTEM to process an OBJECT from a DIRectory
|
|
||||||
do_build_system() { # $DIR $BUILD_SYSTEM $OBJECT
|
|
||||||
# extract params
|
|
||||||
local dir="$1"
|
|
||||||
local build_system="$2"
|
|
||||||
local object="$3"
|
|
||||||
|
|
||||||
# not done yet
|
|
||||||
local result=1
|
|
||||||
|
|
||||||
# get glob patterns for plugin
|
|
||||||
for glob in ${g_build_systems_glob[${build_system}]}; do
|
|
||||||
# match each glob in directory
|
|
||||||
for file in "${dir}"/${glob}; do
|
|
||||||
# check file readability
|
|
||||||
if [ -r "${file}" ]; then
|
|
||||||
# actually call into build system
|
|
||||||
logline_append "Found '${file}':"
|
|
||||||
|
|
||||||
local file="$(basename "${file}")"
|
|
||||||
do_${build_system} "${dir}" "${file}" "${object}" \
|
|
||||||
&& local result=0
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
done
|
|
||||||
|
|
||||||
return ${result}
|
|
||||||
}
|
|
||||||
|
|
||||||
# force build using all systems
|
|
||||||
do_build_all() { #
|
|
||||||
# build systems
|
|
||||||
for build_system in ${g_build_systems[@]}; do
|
|
||||||
echo "Build system '${build_system}'."
|
|
||||||
for glob in ${g_build_systems_glob[${build_system}]}; do
|
|
||||||
|
|
||||||
# match each glob recursively
|
|
||||||
find "${g_root}" -iname "${glob}" | \
|
|
||||||
while read file; do
|
|
||||||
if [ -r "${file}" ]; then
|
|
||||||
# force call into build system
|
|
||||||
logline_append "Found '${file}':"
|
|
||||||
|
|
||||||
local dir="$(dirname "${file}")"
|
|
||||||
local file="$(basename "${file}")"
|
|
||||||
do_${build_system}_all "${dir}" "$(basename "${file}")"
|
|
||||||
|
|
||||||
logline_flush
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
done
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
do_build_watch() { #
|
|
||||||
# setup inotify:
|
|
||||||
# -mrq monitor, recursive, quiet
|
|
||||||
# -e events
|
|
||||||
# --format %e eventlist csv, %w workdir, %f filename
|
|
||||||
inotifywait -mrq \
|
|
||||||
-e create -e delete -e moved_to -e close_write \
|
|
||||||
--format '%e %w%f' \
|
|
||||||
"${g_root}" | \
|
|
||||||
\
|
|
||||||
while read NOTIFICATION; do
|
|
||||||
do_handle_inotify ${NOTIFICATION}
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
@ -1,57 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# plugin name
|
|
||||||
g_build_systems+=(make)
|
|
||||||
|
|
||||||
# build instruction file globs for this plugin
|
|
||||||
g_build_systems_glob[make]="Makefile *.mk"
|
|
||||||
|
|
||||||
# srcpat annotation prefix for this plugin
|
|
||||||
g_build_systems_annotations[make]='#%SRCPAT%'
|
|
||||||
|
|
||||||
# try to compile file OBJECT
|
|
||||||
do_make() { # $DIR $OBJECT $MAKEFILE
|
|
||||||
# extract params
|
|
||||||
local dir="$1"
|
|
||||||
local makefile="$2"
|
|
||||||
local object="$3"
|
|
||||||
|
|
||||||
# only run if "object" is source file
|
|
||||||
if do_check_srcpat "${dir}" "${makefile}" "${g_build_systems_annotations[make]}" "${object}"; then
|
|
||||||
do_run_make "${dir}" "${makefile}"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# try running make for MAKEFILE inside DIRectory
|
|
||||||
do_make_all() { # $DIR $MAKEFILE
|
|
||||||
# extract params
|
|
||||||
local dir="$1"
|
|
||||||
local makefile="$2"
|
|
||||||
|
|
||||||
# only run if "makefile" is relevant for autodoc
|
|
||||||
if do_check_srcpat "${dir}" "${makefile}" "${g_build_systems_annotations[make]}" ""; then
|
|
||||||
do_run_make "${dir}" "${makefile}"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# actually run GNU Make with MAKEFILE inside DIRectory
|
|
||||||
do_run_make() { # $DIR $MAKEFILE
|
|
||||||
# extract params
|
|
||||||
local dir="$1"
|
|
||||||
local makefile="$2"
|
|
||||||
|
|
||||||
# check for autodoc target
|
|
||||||
local target="$(grep -E "^autodoc:" "${dir}/${makefile}" | sed -r "s/:.*$//")"
|
|
||||||
|
|
||||||
if [ -z "${target}" ]; then
|
|
||||||
logline_append "Running 'make'!"
|
|
||||||
else
|
|
||||||
logline_append "Making '${target}'!"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# actually run "make" and save (truncated) output
|
|
||||||
local makelog="$(make --no-print-directory -C "${dir}" -f "${makefile}" -j ${target})"
|
|
||||||
logline_append "$(echo "${makelog}" | head -n 10 | sed 's/$/;/g' | tr '\n' ' ' | sed 's/ *$//')"
|
|
||||||
|
|
||||||
logline_append "Done."
|
|
||||||
}
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
--- PDFA_def.ps
|
|
||||||
+++ PDFA_def.ps
|
|
||||||
@@ -9,7 +9,7 @@
|
|
||||||
/DOCINFO pdfmark
|
|
||||||
|
|
||||||
% Define an ICC profile :
|
|
||||||
-/ICCProfile (srgb.icc) % Customise
|
|
||||||
+/ICCProfile (/usr/local/share/autodoc/sRGB.icc) % Customise
|
|
||||||
def
|
|
||||||
|
|
||||||
[/_objdef {icc_PDFA} /type /stream /OBJ pdfmark
|
|
||||||
BIN
src/usr/local/share/autodoc/compatibleWithAdobeRGB1998.icc
(Stored with Git LFS)
BIN
src/usr/local/share/autodoc/compatibleWithAdobeRGB1998.icc
(Stored with Git LFS)
Binary file not shown.
|
|
@ -1,46 +0,0 @@
|
||||||
#############
|
|
||||||
# FUNCTIONS #
|
|
||||||
#############
|
|
||||||
|
|
||||||
PDFTOOLS_GSFLAGS := \
|
|
||||||
-sDEVICE=pdfwrite \
|
|
||||||
-dNOOUTERSAVE \
|
|
||||||
-dNOPAUSE \
|
|
||||||
-dQUIET \
|
|
||||||
-dBATCH
|
|
||||||
|
|
||||||
pdftools_pdfcat = gs \
|
|
||||||
$(PDFTOOLS_GSFLAGS) \
|
|
||||||
-sPAPERSIZE=a4 \
|
|
||||||
-dFIXEDMEDIA \
|
|
||||||
-dPDFFitPage \
|
|
||||||
-dCompatibilityLevel=1.7 \
|
|
||||||
-dPDFSETTINGS=/ebook \
|
|
||||||
-sOutputFile=$(2) \
|
|
||||||
$(1)
|
|
||||||
|
|
||||||
pdftools_mkpdfa = gs \
|
|
||||||
$(PDFTOOLS_GSFLAGS) \
|
|
||||||
-dPDFA=$(1) \
|
|
||||||
-sColorConversionStrategy=RGB \
|
|
||||||
-dPDFACompatibilityPolicy=1 \
|
|
||||||
--permit-file-read=/usr/local/share/autodoc/ \
|
|
||||||
-sOutputFile=$(3) \
|
|
||||||
/usr/local/share/autodoc/PDFA_def.ps \
|
|
||||||
$(2)
|
|
||||||
|
|
||||||
############
|
|
||||||
# PATTERNS #
|
|
||||||
############
|
|
||||||
|
|
||||||
# convert PDF to PDF/A-2B
|
|
||||||
%_pdfa2.pdf: %.pdf
|
|
||||||
$(call pdftools_mkpdfa,2,$<,$@)
|
|
||||||
|
|
||||||
# convert PDF to PDF/A-3B
|
|
||||||
%_pdfa3.pdf: %.pdf
|
|
||||||
$(call pdftools_mkpdfa,3,$<,$@)
|
|
||||||
|
|
||||||
# convert PDF to PDF/A (default variant 3B)
|
|
||||||
%_pdfa.pdf: %.pdf
|
|
||||||
$(call pdftools_mkpdfa,3,$<,$@)
|
|
||||||
BIN
src/usr/local/share/autodoc/sRGB.icc
(Stored with Git LFS)
BIN
src/usr/local/share/autodoc/sRGB.icc
(Stored with Git LFS)
Binary file not shown.
|
|
@ -1,3 +0,0 @@
|
||||||
{
|
|
||||||
"args": [ "--no-sandbox" ]
|
|
||||||
}
|
|
||||||
Loading…
Reference in a new issue