diff options
author | Jhon Honce <jhonce@redhat.com> | 2019-09-16 09:23:57 -0700 |
---|---|---|
committer | Jhon Honce <jhonce@redhat.com> | 2019-09-19 14:14:38 -0700 |
commit | 96bcf8cecc92c70cdb86ee288eb57795ef6395e7 (patch) | |
tree | 5dc7417b2e7c583ed7f9ddac3311d8d17c7b9558 /docs | |
parent | 408f2780a1dd94f99fe36be4573a9887e6c74cf7 (diff) | |
download | podman-96bcf8cecc92c70cdb86ee288eb57795ef6395e7.tar.gz podman-96bcf8cecc92c70cdb86ee288eb57795ef6395e7.tar.bz2 podman-96bcf8cecc92c70cdb86ee288eb57795ef6395e7.zip |
Support podman-remote help on windows
* Update scipts to produce darwin and windows output
* Update batch file to re-direct help requests to browser
* Add pandoc filter for markdown to html links
Signed-off-by: Jhon Honce <jhonce@redhat.com>
Diffstat (limited to 'docs')
-rw-r--r-- | docs/links-to-html.lua | 5 | ||||
-rwxr-xr-x | docs/podman-remote.sh | 105 |
2 files changed, 102 insertions, 8 deletions
diff --git a/docs/links-to-html.lua b/docs/links-to-html.lua new file mode 100644 index 000000000..74072a9e4 --- /dev/null +++ b/docs/links-to-html.lua @@ -0,0 +1,5 @@ +# links-to-html.lua +function Link(el) + el.target = string.gsub(el.target, "%.1.md", ".html") + return el +end diff --git a/docs/podman-remote.sh b/docs/podman-remote.sh index db3bb6d50..2f8e76d1b 100755 --- a/docs/podman-remote.sh +++ b/docs/podman-remote.sh @@ -1,11 +1,100 @@ -#!/bin/sh +#!/bin/bash -e +# Assemble remote man pages for darwin or windows from markdown files -BREWDIR=$1 -mkdir -p $BREWDIR -docs() { -[ -z $1 ] || type="-$1" -for i in $(podman-remote $1 --help | sed -n '/^Available Commands:/,/^Flags:/p'| sed -e '1d;$d' -e '/^$/d' | awk '{print $1}'); do install podman$type-$i.1 $BREWDIR 2>/dev/null || install links/podman$type-$i.1 $BREWDIR; done +PLATFORM=$1 ## windows or darwin +TARGET=$2 ## where to output files +SOURCES=${@:3} ## directories to find markdown files + +PODMAN=${PODMAN:-bin/podman-remote} ## location overridden for testing + +function usage() { + echo >&2 "$0 PLATFORM TARGET SOURCES..." + echo >&2 "PLATFORM: Is either darwin or windows." + echo >&2 "TARGET: Is the directory where files will be staged." + echo >&2 "SOURCES: Are the directories to source markdown files." +} + +function fail() { + echo >&2 -e "$@\n" + usage + exit 1 +} + +case $PLATFORM in +'darwin') + EXT=1 + PUBLISHER=darwin_fn + ;; +'windows') + EXT=1.md + PUBLISHER=windows_fn + ;; +'-help') + usage + exit 0 + ;; +*) fail '"darwin" and "windows" are currently the only supported platforms.' ;; +esac + +if [[ -z $TARGET ]]; then + fail 'TARGET directory is required' +fi + +if [[ -z $SOURCES ]]; then + fail 'At least one SOURCE directory is required' +fi + +if [[ ! -x $PODMAN ]]; then + fail "$PODMAN does not exist" +fi + +## darwin_fn copies the markdown page or link to flattened directory +function darwin_fn() { + local markdown=$1 + local file=$(basename $markdown) + local dir=$(dirname $markdown) + + if [[ -f $dir/links/$file ]]; then + markdown=$dir/links/$file + fi + install $markdown $TARGET +} + +## windows_fn converts the markdown page or link to HTML +function windows_fn() { + local markdown=$1 + local file=$(basename $markdown) + local dir=$(dirname $markdown) + + if [[ ! -f $markdown ]]; then + local link=$(sed -e 's?.so man1/\(.*\)?\1?' <$dir/links/${file%.md}) + markdown=$dir/$link.md + fi + pandoc --ascii --lua-filter=$dir/links-to-html.lua -o $TARGET/${file%.$EXT}.html $markdown +} + +## pub_pages finds and publishes the remote manual pages +function pub_pages() { + local source=$1 + local publisher=$2 + for f in $(ls $source/podman-remote*$EXT); do + $publisher $f + done + + for c in "container" "image" "pod" "volume" ""; do + local cmd=${c:+-$c} + for s in $($PODMAN $c --help | sed -n '/^Available Commands:/,/^Flags:/p' | sed -e '1d;$d' -e '/^$/d' | awk '{print $1}'); do + $publisher $source/podman$cmd-$s.$EXT + done + done } -docs -for cmd in 'container image pod volume'; do docs $cmd; done +## walk the SOURCES for markdown sources +mkdir -p $TARGET +for s in $SOURCES; do + if [[ -d $s ]]; then + pub_pages $s $PUBLISHER + else + echo >&2 "Warning: $s does not exist" + fi +done |