Skip to main content

Module formatter

Module formatter 

Source
Expand description

Sage source code formatter.

Provides an opinionated, non-configurable formatter for Sage source code. Similar in spirit to gofmt and rustfmt.

§Formatting Rules

  • Indent with 4 spaces (no tabs)
  • One blank line between top-level declarations
  • Two blank lines before run statement
  • Handler ordering: on starton messageon erroron stop
  • Binary operators with spaces either side
  • Closing braces on their own line
  • Spawn initializer fields: one per line if >2 fields, inline if ≤2

Functions§

format
Formats a Sage program into canonical source code.