nutools/lib/nulib/update-docs

65 lines
1.8 KiB
Bash
Executable File

#!/bin/bash
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
NULIB_NO_IMPORT_DEFAULTS=1
MYDIR="$(dirname -- "$0")"
source "$MYDIR/load.sh" || exit 1
NULIB_DOCDIR="$MYDIR/doc/bash"
mkdir -p "$NULIB_DOCDIR"
NULIB_DOCUMENTED_MODULES=()
function nulib_check_documented() {
local module
for module in "${NULIB_DOCUMENTED_MODULES[@]}"; do
[ "$module" == "$1" ] && return 0
done
return 1
}
function nulib__define_functions() {
function nulib_check_loaded() {
local module
for module in "${NULIB_LOADED_MODULES[@]}"; do
[ "$module" == "$1" ] && return 0
done
return 1
}
function module:() {
NULIB_MODULE="$1"
NULIB_FUNC_PREFIX="$2"
if ! nulib_check_loaded "$1"; then
NULIB_LOADED_MODULES=("${NULIB_LOADED_MODULES[@]}" "$1")
fi
if ! nulib_check_documented "$1"; then
NULIB_DOCUMENTED_MODULES=("${NULIB_DOCUMENTED_MODULES[@]}" "$1")
echo "...$NULIB_MODULE"
echo >"$NULIB_DOCDIR/$NULIB_MODULE.md" "\
-*- coding: utf-8 mode: markdown -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
# ${3:-$NULIB_MODULE}
Chargement du module sans les aliases:
~~~
require: $NULIB_MODULE
~~~
Chargement du module en important aussi les aliases:
~~~
import: $NULIB_MODULE
~~~"
fi
}
function function:() {
if [ -n "$NULIB_ALLOW_IMPORT" -a -n "$NULIB_FUNC_PREFIX" -a "${1#$NULIB_FUNC_PREFIX}" != "$1" ]; then
eval "function ${1#$NULIB_FUNC_PREFIX}() { $1 \"\$@\"; }"
fi
echo >>"$NULIB_DOCDIR/$NULIB_MODULE.md" "
## $1()"
[ "${1#$NULIB_FUNC_PREFIX}" != "$1" ] && echo >>"$NULIB_DOCDIR/$NULIB_MODULE.md" "Alias: \`${1#$NULIB_FUNC_PREFIX}()\`"
[ "${#2}" -gt 0 ] && echo >>"$NULIB_DOCDIR/$NULIB_MODULE.md" "
$2"
}
}
import: DEFAULTS