From e406d80377858f37ce683163b2b0ce45e59cfe9f Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Sun, 8 Oct 2023 08:26:37 -0300 Subject: Init server infrastructure files --- aux/.gitignore | 1 + aux/commonmark.sh | 99 +++++++++++++++++++++++++++++++++++ aux/favicon.html | 1 + aux/favicon.svg | 62 ++++++++++++++++++++++ aux/makehelp.sh | 149 +++++++++++++++++++++++++++++++++++++++++++++++++++++ aux/preamble.md.in | 19 +++++++ 6 files changed, 331 insertions(+) create mode 100644 aux/.gitignore create mode 100755 aux/commonmark.sh create mode 100644 aux/favicon.html create mode 100644 aux/favicon.svg create mode 100755 aux/makehelp.sh create mode 100644 aux/preamble.md.in (limited to 'aux') 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 @@ + 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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 +[@MAILING_LIST@] +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*. + -- cgit v1.2.3