diff --git a/dev/.documenter-siteinfo.json b/dev/.documenter-siteinfo.json index d154949e4..91dfc485f 100644 --- a/dev/.documenter-siteinfo.json +++ b/dev/.documenter-siteinfo.json @@ -1 +1 @@ -{"documenter":{"julia_version":"1.10.4","generation_timestamp":"2024-07-26T18:37:04","documenter_version":"1.5.0"}} \ No newline at end of file +{"documenter":{"julia_version":"1.10.4","generation_timestamp":"2024-08-22T17:06:44","documenter_version":"1.6.0"}} \ No newline at end of file diff --git a/dev/api/index.html b/dev/api/index.html index fdb11dd23..d4e7518b1 100644 --- a/dev/api/index.html +++ b/dev/api/index.html @@ -1,5 +1,5 @@ -API Reference · JuliaFormatter

API Documentation

JuliaFormatter.AlignGroupType
AlignGroup

Group of FST node indices and required metadata to potentially align them.

- `node_inds`. Indices of FST nodes affected by alignment.
+API Reference · JuliaFormatter

API Documentation

JuliaFormatter.AlignGroupType
AlignGroup

Group of FST node indices and required metadata to potentially align them.

- `node_inds`. Indices of FST nodes affected by alignment.
 - `nodes`. FST nodes affected by alignment.
 - `line_offsets`. Line offset of the character nodes may be aligned to
 in the source file.
@@ -7,14 +7,14 @@
 to calculate extra whitespace padding.
 - `whitespaces`. Number of whitespaces between the alignment character and
 the prior FST node. If this is > 1 it signifies additional whitespace was
-manually added by the user since the formatter would only use 0 or 1 whitespaces.
source
JuliaFormatter.add_node!Method
add_node!(
     t::FST,
     n::FST,
     s::State;
     join_lines::Bool = false,
     max_padding::Int = -1,
     override_join_lines_based_on_source::Bool = false,
-)

Appends n to t.

  • join_lines if false a NEWLINE node will be added and n will appear

on the next line, otherwise it will appear on the same line as the previous node (when printing).

  • max_padding >= 0 indicates margin of t should be based on whether the margin

of n + max_padding is greater than the current margin of t. Otherwise the margin n will be added to t.

  • override_join_lines_based_on_source is only used when join_lines_based_on_source option is true. In which

n is added to t as if join_lines_based_on_source was false.

source
JuliaFormatter.align_binaryopcalls!Method
align_binaryopcalls!(fst::FST, op_inds::Vector{Int})

Aligns binary operator expressions.

Additionally handles the case where a keyword such as const is used prior to the binary op call.

source
JuliaFormatter.binaryop_to_whereop!Method
binaryop_to_whereop(fst::FST, s::State)

Handles the case of a function def defined as:

foo(a::A)::R where A = body

In this case instead of it being parsed as (1):

Binary
+)

Appends n to t.

  • join_lines if false a NEWLINE node will be added and n will appear

on the next line, otherwise it will appear on the same line as the previous node (when printing).

  • max_padding >= 0 indicates margin of t should be based on whether the margin

of n + max_padding is greater than the current margin of t. Otherwise the margin n will be added to t.

  • override_join_lines_based_on_source is only used when join_lines_based_on_source option is true. In which

n is added to t as if join_lines_based_on_source was false.

source
JuliaFormatter.align_binaryopcalls!Method
align_binaryopcalls!(fst::FST, op_inds::Vector{Int})

Aligns binary operator expressions.

Additionally handles the case where a keyword such as const is used prior to the binary op call.

source
JuliaFormatter.binaryop_to_whereop!Method
binaryop_to_whereop(fst::FST, s::State)

Handles the case of a function def defined as:

foo(a::A)::R where A = body

In this case instead of it being parsed as (1):

Binary
  - Where
  - OP
  - RHS

It's parsed as (2):

Binary
@@ -25,7 +25,7 @@
    - R
    - ...
  - OP
- - RHS

(1) is preferrable since it's the same parsed result as:

foo(a::A) where A = body

This transformation converts (2) to (1).

ref https://github.com/julia-vscode/CSTParser.jl/issues/93

source
JuliaFormatter.eq_to_in_normalization!Method
eq_to_in_normalization!(fst::FST, always_for_in::Bool, for_in_replacement::String)
+ - RHS

(1) is preferrable since it's the same parsed result as:

foo(a::A) where A = body

This transformation converts (2) to (1).

ref https://github.com/julia-vscode/CSTParser.jl/issues/93

source
JuliaFormatter.eq_to_in_normalization!Method
eq_to_in_normalization!(fst::FST, always_for_in::Bool, for_in_replacement::String)
 eq_to_in_normalization!(fst::FST, always_for_in::Nothing, for_in_replacement::String)

Transforms

for i = iter body end
 
 =>
@@ -34,16 +34,16 @@
 
 =>
 
-for i = 1:10 body end

always_for_in=nothing disables this normalization behavior.

  • https://github.com/domluna/JuliaFormatter.jl/issues/34
source
JuliaFormatter.formatMethod
format(
+for i = 1:10 body end

always_for_in=nothing disables this normalization behavior.

  • https://github.com/domluna/JuliaFormatter.jl/issues/34
source
JuliaFormatter.formatMethod
format(
     paths; # a path or collection of paths
     options...,
-)::Bool

Recursively descend into files and directories, formatting any .jl, .md, .jmd, or .qmd files.

See format_file and format_text for a description of the options.

This function will look for .JuliaFormatter.toml in the location of the file being formatted, and searching up the file tree until a config file is (or isn't) found. When found, the configurations in the file will overwrite the given options. See Configuration File for more details.

Output

Returns a boolean indicating whether the file was already formatted (true) or not (false).

source
JuliaFormatter.format_fileMethod
format_file(
+)::Bool

Recursively descend into files and directories, formatting any .jl, .md, .jmd, or .qmd files.

See format_file and format_text for a description of the options.

This function will look for .JuliaFormatter.toml in the location of the file being formatted, and searching up the file tree until a config file is (or isn't) found. When found, the configurations in the file will overwrite the given options. See Configuration File for more details.

Output

Returns a boolean indicating whether the file was already formatted (true) or not (false).

source
JuliaFormatter.format_fileMethod
format_file(
     filename::AbstractString;
     overwrite::Bool = true,
     verbose::Bool = false,
     format_markdown::Bool = false,
     format_options...,
-)::Bool

Formats the contents of filename assuming it's a .jl, .md, .jmd or .qmd file.

See https://domluna.github.io/JuliaFormatter.jl/dev/#File-Options for details on available options.

Output

Returns a boolean indicating whether the file was already formatted (true) or not (false).

source
JuliaFormatter.format_mdMethod
format_md(text::AbstractString; style::AbstractStyle = DefaultStyle(), kwargs...)

Normalizes the Markdown source and formats Julia code blocks.

See format_text for description of formatting options.

source
JuliaFormatter.format_textMethod
format_text(
+)::Bool

Formats the contents of filename assuming it's a .jl, .md, .jmd or .qmd file.

See https://domluna.github.io/JuliaFormatter.jl/dev/#File-Options for details on available options.

Output

Returns a boolean indicating whether the file was already formatted (true) or not (false).

source
JuliaFormatter.format_mdMethod
format_md(text::AbstractString; style::AbstractStyle = DefaultStyle(), kwargs...)

Normalizes the Markdown source and formats Julia code blocks.

See format_text for description of formatting options.

source
JuliaFormatter.format_textMethod
format_text(
     text::AbstractString;
     style::AbstractStyle = DefaultStyle(),
     indent::Int = 4,
@@ -75,7 +75,7 @@
     surround_whereop_typeparameters::Bool = true,
     variable_call_indent::Vector{String} = []
     short_circuit_to_if::Bool = false,
-)::String

Formats a Julia source passed in as a string, returning the formatted code as another string.

See https://domluna.github.io/JuliaFormatter.jl/dev/#Formatting-Options for details on available options.

source
JuliaFormatter.is_dot_opMethod
is_dot_op(x::CSTParser.EXPR)

Checks if the binary operation is a dot operation (e.g. x.y, x..z, x...z). This is different from a dot or broadcast operation.

source
JuliaFormatter.is_iterable_argMethod

Returns whether fst can be an iterable argument. For example in the case of a function call, which is of type Call:

(a, b, c; k1=v1)

This would return true for a, b, c and k1=v1 and false for all other nodes.

source
JuliaFormatter.is_standalone_shortcircuitMethod
is_standalone_shortcircuit(cst::CSTParser.EXPR)

Returns true if the cst is a short-circuit expression (uses &&, ||) and is standalone, meaning it's not directly associated with another statement or expression.

Examples

# this IS a standalone short-circuit
+)::String

Formats a Julia source passed in as a string, returning the formatted code as another string.

See https://domluna.github.io/JuliaFormatter.jl/dev/#Formatting-Options for details on available options.

source
JuliaFormatter.is_dot_opMethod
is_dot_op(x::CSTParser.EXPR)

Checks if the binary operation is a dot operation (e.g. x.y, x..z, x...z). This is different from a dot or broadcast operation.

source
JuliaFormatter.is_iterable_argMethod

Returns whether fst can be an iterable argument. For example in the case of a function call, which is of type Call:

(a, b, c; k1=v1)

This would return true for a, b, c and k1=v1 and false for all other nodes.

source
JuliaFormatter.is_standalone_shortcircuitMethod
is_standalone_shortcircuit(cst::CSTParser.EXPR)

Returns true if the cst is a short-circuit expression (uses &&, ||) and is standalone, meaning it's not directly associated with another statement or expression.

Examples

# this IS a standalone short-circuit
 a && b
 
 # this IS NOT a standalone short-circuit
@@ -90,21 +90,21 @@
 
 # operation inside parenthesis IS NOT a standalone short-circuit
 # operation outside parenthesis IS a standalone short-circuit
-(a && b) && c
source
JuliaFormatter.length_toMethod
`length_to(x::FST, ntyps; start::Int = 1)`

Returns the length to any node type in ntyps based off the start index.

source
JuliaFormatter.length_toMethod
`length_to(x::FST, ntyps; start::Int = 1)`

Returns the length to any node type in ntyps based off the start index.

source
JuliaFormatter.move_at_sign_to_the_endMethod
move_at_sign_to_the_end(fst::FST, s::State)

NOTE: Assumes fst is the caller name of a macrocall such as @macro or Module.@macro.

Moves @ to the last identifier.

Example:

@Module.macro

to

Module.@macro
source
JuliaFormatter.move_at_sign_to_the_endMethod
move_at_sign_to_the_end(fst::FST, s::State)

NOTE: Assumes fst is the caller name of a macrocall such as @macro or Module.@macro.

Moves @ to the last identifier.

Example:

@Module.macro

to

Module.@macro
source
JuliaFormatter.nest_if_over_margin!Method
nest_if_over_margin!(
     style,
     fst::FST,
     s::State,
     idx::Int;
     stop_idx::Union{Int,Nothing} = nothing,
-)::Bool

Converts the node at idx to a NEWLINE if the current margin plus the additional margin from fst[idx:stop_idx-1] is greater than the allowed margin.

If stop_idx == nothing the range is fst[idx:end].

Returns whether nesting occurred.

source
JuliaFormatter.p_macrostr_identifierMethod

This is a special prettifier to handle the case of string macros. As such it is not part of pretty.

format"hello"

The above "format" identifier is parsed by CSTParser as if the text is "@format_str". This creates problems when we format without intervention:

  1. "@format_str" is printed instead of "format"
  2. The state offset is incorrect since the length of "@format_str" is greater than "format"
source
JuliaFormatter.parent_isMethod

Returns whether the first unignored parent of cst matches the criteria determined by valid, which is a function that returns a boolean. ignore can be used to ignore certain parent nodes if desired, also a function which returns a boolean.

source
JuliaFormatter.prepend_return!Method
prepend_return!(fst::FST, s::State)

Prepends return to the last expression of a block if applicable.

function foo()
+)::Bool

Converts the node at idx to a NEWLINE if the current margin plus the additional margin from fst[idx:stop_idx-1] is greater than the allowed margin.

If stop_idx == nothing the range is fst[idx:end].

Returns whether nesting occurred.

source
JuliaFormatter.p_macrostr_identifierMethod

This is a special prettifier to handle the case of string macros. As such it is not part of pretty.

format"hello"

The above "format" identifier is parsed by CSTParser as if the text is "@format_str". This creates problems when we format without intervention:

  1. "@format_str" is printed instead of "format"
  2. The state offset is incorrect since the length of "@format_str" is greater than "format"
source
JuliaFormatter.parent_isMethod

Returns whether the first unignored parent of cst matches the criteria determined by valid, which is a function that returns a boolean. ignore can be used to ignore certain parent nodes if desired, also a function which returns a boolean.

source
JuliaFormatter.prepend_return!Method
prepend_return!(fst::FST, s::State)

Prepends return to the last expression of a block if applicable.

function foo()
     a = 2 * 3
     a / 3
 end

to

function foo()
     a = 2 * 3
     return a / 3
-end
source
JuliaFormatter.walkMethod
walk(f, fst::FST, s::State)

Walks fst calling f on each node.

In situations where descending further into a subtree is not desirable f should return a value other than nothing.

Note

This function mutates the State's (s) line_offset. If this is not desired you should save the value before calling this function and restore it after.

source
+end
source
JuliaFormatter.walkMethod
walk(f, fst::FST, s::State)

Walks fst calling f on each node.

In situations where descending further into a subtree is not desirable f should return a value other than nothing.

Note

This function mutates the State's (s) line_offset. If this is not desired you should save the value before calling this function and restore it after.

source
diff --git a/dev/assets/documenter.js b/dev/assets/documenter.js index b2bdd43ee..82252a11d 100644 --- a/dev/assets/documenter.js +++ b/dev/assets/documenter.js @@ -77,30 +77,35 @@ require(['jquery'], function($) { let timer = 0; var isExpanded = true; -$(document).on("click", ".docstring header", function () { - let articleToggleTitle = "Expand docstring"; - - debounce(() => { - if ($(this).siblings("section").is(":visible")) { - $(this) - .find(".docstring-article-toggle-button") - .removeClass("fa-chevron-down") - .addClass("fa-chevron-right"); - } else { - $(this) - .find(".docstring-article-toggle-button") - .removeClass("fa-chevron-right") - .addClass("fa-chevron-down"); +$(document).on( + "click", + ".docstring .docstring-article-toggle-button", + function () { + let articleToggleTitle = "Expand docstring"; + const parent = $(this).parent(); + + debounce(() => { + if (parent.siblings("section").is(":visible")) { + parent + .find("a.docstring-article-toggle-button") + .removeClass("fa-chevron-down") + .addClass("fa-chevron-right"); + } else { + parent + .find("a.docstring-article-toggle-button") + .removeClass("fa-chevron-right") + .addClass("fa-chevron-down"); - articleToggleTitle = "Collapse docstring"; - } + articleToggleTitle = "Collapse docstring"; + } - $(this) - .find(".docstring-article-toggle-button") - .prop("title", articleToggleTitle); - $(this).siblings("section").slideToggle(); - }); -}); + parent + .children(".docstring-article-toggle-button") + .prop("title", articleToggleTitle); + parent.siblings("section").slideToggle(); + }); + } +); $(document).on("click", ".docs-article-toggle-button", function (event) { let articleToggleTitle = "Expand docstring"; @@ -110,7 +115,7 @@ $(document).on("click", ".docs-article-toggle-button", function (event) { debounce(() => { if (isExpanded) { $(this).removeClass("fa-chevron-up").addClass("fa-chevron-down"); - $(".docstring-article-toggle-button") + $("a.docstring-article-toggle-button") .removeClass("fa-chevron-down") .addClass("fa-chevron-right"); @@ -119,7 +124,7 @@ $(document).on("click", ".docs-article-toggle-button", function (event) { $(".docstring section").slideUp(animationSpeed); } else { $(this).removeClass("fa-chevron-down").addClass("fa-chevron-up"); - $(".docstring-article-toggle-button") + $("a.docstring-article-toggle-button") .removeClass("fa-chevron-right") .addClass("fa-chevron-down"); diff --git a/dev/blue_style/index.html b/dev/blue_style/index.html index 1dfe13e38..a2405224c 100644 --- a/dev/blue_style/index.html +++ b/dev/blue_style/index.html @@ -1,3 +1,3 @@ -Blue Style · JuliaFormatter

Blue Style

JuliaFormatter.BlueStyleType
BlueStyle()

Formatting style based on BlueStyle and JuliaFormatter#283.

Note

This style is still work-in-progress, and does not yet implement all of the BlueStyle guide.

Configurable options with different defaults to DefaultStyle are:

  • always_use_return = true
  • short_to_long_function_def = true
  • whitespace_ops_in_indices = true
  • remove_extra_newlines = true
  • always_for_in = true
  • import_to_using = true
  • pipe_to_function_call = true
  • whitespace_in_kwargs = false
  • annotate_untyped_fields_with_any = false
  • separate_kwargs_with_semicolon = true
source

Configuration File Example

The .JuliaFormatter.toml which represents these settings is

style = "blue"

Or to use BlueStyle except change one of the settings:

style = "blue"
-remove_extra_newlines = false

Direct Usage

format("file.jl", BlueStyle())

Or to use BlueStyle except change one of the settings:

format("file.jl", BlueStyle(), remove_extra_newlines=false)
+Blue Style · JuliaFormatter

Blue Style

JuliaFormatter.BlueStyleType
BlueStyle()

Formatting style based on BlueStyle and JuliaFormatter#283.

Note

This style is still work-in-progress, and does not yet implement all of the BlueStyle guide.

Configurable options with different defaults to DefaultStyle are:

  • always_use_return = true
  • short_to_long_function_def = true
  • whitespace_ops_in_indices = true
  • remove_extra_newlines = true
  • always_for_in = true
  • import_to_using = true
  • pipe_to_function_call = true
  • whitespace_in_kwargs = false
  • annotate_untyped_fields_with_any = false
  • separate_kwargs_with_semicolon = true
source

Configuration File Example

The .JuliaFormatter.toml which represents these settings is

style = "blue"

Or to use BlueStyle except change one of the settings:

style = "blue"
+remove_extra_newlines = false

Direct Usage

format("file.jl", BlueStyle())

Or to use BlueStyle except change one of the settings:

format("file.jl", BlueStyle(), remove_extra_newlines=false)
diff --git a/dev/config/index.html b/dev/config/index.html index b0271d149..09ee7232f 100644 --- a/dev/config/index.html +++ b/dev/config/index.html @@ -13,4 +13,4 @@ │ ├─ .JuliaFormatter.toml │ └─ sub_code1.jl └─ subdir2 - └─ sub_code2.jl

and call format("dir"), code.jl and sub_code2.jl will be formatted according to the rules defined in dir/.JuliaFormatter.toml, while formatting sub_code1.jl will be configured by dir/subdir1/.JuliaFormatter.toml.

Ignoring specific files and directories

If there is an entry in .JuliaFormatter.toml with

ignore = ["file.jl", "directory", "file_*.jl"]

then all of these files will be reported as already formatted: ./file.jl, ./directory/something.jl ./other_directory/file.jl, file_1.jl, .other_directory/file_name.jl.

+ └─ sub_code2.jl

and call format("dir"), code.jl and sub_code2.jl will be formatted according to the rules defined in dir/.JuliaFormatter.toml, while formatting sub_code1.jl will be configured by dir/subdir1/.JuliaFormatter.toml.

Ignoring specific files and directories

If there is an entry in .JuliaFormatter.toml with

ignore = ["file.jl", "directory", "file_*.jl"]

then all of these files will be reported as already formatted: ./file.jl, ./directory/something.jl ./other_directory/file.jl, file_1.jl, .other_directory/file_name.jl.

diff --git a/dev/custom_alignment/index.html b/dev/custom_alignment/index.html index cd5e11d73..cdd19dd32 100644 --- a/dev/custom_alignment/index.html +++ b/dev/custom_alignment/index.html @@ -133,4 +133,4 @@ 100 300 400 1 ee 40000 2 a b -] +] diff --git a/dev/custom_styles/index.html b/dev/custom_styles/index.html index b70ddb334..7c162eaf8 100644 --- a/dev/custom_styles/index.html +++ b/dev/custom_styles/index.html @@ -32,4 +32,4 @@ foo(a, b, key1 = val1, key3 = val4) julia> format_text(s, style=CustomStyle()) |> print -foo(a, b, key1=val1, key3=val4)

Nice! Looks like it's working.

+foo(a, b, key1=val1, key3=val4)

Nice! Looks like it's working.

diff --git a/dev/how_it_works/index.html b/dev/how_it_works/index.html index 84d657487..9c3f2e215 100644 --- a/dev/how_it_works/index.html +++ b/dev/how_it_works/index.html @@ -31,4 +31,4 @@ ..., argument120 ) # way over margin limit !!! -end

You can read how code is nested in the style section.

Once the FST has been nested it's then printed out to a file and voila! You have a formatted version of your code!

+end

You can read how code is nested in the style section.

Once the FST has been nested it's then printed out to a file and voila! You have a formatted version of your code!

diff --git a/dev/index.html b/dev/index.html index 801692b5d..60895f7c7 100644 --- a/dev/index.html +++ b/dev/index.html @@ -200,4 +200,4 @@ a * b end -end

Notice the contents of @muladd begin is not indented.

#!: format: noindent can also be nested.

Editor Plugins

For integration with other editors:

+end

Notice the contents of @muladd begin is not indented.

#!: format: noindent can also be nested.

Editor Plugins

For integration with other editors:

diff --git a/dev/integrations/index.html b/dev/integrations/index.html index eb71dc815..d1dc5d0c1 100644 --- a/dev/integrations/index.html +++ b/dev/integrations/index.html @@ -5,4 +5,4 @@ rev: "v1.0.18" # or whatever the desired release is hooks: - id: "julia-formatter" -# ... other repos you may have

You can find a list of releases here. Be sure to use the entire version string! (You can double-check this by opening the release and looking at the part of the URL that follows .../releases/tag/VERSION.)

+# ... other repos you may have

You can find a list of releases here. Be sure to use the entire version string! (You can double-check this by opening the release and looking at the part of the URL that follows .../releases/tag/VERSION.)

diff --git a/dev/sciml_style/index.html b/dev/sciml_style/index.html index 5f6c4aaee..cf6ed1a01 100644 --- a/dev/sciml_style/index.html +++ b/dev/sciml_style/index.html @@ -1,5 +1,5 @@ -SciML Style · JuliaFormatter

SciML Style

JuliaFormatter.SciMLStyleType
SciMLStyle()

Formatting style based on SciMLStyle.

Note

This style is still work-in-progress.

Configurable options with different defaults to DefaultStyle are:

  • whitespace_ops_in_indices = true
  • remove_extra_newlines = true
  • always_for_in = true
  • whitespace_typedefs = true,
  • normalize_line_endings = "unix"
source

Configuration File Example

The .JuliaFormatter.toml which represents these settings is

style = "sciml"

Or to use SciMLStyle except change one of the settings:

style = "sciml"
+SciML Style · JuliaFormatter

SciML Style

JuliaFormatter.SciMLStyleType
SciMLStyle()

Formatting style based on SciMLStyle.

Note

This style is still work-in-progress.

Configurable options with different defaults to DefaultStyle are:

  • whitespace_ops_in_indices = true
  • remove_extra_newlines = true
  • always_for_in = true
  • whitespace_typedefs = true,
  • normalize_line_endings = "unix"
source

Configuration File Example

The .JuliaFormatter.toml which represents these settings is

style = "sciml"

Or to use SciMLStyle except change one of the settings:

style = "sciml"
 remove_extra_newlines = false

Direct Usage

format("file.jl", SciMLStyle())

Or to use SciMLStyle except change one of the settings:

format("file.jl", SciMLStyle(), remove_extra_newlines=false)

Additional Options

The SciMLStyle supports the additional options variable_call_indent and yas_style_nesting.

The option variable_call_indent is set to [] by default. It allows calls without aligning to the opening parenthesis:

# Allowed with and without `Dict in variable_call_indent`
 Dict{Int, Int}(1 => 2,
     3 => 4)
@@ -20,4 +20,4 @@
                            argument3, argument4,
                            argument5, x, y, z)
     foo(x) + goo(y)
-end
+end
diff --git a/dev/skipping_formatting/index.html b/dev/skipping_formatting/index.html index b5be69876..18c9fc316 100644 --- a/dev/skipping_formatting/index.html +++ b/dev/skipping_formatting/index.html @@ -12,4 +12,4 @@ module Foo ... -end
Ignoring files

You can also ignore entire files and directories by supplying the ignore option in .JuliaFormatter.toml.

Note the formatter expects #! format: on and #! format: off to be on its own line and the whitespace to be an exact match.

+end
Ignoring files

You can also ignore entire files and directories by supplying the ignore option in .JuliaFormatter.toml.

Note the formatter expects #! format: on and #! format: off to be on its own line and the whitespace to be an exact match.

diff --git a/dev/style/index.html b/dev/style/index.html index b7a8af1e6..87398c194 100644 --- a/dev/style/index.html +++ b/dev/style/index.html @@ -206,4 +206,4 @@ arg1, arg2, arg3, -) +) diff --git a/dev/transforms/index.html b/dev/transforms/index.html index bc05c717e..e25ec7ebe 100644 --- a/dev/transforms/index.html +++ b/dev/transforms/index.html @@ -42,4 +42,4 @@ -> -Module.@macro +Module.@macro diff --git a/dev/yas_style/index.html b/dev/yas_style/index.html index e7f32f3a3..d995c9098 100644 --- a/dev/yas_style/index.html +++ b/dev/yas_style/index.html @@ -1,5 +1,5 @@ -YAS Style · JuliaFormatter

YAS Style

JuliaFormatter.YASStyleType
YASStyle()

Formatting style based on YASGuide and JuliaFormatter#198.

Configurable options with different defaults to DefaultStyle are:

  • always_for_in = true
  • whitespace_ops_in_indices = true
  • remove_extra_newlines = true
  • import_to_using = true
  • pipe_to_function_call = true
  • short_to_long_function_def = true
  • always_use_return = true
  • whitespace_in_kwargs = false
  • join_lines_based_on_source = true
  • separate_kwargs_with_semicolon = true
source

Configuration File Example

The .JuliaFormatter.toml which represents these settings is

style = "yas"

Or to use YASStyle except change one of the settings:

style = "yas"
+YAS Style · JuliaFormatter

YAS Style

JuliaFormatter.YASStyleType
YASStyle()

Formatting style based on YASGuide and JuliaFormatter#198.

Configurable options with different defaults to DefaultStyle are:

  • always_for_in = true
  • whitespace_ops_in_indices = true
  • remove_extra_newlines = true
  • import_to_using = true
  • pipe_to_function_call = true
  • short_to_long_function_def = true
  • always_use_return = true
  • whitespace_in_kwargs = false
  • join_lines_based_on_source = true
  • separate_kwargs_with_semicolon = true
source

Configuration File Example

The .JuliaFormatter.toml which represents these settings is

style = "yas"

Or to use YASStyle except change one of the settings:

style = "yas"
 remove_extra_newlines = false

Direct Usage

format("file.jl", YASStyle())

Or to use YASStyle except change one of the settings:

format("file.jl", YASStyle(), remove_extra_newlines=false)

Differences from DefaultStyle

There are three main differences between YASStyle and DefaultStyle. They are based on alignment and line break behaviors.

  1. Arguments are aligned to just after the start of the opener [, {, (, etc.
function_call(arg1,
               arg2)
  1. As you can see from the above the closer sticks to the final argument.

  2. Nesting (line breaks) only occur when the margin of the next argument exceeds the maximim limit.

function_call(arg1, arg2,
               arg3)

arg3 exceeded the margin limit and so it was placed on the following line.

Nesting =

Unlike DefaultStyle, assignment operations = are not nested. That is, the following

my_function(arg1, arg2) = arg1 * arg2

Is not nested to

my_function(arg1, arg2) =
@@ -13,4 +13,4 @@
 # will be changed to the first example when `Dict ∉ variable_call_indent`.
 Dict{Int,Int}(
     1 => 2,
-    3 => 4)
+ 3 => 4)