diff --git a/Makefile b/Makefile index 8c2975f..0843c31 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,7 @@ MANPREFIX ?= "$(PREFIX)/share/man/man1" SYSCONFDIR ?= $(PREFIX)/etc BINS = $(wildcard bin/git-*) MANS = $(wildcard man/git-*.md) +MAN_BINS = $(filter-out man/git-extras.md, $(MANS)) MAN_HTML = $(MANS:.md=.html) MAN_PAGES = $(MANS:.md=.1) CODE_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) @@ -62,7 +63,27 @@ install: @echo "If you are a zsh user, you may want to 'source $(CODE_DIR)etc/git-extras-completion.zsh'" \ "and put this line into ~/.zshrc to enable zsh completion" -man/%.html: man/%.md +man/index.txt: $(MANS) + echo '# manuals' > $@.tmp + for file in $(sort $^) ; do \ + extra=$${file%.md} ; \ + extra=$${extra#man/} ; \ + echo "$$extra(1) $$extra" >> $@.tmp ; \ + done + mv -f $@.tmp $@ + +man/git-extras.md: $(MAN_BINS) + ln=$$(awk '/## COMMANDS/{print NR};' $@) ; \ + awk "NR <= $$ln+1" $@ > $@.tmp + for file in $(sort $^) ; do \ + head -n1 $$file | \ + sed 's/^/ - **/;s/ -- /** /' >> $@.tmp ; \ + done + ln=$$(awk '/## AUTHOR/{print NR};' $@) ; \ + awk "NR >= $$ln-1" $@ >> $@.tmp + mv -f $@.tmp $@ + +man/%.html: man/%.md man/index.txt ronn \ --manual "Git Extras" \ --html \ diff --git a/man/Readme.md b/man/Readme.md index b547596..07fa070 100644 --- a/man/Readme.md +++ b/man/Readme.md @@ -7,12 +7,12 @@ To generate documentation: 1) Start by filling out the 'man-template.md' -2) Then use a program ronn. [Get ronn from github.](https://github.com/rtomayko/ronn) +2) Then install a program ronn. [Get ronn from github.](https://github.com/rtomayko/ronn) -3) Run ronn: +3) Run make: ``` -$ ronn .md +$ make -C .. man/git-.{1,html} ``` 4) Remember, we use the following naming convention for files: @@ -21,33 +21,6 @@ $ ronn .md git-.html git-.1 git-.md -``` - - You'll need to rename the html file, as ronn probably inserted a 1 into the filename. - -## EXAMPLE - -``` -$ ronn git-effort.md - -roff: ./git-effort.1 -html: ./git-effort.1.html +man - -$ mv git-effort.1.html git-effort.html -``` - -## SHELL SCRIPT - -Alternatively you can run the `manning-up.sh` automated shell script included in the man folder. The script will recreate the git-extras index based on the list of .md files available before it runs `ronn` against each one to generate the documents as well as renaming the generated `.html` files to their desired form. - -``` -$ ./manning-up.sh -``` - -To only (re)generate a specific .md manual template and have `.1.html` renamed to `.html` yau may also use manning-up.sh. - -``` -$ ./manning-up.sh git-info.md ``` ## AUTHOR diff --git a/man/manning-up.sh b/man/manning-up.sh deleted file mode 100755 index 290fadd..0000000 --- a/man/manning-up.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env bash -set -e - -update_git_extras_index() { - echo '# manuals' > index.txt.tmp - ln=$(awk '/## COMMANDS/{print NR};' ./git-extras.md) - awk "NR <= $ln+1" git-extras.md > git-extras.md.tmp - for file in $(ls git*.md); do - extra=${file/.md/} - spaced=" " - echo "$extra(1)${spaced:${#extra}}$extra" >> index.txt.tmp; - title=$(grep -m 1 $extra"(1) -- " $file) - test "$extra" != "git-extras" && echo " - **"${title/" --"/"**"} >> git-extras.md.tmp - done - ln=$(awk '/## AUTHOR/{print NR};' ./git-extras.md) - awk "NR >= $ln-1" git-extras.md >> git-extras.md.tmp - mv -f index.txt.tmp index.txt - mv -f git-extras.md.tmp git-extras.md -} - -if [ -n "$1" ] -then - if [[ "$1" == git-extras.md ]] - then - update_git_extras_index - fi - - ronn $1 - mv -f ${1/.md/}.1.html ${1/.md/}.html -else - - update_git_extras_index - for file in $(ls git*.md); do - extra=${file/.md/} - ronn $file && mv -f $extra.1.html $extra.html - done -fi