termux-packages/docs/FORMAT.md

67 lines
2.0 KiB
Markdown
Raw Normal View History

2019-02-12 02:45:08 +01:00
# Formatting Guidelines
All files should adhere to these formatting guidelines.
2019-02-13 00:33:20 +01:00
## Shell Script Formatting
2019-02-12 02:45:08 +01:00
2019-02-13 14:39:19 +01:00
- All `build.sh` files should be set to `644` permission.
2019-02-12 02:45:08 +01:00
- All scripts should use tabs rather than spaces.
- All parantheses of shell functions should not be preceded with a space.
2019-02-13 14:39:19 +01:00
- Avoid trailing spaces and tabs.
2019-06-08 13:31:36 +02:00
- Avoid usage of non UTF-8 encoding.
- Comments should be compact. Do not tab them if not necessary.
2019-02-13 00:33:20 +01:00
## Shell Script Coding Practices
2019-02-13 14:39:19 +01:00
- Do not define global scope variables if not necessary.
- Do not export variables if not necessary.
2019-06-08 13:31:36 +02:00
- Custom variables in build.sh scripts should be defined inside functions.
If you need a "global scope" variable at build time, just define it in
`termux_step_pre_configure()`. If you still need to define variable outside
of function, make sure that it does not use command or process substitution.
2019-02-13 14:39:19 +01:00
2019-06-08 13:31:36 +02:00
- Dollar parentheses `$()` rather than backticks ``` `` ``` should be employed
in command substitution.
2019-02-12 02:45:08 +01:00
2019-02-13 14:39:19 +01:00
- Usage of `sudo` or `su` in build scripts is disallowed.
- Utility `install` is preferred over `cp` as the file installation program.
2019-06-08 13:31:36 +02:00
- Do not hardcode version numbers. Instead, use the `$TERMUX_PKG_VERSION` and
`$TERMUX_PKG_REVISION` variables.
2019-02-13 14:39:19 +01:00
2019-06-08 13:31:36 +02:00
- Do not hardcode Termux prefix directory. Instead, use the `$TERMUX_PREFIX`
variable.
2019-02-13 00:33:20 +01:00
2019-06-08 13:31:36 +02:00
- Do not hardcode Termux home directory. Instead, use the `$TERMUX_ANDROID_HOME`
variable.
2019-02-13 00:33:20 +01:00
## Markdown Formatting
2019-02-12 02:45:08 +01:00
- All `filenames` should be under code formatting, unless they are links.
- All titles should be indented with hashes rather than equal signs.
2019-06-08 13:31:36 +02:00
- All unnumbered lists should be indented with hyphens.
2019-02-12 02:45:08 +01:00
- All Markdown should be edited on alternate line.
- All Markdown should use tabs rather than spaces.
- All `.md` should be set to `644` permission.
- All special characters should be escaped.
2019-02-12 02:45:08 +01:00
- All names of `.md` should be capitalised.
- All code blocks should be enclosed in backticks, with language specified.
2019-06-08 13:31:36 +02:00
- Lines shouldn't be longer than 80 characters.