File: docstring.sh

package info (click to toggle)
lf 28-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 640 kB
  • sloc: sh: 129; makefile: 22; csh: 4
file content (19 lines) | stat: -rwxr-xr-x 837 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/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