lf/gen/docstring.sh
2018-07-05 23:09:53 +03:00

20 lines
729 B
Bash
Executable File

#!/bin/sh
# Generates `docstring.go` having `genDocString` variable with `go doc` output.
#
# This script is called in `doc.go` using `go generate` to embed the
# documentation inside the binary in order to show it on request with `-doc`
# command line flag. Thus the same documentation is used for online and
# terminal display.
tmp=gen/docstring.go
echo "// Code generated by gen/docstring.sh DO NOT EDIT." >> $tmp
echo >> $tmp
echo "package main" >> $tmp
echo >> $tmp
echo "var genDocString = \`" >> $tmp
go doc | tr "\`" "'" >> $tmp
echo "\`" >> $tmp
mv $tmp docstring.go