Skip to content

Commit

Permalink
docs: unfinished manpage build script
Browse files Browse the repository at this point in the history
  • Loading branch information
patrick330602 committed Jan 26, 2020
1 parent 88a07a4 commit d166e95
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 27 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
out
out-docs
target
.vscode
18 changes: 14 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
AUTOMAKE_OPTIONS = foreign
HEADER = src/wslu-header
OUTPATH = out
MANPATH = docs
OUTMANPATH = out-docs
CURPATH = $(shell pwd)

SOURCES := $(wildcard src/*.sh)
Expand All @@ -16,10 +18,10 @@ all:
cat $(HEADER) $$file > $(OUTPATH)/`basename $$file`; \
mv $(OUTPATH)/`basename $$file` $(OUTPATH)/`basename $$file .sh`; \
done
chmod +x $(OUTPATH)/*
chmod +x $(OUTPFILES)

install:
install -Dm 555 docs/* -t $(DESTDIR)/share/man/man1
install -Dm 555 docs-out/* -t $(DESTDIR)/share/man/man1
install -Dm 755 out/* -t $(DESTDIR)/bin
install -Dm 555 src/etc/* -t /usr/share/wslu

Expand All @@ -32,10 +34,18 @@ uninstall:
done
rm -rf /usr/share/wslu

doc:
[ -d $(OUTMANPATH) ] || mkdir $(OUTMANPATH)
for file in $(MANFILES); do \
cp $$file $(OUTMANPATH); \
sed -i 's|DATEPLACEHOLDER|''$(date +%Y-%m-%d)''|' $(OUTMANPATH)/`basename $$file`; \
sed -i 's|VERSIONPLACEHOLDER|''$(grep 'version=' $(HEADER) | cut -d'=' -f 2 | xargs)''|' $(OUTMANPATH)/`basename $$file`; \
gzip $(OUTMANPATH)/`basename $$file`; \
rm $(OUTMANPATH)/`basename $$file`; \
done

clean:
rm -rf $(OUTPATH)

bash extras/script/doc_handler.sh

test:
extras/bats/libexec/bats tests/header.bats tests/wslsys.bats tests/wslusc.bats tests/wslupath.bats tests/wslvar.bats tests/wslfetch.bats tests/wslview.bats
32 changes: 9 additions & 23 deletions extras/scripts/builder-docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,37 +18,23 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

# get documentation from online
git clone https://github.com/wslutilities/wslu.wiki.git

OUTPATH="../../docs"
SOURCES=(wslfetch wslsys wslupath wslusc wslview wslvar)
BUILD_TIME="$(date +%Y-%m-%d)"
SOURCEPATH="../../docs"
OUTPATH="../../out-docs"
BUILD_TIME="$"

[[ -d "$OUTPATH" ]] || mkdir "$OUTPATH"

for file in "${SOURCES[@]}"; do
NAME_CAP="$(echo "$file" | tr '[:lower:]' '[:upper:]')"

# rename the filename
mv wslu.wiki/"$file".md wslu.wiki/"$file"

# generate base files using ronn
ronn --manual="$NAME_CAP" --organization="Patrick Wu" --date="$BUILD_TIME" wslu.wiki/"$file"

# cleanup folder for file modification
rm wslu.wiki/"$file".html
mv wslu.wiki/"$file" wslu.wiki/"$file".1

for file in "$(ls $SOURCEPATH)"; do
cp "$SOURCEPATH/$file" "$OUTPATH"
# Manpage Modification
sed -i "s|.TH \"$NAME_CAP\" \"\"|.TH \"$NAME_CAP\" \"1\"|" wslu.wiki/"$file".1
sed -i "s|DATEPLACEHOLDER|"$$()""|" "$OUTPATH/$file"
sed -i 's|.SH "NAME"||' wslu.wiki/"$file".1
sed -i 's|\\fBwslfetch\\fR||' wslu.wiki/"$file".1
sed -i 's|Manpage Name|NAME|' wslu.wiki/"$file".1
# gzip file and move to the destination
gzip wslu.wiki/"$file".1
mv wslu.wiki/"$file".1.gz "$OUTPATH"
# gzip file and mremove the temp file
gzip "$OUTPATH/$file"
rm "$OUTPATH/$file"
done
# cleanup temp files
Expand Down

0 comments on commit d166e95

Please sign in to comment.