Skip to content

Commit

Permalink
fix style guide and move taplo config to .config
Browse files Browse the repository at this point in the history
  • Loading branch information
liamaharon committed Dec 1, 2023
1 parent 7cffceb commit 6d2861a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 46 deletions.
File renamed without changes.
4 changes: 2 additions & 2 deletions .gitlab/pipeline/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ check-toml-format:
- .common-refs
script:
- cargo install taplo-cli --locked --version 0.8.1
- taplo format --check
- echo "Please run `taplo format` to fix any toml formatting issues"
- taplo format --check --config .config/taplo.toml
- echo "Please run `taplo format --config .config/taplo.toml` to fix any toml formatting issues"

# More info can be found here: https://github.com/paritytech/polkadot/pull/5865
.check-runtime-migration:
Expand Down
19 changes: 0 additions & 19 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,25 +157,6 @@ will run the tests for the specified rust version and specified image

We use [zepter](https://github.com/ggwpez/zepter) to enforce features are propagated between crates correctly.

## Rust Code Style

We use the nightly version of rustfmt to enforce consistent code formatting.

You should format your code with `cargo +nightly fmt`.

To see exactly which nightly version is used, check our CI job logs.

## TOML Code Style

We use [taplo](https://taplo.tamasfe.dev/) to enforce consistent TOML formatting.

You can install it with `cargo install taplo-cli` and format your code with `taplo format`.

You may find useful

- [Taplo VSCode extension](https://marketplace.visualstudio.com/items?itemName=tamasfe.even-better-toml)
- For NeoVim, [taplo is avaliable with Mason](https://github.com/williamboman/mason-lspconfig.nvim#available-lsp-servers)

## Command Bot

If you're member of **paritytech** org - you can use command-bot to run various of common commands in CI:
Expand Down
34 changes: 9 additions & 25 deletions docs/STYLE_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
title: Style Guide for Rust in the Polkadot-SDK
---

Where possible these styles are enforced by settings in `rustfmt.toml` so if you run `cargo fmt`
Where possible these styles are enforced by settings in `rustfmt.toml` so if you run `cargo +nightly fmt`
then you will adhere to most of these style guidelines automatically.

To see exactly which nightly version is used, check our CI job logs.

# Formatting

- Indent using tabs.
Expand Down Expand Up @@ -150,31 +152,13 @@ let mut target_path =

# Manifest Formatting

> **TLDR**
> You can use the CLI tool [Zepter](https://crates.io/crates/zepter) to
> format the files: `zepter format features --fix` (or `zepter f f -f`).
We use [taplo](https://taplo.tamasfe.dev/) to enforce consistent TOML formatting.

Rust `Cargo.toml` files need to respect certain formatting rules. All entries
need to be alphabetically sorted. This makes it easier to read them and insert
new entries. The exhaustive list of rules is enforced by the CI. The general
format looks like this:
You can install it with `cargo install taplo-cli` and format your code with `taplo format --config .config/taplo.toml`.

- The feature is written as a single line if it fits within 80 chars:
See the config file for the exact rules.

```toml
[features]
default = [ "std" ]
```
You may find useful

- Otherwise the feature is broken down into multiple lines with one entry per
line. Each line is padded with one tab and no trailing spaces but a trailing
comma.

```toml
[features]
default = [
"loooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong",
# Comments go here as well ;)
"std",
]
```
- [Taplo VSCode extension](https://marketplace.visualstudio.com/items?itemName=tamasfe.even-better-toml)
- For NeoVim, [taplo is avaliable with Mason](https://github.com/williamboman/mason-lspconfig.nvim#available-lsp-servers)

0 comments on commit 6d2861a

Please sign in to comment.