From 6e4d4219d2f1a7f68d1ea169f8b2985f1c9e8952 Mon Sep 17 00:00:00 2001 From: Joyce Siqueira <98593770+the-right-joyce@users.noreply.github.com> Date: Sat, 26 Aug 2023 08:29:23 +0200 Subject: [PATCH] add manifest formatting --- docs/STYLE_GUIDE.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/docs/STYLE_GUIDE.md b/docs/STYLE_GUIDE.md index 8854f885a4b2..bf015098a16b 100644 --- a/docs/STYLE_GUIDE.md +++ b/docs/STYLE_GUIDE.md @@ -147,3 +147,26 @@ let mut target_path = - how likely is it that invariants could be violated, - are issues stemming from the use of unsafe code caught by existing tests/tooling, - what are the consequences if the problems slip into production. + +# Manifest Formatting + +> **TLDR** +> You can use the CLI tool [Zepter](https://crates.io/crates/zepter) to format the files: `zepter format features` + +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: + +- The feature is written as a single line if it fits within 80 chars: +```toml +[features] +default = [ "std" ] +``` + +- 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", +] +``` \ No newline at end of file