|
|
||
|---|---|---|
| libdparse@617b7c6f2c | ||
| src/dfmt | ||
| tests | ||
| .editorconfig | ||
| .gitignore | ||
| .gitmodules | ||
| .travis.yml | ||
| LICENSE.txt | ||
| README.md | ||
| build.bat | ||
| dub.json | ||
| makefile | ||
README.md
dfmt 
dfmt is a formatter for D source code
Status
dfmt is alpha-quality. Make backups of your files or use source control.
Building
Using Make
- Clone the repository
- Run
git submodule update --initin the dfmt directory - To compile with DMD, run
makein the dfmt directory. To compile with LDC, runmake ldcinstead. The generated binary will be placed indfmt/bin/.
Using
By default, dfmt reads its input from stdin and writes to stdout.
If a file name is specified on the command line, input will be read from the
file instead, and output will be written to stdout.
Options
--help:--inplace: a file name is required and the file will be edited in-place.--align_switch_statements: Seedfmt_align_switch_statementsbelow--brace_style: See ``brace_style``` below--end_of_line: Seeend_of_linebelow--indent_size: Seeindent_sizebelow--indent_style: Seeindent_stylebelow--max_line_length: Seemax_line_lengthbelow--soft_max_line_length: Seedfmt_soft_max_line_lengthbelow--outdent_attributes: Seedfmt_outdent_attributesbelow--outdent_labels: Seedfmt_outdent_labelsbelow--space_after_cast: Seedfmt_space_after_castbelow--split_operator_at_line_end: Seedfmt_split_operator_at_line_endbelow--tab_width: Seetab_widthbelow
Example
dfmt --inplace --space_after_cast=false --max_line_length=80 --soft_max_line_length=70 file.d
Configuration
dfmt uses EditorConfig configuration files. dfmt-specific properties are prefixed with dfmt_.
Standard EditorConfig properties
| Property Name | Allowed Values | Default Value | Description |
|---|---|---|---|
| end_of_line | cr, crlf and lf |
lf |
See EditorConfig documentation. |
| insert_final_newline | true |
Not supported. dfmt always inserts a final newline. | |
| charset | UTf-8 |
Not supported. dfmt only works correctly on UTF-8. | |
| indent_style | tab, space |
space |
See EditorConfig documentation. |
| indent_size | positive integers | 4 |
See EditorConfig documentation. |
| tab_width | positive integers | 8 |
See EditorConfig documentation. |
| trim_trailing_whitespace | true |
Not supported. dfmt does not emit trailing whitespace. | |
| max_line_length | positive integers | 120 |
See EditorConfig documentation. |
dfmt-specific properties
| Property Name | Allowed Values | Default Value | Description |
|---|---|---|---|
| dfmt_brace_style | allman, otbs, or stroustrup |
allman |
See Wikipedia |
| dfmt_soft_max_line_length | positive integers | 80 |
The formatting process will usually keep lines below this length, but they may be up to max_line_length columns long. |
| dfmt_outdent_labels (Not yet implemented) | true, false |
true |
Decrease the indentation of labels |
| dfmt_align_switch_statements (Not yet implemented) | true, false |
true |
Align labels, cases, and defaults with their enclosing switch |
| dfmt_outdent_attributes (Not yet implemented) | true, false |
true |
Decrease the indentation level of attributes |
| dfmt_split_operator_at_line_end (Not yet implemented) | true, false |
false |
Place operators on the end of the previous line when splitting lines |
| dfmt_space_after_cast | true, false |
false |
Insert space after the closing paren of a cast expression |
| dfmt_space_after_keywords (Not yet implemented) | true, false |
true |
Insert space after if, while, foreach, etc, and before the ( |
Terminology
- Braces -
{and} - Brackets -
[and] - Parenthesis / Parens -
(and)