mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-11 21:11:07 +00:00
Enforce consistent and correct toml formatting (#2518)
Using taplo, fixes all our broken and inconsistent toml formatting and adds CI to keep them tidy. If people want we can customise the format rules as described here https://taplo.tamasfe.dev/configuration/formatter-options.html @ggwpez, I suggest zepter is used only for checking features are propagated, and leave formatting for taplo to avoid duplicate work and conflicts. TODO - [x] Use `exclude = [...]` syntax in taplo file to ignore zombienet tests instead of deleting the dir --------- Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: Bastian Köcher <git@kchr.de>
This commit is contained in:
+9
-25
@@ -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.
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user