CodeFormatter`
CodeFormatter`
CodeFormat
CodeFormat["code"]
formats a string of WL code returning a string.
CodeFormat[File[src]]
formats a file of WL code returning a string.
更多信息和选项
- The following options can be given:
-
Airiness 0 high-level control of amount of whitespace and newlines "IndentationString" " " string to use for indentation "LineWidth" 78 width of lines before line breaking occurs "NewlineString" "\n" string to use for newlines "NewlinesBetweenCommas" Automatic low-level control for newlines between commas "NewlinesBetweenSemicolons" Automatic low-level control for newlines between semicolons "NewlinesBetweenOperators" Automatic low-level control for newlines between operators "NewlinesInComments" Automatic low-level control for newlines in comments "NewlinesInControl" Automatic low-level control for newlines in control structures "NewlinesInGroups" Automatic low-level control for newlines in groups "NewlinesInScoping" Automatic low-level control for newlines in scoping constructs - Airiness can be a value between -1 and 1.
- Settings for "IndentationString" must result in equivalent code.
- Settings for "NewlineString" must result in equivalent code.
- Possible settings for the low-level newline options are:
-
Automatic use default behavior that relies on heuristics Insert always insert newlines Delete always delete newlines - Values for Airiness map directly to different values for low-level newline options.
- Airiness of 0 is equivalent to all low-level newline options having value Automatic.
- Airiness of -1 is equivalent to all low-level newline options having value Delete.
- Airiness of 1 is equivalent to all low-level newline options having value Insert.
范例
打开所有单元关闭所有单元Options (4)
"IndentationString" (1)
Possible Issues (1)
A string representing a file path is treated as code.
File paths must use the File wrapper.