* 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
2.7 KiB
Contributing
Code contributions are always welcomed in lf.
If you are going to introduce a new feature, it is best to open an issue first for discussion. If your feature can be implemented as a configuration option please add it to the wiki.
For bug fixes, you can simply send a pull request.
Code conventions
In addition to gofmt and friends (e.g. go vet, staticcheck, golangci-lint), we have a few conventions:
- Global variables are best avoided except when they are not.
Global variable names are prefixed with
gas ingFooBar. Exceptions are variables holding values of environmental variables which are prefixed withenvas inenvFooBarand regular expressions which are prefixed withreas inreFooBarwhen they are global. - Type and function names are small case as in
fooBarsince we don't use exporting. - For file name variables,
name,fname, orfilenameshould refer to the base name of the file as inbaz.txt, andpath,fpath, orfilepathshould refer to the full path of the file as in/foo/bar/baz.txt. - Run
go fmt && go generateusing Go 1.19+. On earlier versions of Go,go generatecreates needless whitespace differences.
Use the surrounding code as reference when in doubt as usual.
Adding a new option
Adding a new option usually requires the following steps:
- Add option name/type to
gOptsstruct inopts.go - Add default option value to
initfunction inopts.go - Add option evaluation logic to
setExpr.evalineval.go - Implement the option somewhere in the code
- Add option name to
gOptWordsincomplete.gofor tab completion - Add option name and its default value to
Quick ReferenceandOptionssections indoc.go - Run
go generateto update the documentation - Commit your changes and send a pull request
Adding a new builtin command
Adding a new command usually requires the following steps:
- Add default key if any to
initfunction inopts.go - Add command evaluation logic to
callExpr.evalineval.go - Implement the command somewhere in the code
- Add command name to
gCmdWordsincomplete.gofor tab completion - Add command name to
Quick ReferenceandCommandssections indoc.go - Run
go generateto update the documentation - Commit your changes and send a pull request
Platform specific code
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 your addition works the same in both platforms, your addition probably belongs to main.go instead.