diff options
Diffstat (limited to 'aux')
-rw-r--r-- | aux/.gitignore | 1 | ||||
-rwxr-xr-x | aux/commonmark.sh | 99 | ||||
-rw-r--r-- | aux/favicon.html | 1 | ||||
-rw-r--r-- | aux/favicon.svg | 62 | ||||
-rwxr-xr-x | aux/makehelp.sh | 149 | ||||
-rw-r--r-- | aux/preamble.md.in | 19 |
6 files changed, 331 insertions, 0 deletions
diff --git a/aux/.gitignore b/aux/.gitignore new file mode 100644 index 0000000..da8cb46 --- /dev/null +++ b/aux/.gitignore @@ -0,0 +1 @@ +/preamble.md diff --git a/aux/commonmark.sh b/aux/commonmark.sh new file mode 100755 index 0000000..7f56e53 --- /dev/null +++ b/aux/commonmark.sh @@ -0,0 +1,99 @@ +#!/bin/sh +set -eu + +. tests/lib.sh + + +usage() { + cat <<-'EOF' + Usage: + sh aux/commonmark.sh -N NAME_UC -t TITLE -l LANG [-H HEADER] + sh aux/commonmark.sh -h + EOF +} + +help() { + cat <<-'EOF' + + + Options: + -N NAME_UC the UpperCase name of the project + -t TITLE the title of the page + -l LANG the language of this page + -H HEADER extra header content to be included as a file + -h, --help show this message + + + Consume CommonMark data from STDIN and emit HTML5 to STDOUT, + using NAME_UC, TITLE and LANG as metadata, and allowing extra + HTML to be injected via HEADER. + + + Examples: + + Generate `index.html` from `README.md`: + + $ sh aux/commonmark.sh -N MyProj -t Home -l en -H extra.html < README.md > index.html + EOF +} + + +for flag in "$@"; do + case "$flag" in + (--) + break + ;; + (--help) + usage + help + exit + ;; + (*) + ;; + esac +done + +while getopts 'N:t:l:H:h' flag; do + case "$flag" in + (N) + NAME_UC="$OPTARG" + ;; + (t) + TITLE="$OPTARG" + ;; + (l) + THE_LANG="$OPTARG" + ;; + (H) + HEADER="$OPTARG" + ;; + (h) + usage + help + exit + ;; + (*) + usage >&2 + exit 2 + ;; + esac +done +shift $((OPTIND - 1)) + +eval "$(assert_arg "${NAME_UC:-}" '-N NAME_UC')" +eval "$(assert_arg "${TITLE:-}" '-t TITLE')" +eval "$(assert_arg "${THE_LANG:-}" '-l THE_LANG')" + + +THE_TITLE="$NAME_UC | $TITLE" + +pandoc \ + --toc \ + --toc-depth=2 \ + -s \ + --metadata title="$THE_TITLE" \ + --metadata "lang=$THE_LANG" \ + -r commonmark \ + -w html \ + -H aux/favicon.html \ + ${HEADER:+-H} ${HEADER:-} diff --git a/aux/favicon.html b/aux/favicon.html new file mode 100644 index 0000000..8f9327c --- /dev/null +++ b/aux/favicon.html @@ -0,0 +1 @@ +<link rel="icon" type="image/svg+xml" href="favicon.svg" /> diff --git a/aux/favicon.svg b/aux/favicon.svg new file mode 100644 index 0000000..ce566b2 --- /dev/null +++ b/aux/favicon.svg @@ -0,0 +1,62 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"> + <path d="M 0 8 L 1 8 L 1 9 L 0 9 L 0 8 Z" /> + <path d="M 0 13 L 1 13 L 1 14 L 0 14 L 0 13 Z" /> + <path d="M 1 8 L 2 8 L 2 9 L 1 9 L 1 8 Z" /> + <path d="M 1 13 L 2 13 L 2 14 L 1 14 L 1 13 Z" /> + <path d="M 2 8 L 3 8 L 3 9 L 2 9 L 2 8 Z" /> + <path d="M 2 13 L 3 13 L 3 14 L 2 14 L 2 13 Z" /> + <path d="M 3 8 L 4 8 L 4 9 L 3 9 L 3 8 Z" /> + <path d="M 3 13 L 4 13 L 4 14 L 3 14 L 3 13 Z" /> + <path d="M 4 7 L 5 7 L 5 8 L 4 8 L 4 7 Z" /> + <path d="M 4 8 L 5 8 L 5 9 L 4 9 L 4 8 Z" /> + <path d="M 4 13 L 5 13 L 5 14 L 4 14 L 4 13 Z" /> + <path d="M 5 6 L 6 6 L 6 7 L 5 7 L 5 6 Z" /> + <path d="M 5 7 L 6 7 L 6 8 L 5 8 L 5 7 Z" /> + <path d="M 5 13 L 6 13 L 6 14 L 5 14 L 5 13 Z" /> + <path d="M 6 5 L 7 5 L 7 6 L 6 6 L 6 5 Z" /> + <path d="M 6 6 L 7 6 L 7 7 L 6 7 L 6 6 Z" /> + <path d="M 6 14 L 7 14 L 7 15 L 6 15 L 6 14 Z" /> + <path d="M 7 1 L 8 1 L 8 2 L 7 2 L 7 1 Z" /> + <path d="M 7 14 L 8 14 L 8 15 L 7 15 L 7 14 Z" /> + <path d="M 7 15 L 8 15 L 8 16 L 7 16 L 7 15 Z" /> + <path d="M 7 2 L 8 2 L 8 3 L 7 3 L 7 2 Z" /> + <path d="M 7 3 L 8 3 L 8 4 L 7 4 L 7 3 Z" /> + <path d="M 7 4 L 8 4 L 8 5 L 7 5 L 7 4 Z" /> + <path d="M 7 5 L 8 5 L 8 6 L 7 6 L 7 5 Z" /> + <path d="M 8 1 L 9 1 L 9 2 L 8 2 L 8 1 Z" /> + <path d="M 8 15 L 9 15 L 9 16 L 8 16 L 8 15 Z" /> + <path d="M 9 1 L 10 1 L 10 2 L 9 2 L 9 1 Z" /> + <path d="M 9 2 L 10 2 L 10 3 L 9 3 L 9 2 Z" /> + <path d="M 9 6 L 10 6 L 10 7 L 9 7 L 9 6 Z" /> + <path d="M 9 15 L 10 15 L 10 16 L 9 16 L 9 15 Z" /> + <path d="M 10 2 L 11 2 L 11 3 L 10 3 L 10 2 Z" /> + <path d="M 10 3 L 11 3 L 11 4 L 10 4 L 10 3 Z" /> + <path d="M 10 4 L 11 4 L 11 5 L 10 5 L 10 4 Z" /> + <path d="M 10 5 L 11 5 L 11 6 L 10 6 L 10 5 Z" /> + <path d="M 10 6 L 11 6 L 11 7 L 10 7 L 10 6 Z" /> + <path d="M 11 6 L 12 6 L 12 7 L 11 7 L 11 6 Z" /> + <path d="M 11 8 L 12 8 L 12 9 L 11 9 L 11 8 Z" /> + <path d="M 10 15 L 11 15 L 11 16 L 10 16 L 10 15 Z" /> + <path d="M 11 10 L 12 10 L 12 11 L 11 11 L 11 10 Z" /> + <path d="M 11 12 L 12 12 L 12 13 L 11 13 L 11 12 Z" /> + <path d="M 11 14 L 12 14 L 12 15 L 11 15 L 11 14 Z" /> + <path d="M 11 15 L 12 15 L 12 16 L 11 16 L 11 15 Z" /> + <path d="M 12 6 L 13 6 L 13 7 L 12 7 L 12 6 Z" /> + <path d="M 12 8 L 13 8 L 13 9 L 12 9 L 12 8 Z" /> + <path d="M 12 10 L 13 10 L 13 11 L 12 11 L 12 10 Z" /> + <path d="M 12 12 L 13 12 L 13 13 L 12 13 L 12 12 Z" /> + <path d="M 12 14 L 13 14 L 13 15 L 12 15 L 12 14 Z" /> + <path d="M 13 6 L 14 6 L 14 7 L 13 7 L 13 6 Z" /> + <path d="M 13 8 L 14 8 L 14 9 L 13 9 L 13 8 Z" /> + <path d="M 13 10 L 14 10 L 14 11 L 13 11 L 13 10 Z" /> + <path d="M 13 12 L 14 12 L 14 13 L 13 13 L 13 12 Z" /> + <path d="M 13 13 L 14 13 L 14 14 L 13 14 L 13 13 Z" /> + <path d="M 13 14 L 14 14 L 14 15 L 13 15 L 13 14 Z" /> + <path d="M 14 7 L 15 7 L 15 8 L 14 8 L 14 7 Z" /> + <path d="M 14 8 L 15 8 L 15 9 L 14 9 L 14 8 Z" /> + <path d="M 14 9 L 15 9 L 15 10 L 14 10 L 14 9 Z" /> + <path d="M 14 10 L 15 10 L 15 11 L 14 11 L 14 10 Z" /> + <path d="M 14 11 L 15 11 L 15 12 L 14 12 L 14 11 Z" /> + <path d="M 14 12 L 15 12 L 15 13 L 14 13 L 14 12 Z" /> +</svg> diff --git a/aux/makehelp.sh b/aux/makehelp.sh new file mode 100755 index 0000000..39a38ca --- /dev/null +++ b/aux/makehelp.sh @@ -0,0 +1,149 @@ +#!/bin/sh +set -eu + +. tests/lib.sh + + +usage() { + cat <<-'EOF' + Usage: + makehelp.sh < MAKEFILE + makehelp.sh -h + EOF +} + +help() { + cat <<-'EOF' + + + Options: + -h, --help show this message + + + Generate a help message from the given Makefile. + + Any target or variable commented with two "#" characters gets + picked up. Multi-line comments are supported: + + VAR1 = 1 + # a comment + VAR2 = 2 + ## another comment -> this one is included in the docs + VAR3 = 3 + + ## with a big + ## comment, which is also included + a-target: + + + Examples: + + Generate help messages from "Makefile": + + $ aux/makehelp.sh < Makefile + + + Generate help messages for all targets: + + $ cat Makefile dev.mk | aux/makehelp.sh + EOF +} + + +for flag in "$@"; do + case "$flag" in + (--) + break + ;; + (--help) + usage + help + exit + ;; + (*) + ;; + esac +done + +while getopts 'h' flag; do + case "$flag" in + (h) + usage + help + exit + ;; + (*) + usage >&2 + exit 2 + ;; + esac +done +shift $((OPTIND - 1)) + + +TARGETS="$(mkstemp)" +VARIABLES="$(mkstemp)" +trap 'rm -f "$TARGETS" "$VARIABLES"' EXIT + +awk -vCOLUMN=15 -vTARGETS="$TARGETS" -vVARIABLES="$VARIABLES" ' +function indent(n, where) { + for (INDENT = 0; INDENT < n; INDENT++) { + printf " " > where + } +} + +/^## / { doc[len++] = substr($0, 4) } + +/^[-_a-zA-Z]+:/ && len { + printf "\033[36m%s\033[0m", substr($1, 1, length($1) - 1) > TARGETS + for (i = 0; i < len; i++) { + n = COLUMN - (i == 0 ? length($1) - 1 : 0) + indent(n, TARGETS) + printf "%s\n", doc[i] > TARGETS + } + len = 0 +} + +/^.++=/ && len { + printf "\033[36m%s\033[0m", $1 > VARIABLES + for (i = 0; i < len; i++) { + n = COLUMN - (i == 0 ? length($1) : 0) + indent(n, VARIABLES) + printf "%s\n", doc[i] > VARIABLES + } + len = 0 +}' + + + +indent() { + sed 's|^| |' +} + +cat <<-EOF + Usage: + + make [VARIABLE=value...] [target...] + + + Targets: + + $(indent < "$TARGETS") + + + Variables: + + $(indent < "$VARIABLES") + + + Examples: + + Build "all", the default target: + + $ make + + + Test and install, with \$(DESTDIR) set to "tmp/": + + $ make DESTDIR=tmp check install +EOF diff --git a/aux/preamble.md.in b/aux/preamble.md.in new file mode 100644 index 0000000..a8b7710 --- /dev/null +++ b/aux/preamble.md.in @@ -0,0 +1,19 @@ +# About + +TODOs for [@NAME@](https://@URL@). + +Register a new one at +<span id="new">[@MAILING_LIST@]</span> +and see [existing discussions]. + +[@MAILING_LIST@]: mailto:@MAILING_LIST@?subject=%20BUG%20or%20TASK%3A%20%3Cdescription%3E +[existing discussions]: https://@URL@/discussions/ + +*Você também pode escrever em português*. + +*Vous pouvez aussi écrire en français*. + +*Vi povas ankaŭ skribi esperante*. + +*Tu también puedes escribir en español*. + |