Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Submodules in one file should be indented according to BlueStyle #484

Closed
oxinabox opened this issue Oct 7, 2021 · 2 comments · Fixed by #489
Closed

Submodules in one file should be indented according to BlueStyle #484

oxinabox opened this issue Oct 7, 2021 · 2 comments · Fixed by #489

Comments

@oxinabox
Copy link

oxinabox commented Oct 7, 2021

From: https://github.com/invenia/BlueStyle#modules

Sometimes, e.g. for tests, or for namespacing a enumeration, it is desirable to declare a submodule midway through a file.
In this case the code within the submodule should be indented.

Consider the following code:

module Foo
module Bar
    x = 2
    y = 4
end

z = 5

end

It is correctly formatted by BlueStyle.

But after I run JuliaFormatter it ends up wrong:

julia> format_text(str, BlueStyle()) |> println
module Foo
module Bar
x = 2
y = 4
end

z = 5
end
st-- added a commit to st--/ChainRulesCore.jl that referenced this issue Oct 8, 2021
oxinabox added a commit to JuliaDiff/ChainRulesCore.jl that referenced this issue Oct 8, 2021
* format(".")

* format workflow

* format with blue style

* Update src/rule_definition_tools.jl

* Revert "format with blue style"

This reverts commit 8ddb4ac.

* Revert "format(".")"

This reverts commit 2783a90.

* format(".") with blue style from scratch

* manual format cleanup

* Update test/tangent_types/tangent.jl

* Revert "format(".") with blue style from scratch"

This reverts commit 8b54ef6.

* add .JuliaFormatter.toml with style = blue

* format(".") - hopefully actually with BlueStyle this time around!!!

* Update .github/workflows/format.yml

Co-authored-by: Lyndon White <[email protected]>

* Apply suggestions from code review

Co-authored-by: Lyndon White <[email protected]>

* fix suggestion

* manual formatting workaround for domluna/JuliaFormatter.jl#484

* Update src/rule_definition_tools.jl

Co-authored-by: Lyndon White <[email protected]>

* Update src/rule_definition_tools.jl

* Update src/rule_definition_tools.jl

* Update src/rule_definition_tools.jl

Co-authored-by: Lyndon White <[email protected]>
@domluna
Copy link
Owner

domluna commented Oct 11, 2021

Is this recursive? what would this be

module Foo
module Bar
    x = 2
    y = 4
    module C
        stuff
    end
end

z = 5

end

@oxinabox
Copy link
Author

That would be unchanged.

Basically the rule is:
Indent within modules, unless that module is the first/outermost module in this file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants