2018-07-05 20:09:53 +00:00
|
|
|
#!/bin/sh
|
|
|
|
# Generates `lf.1` man page using man macros with `go doc` output.
|
|
|
|
#
|
|
|
|
# This script is called in `doc.go` using `go generate` to generate a man page
|
|
|
|
# formatted with man macros from the documentation. A few additional sections
|
|
|
|
# such as `NAME` and `SYNOPSIS` are added to comply with man page conventions.
|
|
|
|
#
|
|
|
|
# Conversion logic implemented here from godoc output to man macros should not
|
|
|
|
# be considered compliant, as such it has inexact assumptions such as the use
|
|
|
|
# of spaces over tabs along with various corner cases that are not handled
|
|
|
|
# properly like character escaping. The intention here is to come up with
|
|
|
|
# something that can convert the current content in the documentation. For this
|
|
|
|
# reason, it is recommended to check the output after generation especially
|
|
|
|
# when the documentation is changed in a significant way.
|
|
|
|
|
2018-07-05 22:12:20 +00:00
|
|
|
out=lf.1
|
2018-07-05 20:09:53 +00:00
|
|
|
|
2018-07-05 22:12:20 +00:00
|
|
|
echo '.\" Code generated by gen/man.sh DO NOT EDIT.' > $out
|
2018-07-05 20:09:53 +00:00
|
|
|
|
2018-07-05 22:12:20 +00:00
|
|
|
cat << END >> $out
|
2018-07-05 20:09:53 +00:00
|
|
|
.TH LF 1
|
|
|
|
.SH NAME
|
|
|
|
lf \- terminal file manager
|
|
|
|
.SH SYNOPSIS
|
|
|
|
.SY lf
|
2021-02-21 22:45:48 +00:00
|
|
|
.OP \-command command
|
2021-04-13 20:29:26 +00:00
|
|
|
.OP \-config path
|
2018-07-05 20:09:53 +00:00
|
|
|
.OP \-cpuprofile path
|
|
|
|
.OP \-doc
|
|
|
|
.OP \-last-dir-path path
|
2022-02-06 16:43:01 +00:00
|
|
|
.OP \-log path
|
2018-07-05 20:09:53 +00:00
|
|
|
.OP \-memprofile path
|
|
|
|
.OP \-remote command
|
|
|
|
.OP \-selection-path path
|
|
|
|
.OP \-server
|
2021-05-19 20:38:05 +00:00
|
|
|
.OP \-single
|
2018-07-05 20:09:53 +00:00
|
|
|
.OP \-version
|
2021-04-13 20:29:26 +00:00
|
|
|
.OP \-help
|
2022-02-04 20:32:34 +00:00
|
|
|
.RI [ select-path ]
|
2018-07-05 20:09:53 +00:00
|
|
|
.YS
|
|
|
|
.SH DESCRIPTION
|
2018-07-05 22:12:20 +00:00
|
|
|
END
|
2018-07-05 20:09:53 +00:00
|
|
|
|
|
|
|
go doc | awk '
|
|
|
|
BEGIN {
|
|
|
|
RS = ""
|
|
|
|
start = 1
|
|
|
|
}
|
|
|
|
|
|
|
|
# preformatted
|
|
|
|
/^ / {
|
|
|
|
gsub("\\\\", "\\e", $0)
|
|
|
|
print ".PP"
|
|
|
|
print ".EX"
|
|
|
|
print $0
|
|
|
|
print ".EE"
|
|
|
|
next
|
|
|
|
}
|
|
|
|
|
|
|
|
# heading
|
|
|
|
/^[^[:punct:]]*$/ {
|
|
|
|
print ".SH", toupper($0)
|
|
|
|
start = 1
|
|
|
|
next
|
|
|
|
}
|
|
|
|
|
|
|
|
# paragraph
|
|
|
|
{
|
|
|
|
gsub("\n", " ", $0)
|
|
|
|
gsub("\\\\", "\\e", $0)
|
|
|
|
if (start) { start = 0 } else { print ".PP" }
|
|
|
|
print $0
|
|
|
|
}
|
|
|
|
' >> $out
|