From b0b06c46d22eff53fdd67e89121df225c7672a54 Mon Sep 17 00:00:00 2001 From: Gokcehan Date: Thu, 15 Sep 2016 17:08:05 +0300 Subject: [PATCH] escape backticks in documentation --- doc.go | 48 +++++++++++++++++++++---------------- docstring.go | 61 ++++++++++++++++++++++++++++-------------------- gen/docstring.sh | 14 ++++++++++- main.go | 2 +- 4 files changed, 78 insertions(+), 47 deletions(-) diff --git a/doc.go b/doc.go index d64e879e..c755da33 100644 --- a/doc.go +++ b/doc.go @@ -10,7 +10,7 @@ at https://godoc.org/github.com/gokcehan/lf. Reference -The following commands and default keybindings are provided by lf. +The following commands are provided by lf with default keybindings. up (default "k" and "") half-up (default "") @@ -35,6 +35,11 @@ The following commands and default keybindings are provided by lf. paste (default "p") renew (default "") +The following commands are provided by lf without default keybindings. + + echo + cd + The following options can be used to customize the behavior of lf. hidden bool (default off) @@ -53,6 +58,8 @@ The following variables are exported for shell commands. $fs marked file(s) separated with ':' $fx current file or marked file(s) if any +Configuration + The configuration file should either be located in "$XDG_CONFIG_HOME/lf/lfrc" or "~/.config/lf/lfrc". A sample configuration file can be found at https://github.com/gokcehan/lf/blob/master/etc/lfrc.example. @@ -75,17 +82,17 @@ default these modes are mapped to the prefix keys above. Syntax -Characters from "#" to the line end are comments and ignored. +Characters from "#" to "\n" are comments and ignored. There are three special commands for configuration. -"set" is used to set an option which could be (1) bool (e.g. "set hidden", "set -nohidden", "set hidden!") (2) int (e.g. "set scrolloff 10") (3) string (e.g. -"set sortby time"). +"set" is used to set an option which could be bool (e.g. "set hidden", "set +nohidden", "set hidden!"), int (e.g. "set scrolloff 10"), or string (e.g. "set +sortby time"). -"map" is used to bind a key to a command which could be (1) built-in command -(e.g. "map gh cd ~") (2) custom command (e.g. "map D trash") (3) shell command -(e.g. "map i $less "$f"", "map u !du -h . | less"). You can delete an existing +"map" is used to bind a key to a command which could be built-in command (e.g. +"map gh cd ~"), custom command (e.g. "map D trash"), or shell command (e.g. +"map i $less "$f"", "map u !du -h . | less"). You can delete an existing binding by leaving the expression empty (e.g. "map gh"). "cmd" is used to define a custom command or delete an existing command by @@ -96,20 +103,10 @@ group statements until a "\n" occurs. This is especially useful for "map" and "cmd" commands. If you need multiline you can wrap statements in "{{" and "}}" after the proper prefix. -File Operations - -lf uses the underlying "cp" and "mv" shell commands for file operations. For -this purpose, when you "yank" (i.e. copy) a file, it doesn't actually copy the -file on the disk, but only records its name to memory. The actual file -operation takes place when you do the "paste" in which case the "cp" command is -used. Similarly the "mv" command is used for "delete" (i.e. cut or kill) -followed by "paste". These traditional names (e.g. "yank" and "delete") are -picked instead of the other common convention (e.g. copy and cut) to resemble -the default keybinds for these operations. - Custom Commands -To wrap up let us write a shell command to move selected file(s) to trash. +For demonstration let us write a shell command to move selected file(s) to +trash. A first attempt to write such a command may look like this: @@ -150,6 +147,17 @@ This could be especially useful for interactive use (e.g. "rm $fs" would simply work). This option is not set by default as things may behave unexpectedly at other places. +File Operations + +lf uses the underlying "cp" and "mv" shell commands for file operations. For +this purpose, when you "yank" (i.e. copy) a file, it doesn't actually copy the +file on the disk, but only records its name to memory. The actual file +operation takes place when you do the "paste" in which case the "cp" command is +used. Similarly the "mv" command is used for "delete" (i.e. cut or kill) +followed by "paste". These traditional names (e.g. "yank" and "delete") are +picked instead of the other common convention (e.g. copy and cut) to resemble +the default keybinds for these operations. + Opening Files You can use "open-file" command to open a file. This is a special command diff --git a/docstring.go b/docstring.go index 2739905a..8cb924cc 100644 --- a/docstring.go +++ b/docstring.go @@ -2,7 +2,8 @@ package main -var genDocString = `lf is a terminal file manager. +var genDocString = ` +lf is a terminal file manager. Source code can be found in the repository at https://github.com/gokcehan/lf. @@ -13,7 +14,7 @@ online at https://godoc.org/github.com/gokcehan/lf. Reference -The following commands and default keybindings are provided by lf. +The following commands are provided by lf with default keybindings. up (default "k" and "") half-up (default "") @@ -38,6 +39,11 @@ The following commands and default keybindings are provided by lf. paste (default "p") renew (default "") +The following commands are provided by lf without default keybindings. + + echo + cd + The following options can be used to customize the behavior of lf. hidden bool (default off) @@ -56,6 +62,9 @@ The following variables are exported for shell commands. $fs marked file(s) separated with ':' $fx current file or marked file(s) if any + +Configuration + The configuration file should either be located in "$XDG_CONFIG_HOME/lf/lfrc" or "~/.config/lf/lfrc". A sample configuration file can be found at @@ -81,43 +90,32 @@ that by default these modes are mapped to the prefix keys above. Syntax -Characters from "#" to the line end are comments and ignored. +Characters from "#" to "\n" are comments and ignored. There are three special commands for configuration. -"set" is used to set an option which could be (1) bool (e.g. "set hidden", -"set nohidden", "set hidden!") (2) int (e.g. "set scrolloff 10") (3) string -(e.g. "set sortby time"). +"set" is used to set an option which could be bool (e.g. "set hidden", "set +nohidden", "set hidden!"), int (e.g. "set scrolloff 10"), or string (e.g. +"set sortby time"). -"map" is used to bind a key to a command which could be (1) built-in command -(e.g. "map gh cd ~") (2) custom command (e.g. "map D trash") (3) shell -command (e.g. "map i $less "$f"", "map u !du -h . | less"). You can delete -an existing binding by leaving the expression empty (e.g. "map gh"). +"map" is used to bind a key to a command which could be built-in command +(e.g. "map gh cd ~"), custom command (e.g. "map D trash"), or shell command +(e.g. "map i $less "$f"", "map u !du -h . | less"). You can delete an +existing binding by leaving the expression empty (e.g. "map gh"). "cmd" is used to define a custom command or delete an existing command by leaving the expression empty (e.g. "cmd trash"). If there is no prefix then ":" is assumed. An explicit ":" could be provided -to group statements until a " -" occurs. This is especially useful for "map" +to group statements until a "\n" occurs. This is especially useful for "map" and "cmd" commands. If you need multiline you can wrap statements in "{{" and "}}" after the proper prefix. -Yank/Delete/Paste - -lf uses the underlying "cp" and "mv" shell commands for file operations. For -this purpose, when you "yank" (i.e. copy) a file, it doesn't actually copy -the file on the disk, but only records its name to memory. The actual file -operation takes place when you do the "paste" in which case the "cp" command -is used. Similarly the "mv" command is used for "delete" (i.e. cut or kill) -followed by "paste". These traditional names (e.g. "yank" and "delete") are -picked instead of the other common convention (e.g. copy and cut) to -resemble the default keybinds for these operations. - Custom Commands -To wrap up let us write a shell command to move selected file(s) to trash. +For demonstration let us write a shell command to move selected file(s) to +trash. A first attempt to write such a command may look like this: @@ -160,6 +158,18 @@ would simply work). This option is not set by default as things may behave unexpectedly at other places. +File Operations + +lf uses the underlying "cp" and "mv" shell commands for file operations. For +this purpose, when you "yank" (i.e. copy) a file, it doesn't actually copy +the file on the disk, but only records its name to memory. The actual file +operation takes place when you do the "paste" in which case the "cp" command +is used. Similarly the "mv" command is used for "delete" (i.e. cut or kill) +followed by "paste". These traditional names (e.g. "yank" and "delete") are +picked instead of the other common convention (e.g. copy and cut) to +resemble the default keybinds for these operations. + + Opening Files You can use "open-file" command to open a file. This is a special command @@ -187,4 +197,5 @@ lf does not come bundled with a file opener. You can use any of the existing file openers as you like. Possible options are "open" (for Mac OS X only), "xdg-utils" (executable name is "xdg-open"), "libfile-mimeinfo-perl" (executable name is "mimeopen"), "rifle" (ranger's default file opener), or -"mimeo" to name a few.` +"mimeo" to name a few. +` diff --git a/gen/docstring.sh b/gen/docstring.sh index c4d248f3..678e7356 100755 --- a/gen/docstring.sh +++ b/gen/docstring.sh @@ -6,4 +6,16 @@ # command line flag. Thus the same documentation is used for online and # terminal display. -echo "// DO NOT EDIT! (AUTO-GENERATED)\n\npackage main\n\nvar genDocString = \`$(go doc)\`" > docstring.go +tmp=$(mktemp) + +[ -f docstring.go ] && rm docstring.go + +echo "// DO NOT EDIT! (AUTO-GENERATED)" >> $tmp +echo >> $tmp +echo "package main" >> $tmp +echo >> $tmp +echo "var genDocString = \`" >> $tmp +go doc | tr "\`" "'" >> $tmp +echo "\`" >> $tmp + +mv $tmp docstring.go diff --git a/main.go b/main.go index af60071d..a5946b71 100644 --- a/main.go +++ b/main.go @@ -75,7 +75,7 @@ func main() { flag.Parse() if *showDoc { - fmt.Println(genDocString) + fmt.Print(genDocString) return }