mirror of
https://github.com/tj/git-extras.git
synced 2026-09-10 07:26:17 -04:00
Remove one of the documentation building tools
The two methods build slightly different manual pages. The Makefile based version has better headers so use it. Automatically generate git-extras.md and index.txt when building docs.
This commit is contained in:
parent
a6732ef6db
commit
317e546b0a
23
Makefile
23
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 \
|
||||
|
|
|
|||
|
|
@ -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 <filename>.md
|
||||
$ make -C .. man/git-<command>.{1,html}
|
||||
```
|
||||
|
||||
4) Remember, we use the following naming convention for files:
|
||||
|
|
@ -21,33 +21,6 @@ $ ronn <filename>.md
|
|||
git-<command>.html
|
||||
git-<command>.1
|
||||
git-<command>.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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
Loading…
Reference in a new issue