From ab2a17e9ad35e3202a6acd0b67aaff7fd6d54d20 Mon Sep 17 00:00:00 2001 From: "Documenter.jl" Date: Tue, 17 Sep 2024 03:23:59 +0000 Subject: [PATCH] build based on 534f70a --- previews/PR870/.documenter-siteinfo.json | 2 +- previews/PR870/api/index.html | 24 +++++++++---------- previews/PR870/blue_style/index.html | 4 ++-- previews/PR870/config/index.html | 2 +- previews/PR870/custom_alignment/index.html | 2 +- previews/PR870/how_it_works/index.html | 2 +- previews/PR870/index.html | 2 +- previews/PR870/integrations/index.html | 2 +- previews/PR870/sciml_style/index.html | 4 ++-- previews/PR870/skipping_formatting/index.html | 2 +- previews/PR870/style/index.html | 2 +- previews/PR870/transforms/index.html | 2 +- previews/PR870/yas_style/index.html | 4 ++-- 13 files changed, 27 insertions(+), 27 deletions(-) diff --git a/previews/PR870/.documenter-siteinfo.json b/previews/PR870/.documenter-siteinfo.json index 21d53c9d..0ff94861 100644 --- a/previews/PR870/.documenter-siteinfo.json +++ b/previews/PR870/.documenter-siteinfo.json @@ -1 +1 @@ -{"documenter":{"julia_version":"1.10.5","generation_timestamp":"2024-09-17T03:20:14","documenter_version":"1.7.0"}} \ No newline at end of file +{"documenter":{"julia_version":"1.10.5","generation_timestamp":"2024-09-17T03:23:51","documenter_version":"1.7.0"}} \ No newline at end of file diff --git a/previews/PR870/api/index.html b/previews/PR870/api/index.html index 3c3afcc4..f96ac8e2 100644 --- a/previews/PR870/api/index.html +++ b/previews/PR870/api/index.html @@ -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.DefaultStyleType
DefaultStyle

The default formatting style. See the Style section of the documentation for more details.

See also: BlueStyle, YASStyle, SciMLStyle, MinimalStyle

source
JuliaFormatter.FSTType

Formatted Syntax Tree

source
JuliaFormatter.MinimalStyleType
MinimalStyle()
source
JuliaFormatter.add_node!Method
add_node!(
+manually added by the user since the formatter would only use 0 or 1 whitespaces.
source
JuliaFormatter.DefaultStyleType
DefaultStyle

The default formatting style. See the Style section of the documentation for more details.

See also: BlueStyle, YASStyle, SciMLStyle, MinimalStyle

source
JuliaFormatter.FSTType

Formatted Syntax Tree

source
JuliaFormatter.MinimalStyleType
MinimalStyle()
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.align_conditional!Method
align_conditional!(fst::FST)

Aligns a conditional expression.

source
JuliaFormatter.align_matrix!Method

Adjust whitespace in between matrix elements such that it's the same as the original source file.

source
JuliaFormatter.align_struct!Method
align_struct!(fst::FST)

Aligns struct fields.

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

Annotates fields in a type definitions with ::Any if no type annotation is provided.

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.align_conditional!Method
align_conditional!(fst::FST)

Aligns a conditional expression.

source
JuliaFormatter.align_matrix!Method

Adjust whitespace in between matrix elements such that it's the same as the original source file.

source
JuliaFormatter.align_struct!Method
align_struct!(fst::FST)

Aligns struct fields.

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

Annotates fields in a type definitions with ::Any if no type annotation is provided.

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,36 +34,36 @@
 
 =>
 
-for i = 1:10 body end

always_for_in=nothing disables this normalization behavior.

  • https://github.com/domluna/JuliaFormatter.jl/issues/34
source
JuliaFormatter.find_optimal_nest_placeholdersMethod

Finds the optimal placeholders to turn into a newlines such that the length of the arguments on each line is as close as possible while following margin constraints.

source
JuliaFormatter.flatten_binaryopcallMethod

Flattens a binary operation call tree if the operation repeats 2 or more times. "a && b && c" will be transformed while "a && b" will not.

source
JuliaFormatter.formatMethod
format(path, style::AbstractStyle; options...)::Bool
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.find_optimal_nest_placeholdersMethod

Finds the optimal placeholders to turn into a newlines such that the length of the arguments on each line is as close as possible while following margin constraints.

source
JuliaFormatter.flatten_binaryopcallMethod

Flattens a binary operation call tree if the operation repeats 2 or more times. "a && b && c" will be transformed while "a && b" will not.

source
JuliaFormatter.formatMethod
format(path, style::AbstractStyle; options...)::Bool
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.formatMethod
format(mod::Module, args...; options...)
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.formatMethod
format(mod::Module, args...; options...)
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,
     margin::Int = 92,
     options...,
-)::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_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.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.long_to_short_function_def!Method
long_to_short_function_def!(fst::FST, s::State)

Transforms a long function definition

function f(arg2, arg2)
+)::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_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.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.long_to_short_function_def!Method
long_to_short_function_def!(fst::FST, s::State)

Transforms a long function definition

function f(arg2, arg2)
     body
-end

to a short function definition

f(arg1, arg2) = body
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!(
+end

to a short function definition

f(arg1, arg2) = body
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.pipe_to_function_call_pass!Method
pipe_to_function_call_pass!(fst::FST)

Rewrites x |> f to f(x).

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.pipe_to_function_call_pass!Method
pipe_to_function_call_pass!(fst::FST)

Rewrites x |> f to f(x).

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.remove_superfluous_whitespace!Method
remove_superfluous_whitespace!(fst::FST)

Soft deletes WHITESPACE or PLACEHOLDER that's directly followed by a NEWLINE or INLINECOMMENT node.

source
JuliaFormatter.separate_kwargs_with_semicolon!Method
separate_kwargs_with_semicolon!(fst::FST)

Ensures keyword arguments are separated by a ";".

Examples

Replace "," with ";".

a = f(x, y = 3)
+end
source
JuliaFormatter.remove_superfluous_whitespace!Method
remove_superfluous_whitespace!(fst::FST)

Soft deletes WHITESPACE or PLACEHOLDER that's directly followed by a NEWLINE or INLINECOMMENT node.

source
JuliaFormatter.separate_kwargs_with_semicolon!Method
separate_kwargs_with_semicolon!(fst::FST)

Ensures keyword arguments are separated by a ";".

Examples

Replace "," with ";".

a = f(x, y = 3)
 
 ->
 
@@ -71,6 +71,6 @@
 
 ->
 
-a = f(; x = 1, y = 2)
source
JuliaFormatter.short_to_long_function_def!Method
short_to_long_function_def!(fst::FST, s::State)

Transforms a short function definition

f(arg1, arg2) = body

to a long function definition

function f(arg2, arg2)
+a = f(; x = 1, y = 2)
source
JuliaFormatter.short_to_long_function_def!Method
short_to_long_function_def!(fst::FST, s::State)

Transforms a short function definition

f(arg1, arg2) = body

to a long function definition

function f(arg2, arg2)
     body
-end
source
JuliaFormatter.unnestable_nodeMethod

cst is assumed to be a single child node. Returnss true if the node is of the syntactic form {...}, [...], or (...).

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
+endsource
JuliaFormatter.unnestable_nodeMethod

cst is assumed to be a single child node. Returnss true if the node is of the syntactic form {...}, [...], or (...).

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/previews/PR870/blue_style/index.html b/previews/PR870/blue_style/index.html index ff2f20f4..0011d51d 100644 --- a/previews/PR870/blue_style/index.html +++ b/previews/PR870/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/previews/PR870/config/index.html b/previews/PR870/config/index.html index b389ee0e..a6c9b933 100644 --- a/previews/PR870/config/index.html +++ b/previews/PR870/config/index.html @@ -11,4 +11,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/previews/PR870/custom_alignment/index.html b/previews/PR870/custom_alignment/index.html index 34fe7343..be7d4936 100644 --- a/previews/PR870/custom_alignment/index.html +++ b/previews/PR870/custom_alignment/index.html @@ -133,4 +133,4 @@ 100 300 400 1 ee 40000 2 a b -] +] diff --git a/previews/PR870/how_it_works/index.html b/previews/PR870/how_it_works/index.html index ab6c4547..16eb5975 100644 --- a/previews/PR870/how_it_works/index.html +++ b/previews/PR870/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/previews/PR870/index.html b/previews/PR870/index.html index b43124ac..bdfaea97 100644 --- a/previews/PR870/index.html +++ b/previews/PR870/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/previews/PR870/integrations/index.html b/previews/PR870/integrations/index.html index 1fc1863d..06271823 100644 --- a/previews/PR870/integrations/index.html +++ b/previews/PR870/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/previews/PR870/sciml_style/index.html b/previews/PR870/sciml_style/index.html index e82caea3..1a59b5ff 100644 --- a/previews/PR870/sciml_style/index.html +++ b/previews/PR870/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/previews/PR870/skipping_formatting/index.html b/previews/PR870/skipping_formatting/index.html index d3a0af8d..adb5395c 100644 --- a/previews/PR870/skipping_formatting/index.html +++ b/previews/PR870/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/previews/PR870/style/index.html b/previews/PR870/style/index.html index f250bc6b..26b53197 100644 --- a/previews/PR870/style/index.html +++ b/previews/PR870/style/index.html @@ -206,4 +206,4 @@ arg1, arg2, arg3, -) +) diff --git a/previews/PR870/transforms/index.html b/previews/PR870/transforms/index.html index cb0e6df1..3b918dc7 100644 --- a/previews/PR870/transforms/index.html +++ b/previews/PR870/transforms/index.html @@ -42,4 +42,4 @@ -> -Module.@macro +Module.@macro diff --git a/previews/PR870/yas_style/index.html b/previews/PR870/yas_style/index.html index 71207334..f2233cf3 100644 --- a/previews/PR870/yas_style/index.html +++ b/previews/PR870/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)