scfmt

Crates.ioscfmt
lib.rsscfmt
version0.3.1
sourcesrc
created_at2022-04-14 03:45:19.191078
updated_at2022-04-19 04:28:24.191973
descriptionA tool for formatting code with structured comments
homepage
repositoryhttps://github.com/sloganking/Structured-commenting-formatter
max_upload_size
id567334
size99,995
Logan King (sloganking)

documentation

README

Structured commenting formatter (scfmt)

scfmt is a formatter designed to enable structured commenting in your code. Running scfmt after traditional code formatters, will ensure your structured comments are indented correctly and not mangled. This repository provides both a CLI for quickly formatting files, and a rust library for adding scfmt support to other projects.

Quick Links

FAQ

Features

Formatting

scfmt will format strings with bracketed structured comments, so that their contents inside them are correctly indented.

Adding Brackets

Adding brackets converts the bracketless method of structured commenting to the bracketed version. Strucutred comments must be bracketed before being run through the formatter, or else no change will take effect.

Removing Brackets

Removing brackets converts the bracketed method of structured commenting to the bracketless version. Bracketless structured comments are less verbose, but have no method of being recovered if their whitespace gets messed up. Say after running them through a traditional code formatter.

Nullifying Brackets

Nullifying brackets puts a _ character in front of any existing bracketed comments. This allows for more easily converting existing projects to being compatible with structured commenting.

What is scfmt allowed to do?

The only things scfmt is allowed to do are:

  • Create and delete //< closing comments
  • Add and remove brackets >, <> to the begining of existing comments.
  • Ensure empty lines are depth 0
  • Edit the indentation of lines for SC formatting.

What will scfmt not do?

  • Turn one line into many
  • Turn many lines into one
  • Ensure a max_width
  • Add or remove empty lines

Noteworthy bugs

  • Per issue #1, scfmt will mistake lines in multi-line strings or multi-line comments, as strucutred comments if those lines start with your language's comment starter. This means multi-line strings and comments such as the one below would get formatted, even though they should not be.
/*
//>
comment line that will get indented after formatting
//<
*/

let multi_line_str = "
//>
string line that will get indented after formatting
//<
"

Commit count: 140

cargo fmt