mirror of
https://github.com/go-task/task.git
synced 2025-02-07 13:41:53 +02:00
docs: improve style guide docs (#1495)
This commit is contained in:
parent
971c3e3a01
commit
27455fc4c8
@ -3,27 +3,28 @@ slug: /styleguide/
|
|||||||
sidebar_position: 10
|
sidebar_position: 10
|
||||||
---
|
---
|
||||||
|
|
||||||
# Styleguide
|
# Style guide
|
||||||
|
|
||||||
This is the official Task styleguide for `Taskfile.yml` files. This guide
|
This is the official style guide for `Taskfile.yml` files. It provides basic
|
||||||
contains some basic instructions to keep your Taskfile clean and familiar to
|
instructions for keeping your Taskfiles clean and familiar to other users.
|
||||||
other users.
|
|
||||||
|
|
||||||
This contains general guidelines, but they don't necessarily need to be strictly
|
This guide contains general guidelines, but they do not necessarily need to be
|
||||||
followed. Feel free to disagree and proceed differently at some point if you
|
followed strictly. Feel free to disagree and do things differently if you need
|
||||||
need or want to. Also, feel free to open issues or pull requests with
|
or want to. Any improvements to this guide are welcome! Please open an issue or
|
||||||
improvements to this guide.
|
create a pull request to contribute.
|
||||||
|
|
||||||
## Use the correct order of keywords
|
## Use the suggested ordering of the main sections
|
||||||
|
|
||||||
- `version:`
|
```yaml
|
||||||
- `includes:`
|
version:
|
||||||
- Configuration ones, like `output:`, `silent:`, `method:` and `run:`
|
includes:
|
||||||
- `vars:`
|
# optional configurations (output, silent, method, run, etc.)
|
||||||
- `env:`, `dotenv:`
|
vars:
|
||||||
- `tasks:`
|
env: # followed or replaced by dotenv
|
||||||
|
tasks:
|
||||||
|
```
|
||||||
|
|
||||||
## Use 2 spaces for indentation
|
## Use two spaces for indentation
|
||||||
|
|
||||||
This is the most common convention for YAML files, and Task follows it.
|
This is the most common convention for YAML files, and Task follows it.
|
||||||
|
|
||||||
@ -42,7 +43,7 @@ tasks:
|
|||||||
- echo 'foo'
|
- echo 'foo'
|
||||||
```
|
```
|
||||||
|
|
||||||
## Separate with spaces the mains sections
|
## Separate the main sections with empty lines
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
# bad
|
# bad
|
||||||
@ -76,7 +77,7 @@ tasks:
|
|||||||
# ...
|
# ...
|
||||||
```
|
```
|
||||||
|
|
||||||
## Add spaces between tasks
|
## Separate tasks with empty lines
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
# bad
|
# bad
|
||||||
@ -111,7 +112,7 @@ tasks:
|
|||||||
- echo 'baz'
|
- echo 'baz'
|
||||||
```
|
```
|
||||||
|
|
||||||
## Use upper-case variable names
|
## Use only uppercase letters for variable names
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
# bad
|
# bad
|
||||||
@ -138,7 +139,7 @@ tasks:
|
|||||||
- go build -o {{.BINARY_NAME}} .
|
- go build -o {{.BINARY_NAME}} .
|
||||||
```
|
```
|
||||||
|
|
||||||
## Don't wrap vars in spaces when templating
|
## Avoid using whitespace when templating variables
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
# bad
|
# bad
|
||||||
@ -159,9 +160,10 @@ tasks:
|
|||||||
- echo '{{.MESSAGE}}'
|
- echo '{{.MESSAGE}}'
|
||||||
```
|
```
|
||||||
|
|
||||||
This convention is also used by most people for any Go templating.
|
This convention is also commonly used in templates for the Go programming
|
||||||
|
language.
|
||||||
|
|
||||||
## Separate task name words with a dash
|
## Use kebab case for task names
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
# bad
|
# bad
|
||||||
@ -182,7 +184,7 @@ tasks:
|
|||||||
- echo 'Do something'
|
- echo 'Do something'
|
||||||
```
|
```
|
||||||
|
|
||||||
## Use colon for task namespacing
|
## Use a colon to separate the task namespace and name
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
# good
|
# good
|
||||||
@ -200,7 +202,7 @@ tasks:
|
|||||||
|
|
||||||
This is also done automatically when using included Taskfiles.
|
This is also done automatically when using included Taskfiles.
|
||||||
|
|
||||||
## Prefer external scripts over complex multi-line commands
|
## Prefer using external scripts instead of multi-line commands
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
# bad
|
# bad
|
||||||
|
Loading…
x
Reference in New Issue
Block a user