use markdown for the documentation (#1474)

* add doc.md

* use h2 for doc sections

* use h3 for doc commands/options/vars

* use backticks instead of quotes in the doc

* merge multiple commands/options in the doc

* change header levels in the doc

* add man page sections to the doc

* remove extra spaces in headers in the doc

* add man and plain conversions of the doc

* update doc

* add missing flags to the doc

* replace the old documentation with the new one

* remove old doc files

* remove the doc instructions from CONTRIBUTING.md

* change the links to the doc

* shorten long links in the readme
This commit is contained in:
Gökçehan Kara authored and GitHub committed 2023-11-12 15:43:06 +01:00
1 parent ade9e986e5
commit 9698ecddf1
10 files changed
+4638 -4063

No files matched your search

-11
View File
@@ -49,14 +49,3 @@ Adding a new command usually requires the following steps:
There are two files named `os.go` and `os_windows.go` for unix and windows specific code respectively. There are two files named `os.go` and `os_windows.go` for unix and windows specific code respectively.
If you add something to either of these files but not the other, you probably break the build for the other platform. If you add something to either of these files but not the other, you probably break the build for the other platform.
If your addition works the same in both platforms, your addition probably belongs to `main.go` instead. If your addition works the same in both platforms, your addition probably belongs to `main.go` instead.
## Make changes to the documentation
There are three files that contain the documentation in various formats:
- `doc.go` is the source of the [online documentation](https://pkg.go.dev/github.com/gokcehan/lf)
- `docstring.go` is used when running `lf -doc`
- `lf.1` is a man page which is commonly available on Unix-like operating systems (`man lf`)
You should only make changes to `doc.go`, the other files are automatically generated **and should not be edited manually**.
Run `go fmt && go generate` to ensure that the code is formatted and files are generated correctly.
+3 -3
View File
@@ -1,13 +1,13 @@
# LF # LF
[Google Groups](https://groups.google.com/forum/#!forum/lf-fm) [Google Groups](https://groups.google.com/forum/#!forum/lf-fm)
| [Doc](doc.md)
| [Wiki](https://github.com/gokcehan/lf/wiki) | [Wiki](https://github.com/gokcehan/lf/wiki)
| [#lf](https://web.libera.chat/#lf) (on Libera.Chat) | [#lf](https://web.libera.chat/#lf) (on Libera.Chat)
| [#lf:matrix.org](https://matrix.to/#/#lf:matrix.org) (with IRC bridge) | [#lf:matrix.org](https://matrix.to/#/#lf:matrix.org) (with IRC bridge)
[![Go Build](https://github.com/gokcehan/lf/actions/workflows/go.yml/badge.svg)](https://github.com/gokcehan/lf/actions/workflows/go.yml) [![Go Build](https://github.com/gokcehan/lf/actions/workflows/go.yml/badge.svg)](https://github.com/gokcehan/lf/actions/workflows/go.yml)
[![Go Report Card](https://goreportcard.com/badge/github.com/gokcehan/lf)](https://goreportcard.com/report/github.com/gokcehan/lf) [![Go Report Card](https://goreportcard.com/badge/github.com/gokcehan/lf)](https://goreportcard.com/report/github.com/gokcehan/lf)
[![Go Reference](https://pkg.go.dev/badge/github.com/gokcehan/lf.svg)](https://pkg.go.dev/github.com/gokcehan/lf)
`lf` (as in "list files") is a terminal file manager written in Go with a heavy inspiration from ranger file manager. `lf` (as in "list files") is a terminal file manager written in Go with a heavy inspiration from ranger file manager.
See [faq](https://github.com/gokcehan/lf/wiki/FAQ) for more information and [tutorial](https://github.com/gokcehan/lf/wiki/Tutorial) for a gentle introduction with screencasts. See [faq](https://github.com/gokcehan/lf/wiki/FAQ) for more information and [tutorial](https://github.com/gokcehan/lf/wiki/Tutorial) for a gentle introduction with screencasts.
@@ -24,7 +24,7 @@ See [faq](https://github.com/gokcehan/lf/wiki/FAQ) for more information and [tut
- Server/client architecture and remote commands to manage multiple instances - Server/client architecture and remote commands to manage multiple instances
- Extendable and configurable with shell commands - Extendable and configurable with shell commands
- Customizable keybindings (vi and readline defaults) - Customizable keybindings (vi and readline defaults)
- A reasonable set of other features (see the [documentation](https://pkg.go.dev/github.com/gokcehan/lf)) - A reasonable set of other features (see the [documentation](doc.md))
## Non-Features ## Non-Features
@@ -66,7 +66,7 @@ After the installation `lf` command should start the application in the current
Run `lf -help` to see command line options. Run `lf -help` to see command line options.
Run `lf -doc` to see the [documentation](https://pkg.go.dev/github.com/gokcehan/lf). Run `lf -doc` to see the [documentation](doc.md).
See [etc](etc) directory to integrate `lf` to your shell and/or editor. See [etc](etc) directory to integrate `lf` to your shell and/or editor.
Example configuration files along with example colors and icons files can also be found in this directory. Example configuration files along with example colors and icons files can also be found in this directory.
+390 -401
View File
File diff suppressed because it is too large. Load diff
+2258
View File
File diff suppressed because it is too large. Load diff
-1989
View File
File diff suppressed because it is too large. Load diff
Executable
+30
View File
@@ -0,0 +1,30 @@
#!/bin/sh
# Generates `lf.1` and `doc.txt` from the `doc.md` file.
#
# This script is used to generate a man page and a plain text conversion of the
# markdown documentation using pandoc (https://pandoc.org/). GitHub Flavored
# Markdown (GFM) (https://github.github.com/gfm/) is used for the markdown
# input format. The markdown file is automatically rendered in the GitHub
# repository (https://github.com/gokcehan/lf/blob/master/doc.md). The man page
# file `lf.1` is meant to be used for installations on Unix systems. The plain
# text file `doc.txt` is embedded in the binary to be displayed on request with
# the `-doc` command line flag. Thus the same documentation is used for online
# and terminal display.
[ -z $version ] && version=$(git describe --tags)
[ -z $date ] && date=$(date +%F)
pandoc \
--standalone \
--from gfm --to man \
--metadata=title:"LF" \
--metadata=section:"1" \
--metadata=date:"$date" \
--metadata=footer:"$version" \
--metadata=header:"DOCUMENTATION" \
doc.md -o lf.1
pandoc \
--standalone \
--from gfm --to plain \
doc.md -o doc.txt
-19
View File
@@ -1,19 +0,0 @@
#!/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
-75
View File
@@ -1,75 +0,0 @@
#!/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.
out=lf.1
echo '.\" Code generated by gen/man.sh DO NOT EDIT.' > $out
cat << END >> $out
.TH LF 1
.SH NAME
lf \- terminal file manager
.SH SYNOPSIS
.SY lf
.OP \-command command
.OP \-config path
.OP \-cpuprofile path
.OP \-doc
.OP \-last-dir-path path
.OP \-log path
.OP \-memprofile path
.OP \-remote command
.OP \-selection-path path
.OP \-server
.OP \-single
.OP \-version
.OP \-help
.RI [ cd-or-select-path ]
.YS
.SH DESCRIPTION
END
go doc | awk '
BEGIN {
RS = ""
start = 1
}
# preformatted
/^ / {
gsub("\\\\", "\\e", $0)
print ".PP"
print ".EX"
print $0
print ".EE"
next
}
# heading
/^# *[^[:punct:]]*$/ {
gsub(/# */, "", $0)
print ".SH", toupper($0)
start = 1
next
}
# paragraph
{
gsub("\n", " ", $0)
gsub("\\\\", "\\e", $0)
if (start) { start = 0 } else { print ".PP" }
print $0
}
' >> $out
+1952 -1565
View File
File diff suppressed because it is too large. Load diff
+5
View File
@@ -14,6 +14,11 @@ import (
"strings" "strings"
) )
import _ "embed"
//go:embed doc.txt
var genDocString string
var ( var (
envPath = os.Getenv("PATH") envPath = os.Getenv("PATH")
envLevel = os.Getenv("LF_LEVEL") envLevel = os.Getenv("LF_LEVEL")