Skip to content

Commit

Permalink
Rewrite with JuliaSyntax (#870)
Browse files Browse the repository at this point in the history
* use JuliaSyntax for document + state

* CSTParser is bad at this part

* wip

* same api

* wip

* first format working

* rm DataStructures

* options

* good progress

* works

* ok

* Disable for now

* fixes

* progress - unicode is being an issue

* ok

* ok

* more tests pass

* ok i think it's time to use julia syntax for more now all tests pass except some alignment ones and that's due to unicode length/ncodeunits stuff

* k

* precompile

* hmmm

* progress

* wip

* wip

* wip

* fmt

* wio

* lineage

* lfg

* wip

* coming together

* dwadaw

* wow

* parameters working better

* more tests passing

* almost got initial tests passing

* wip

* let passing

* format

* ok

* more tests passing

* fmt

* fix

* foo

* format

* more stuff working

* wip

* wip

* almost there

* fmt

* hmmmm

* looking good

* almost

* tests pass

* save

* add warning to skip file if it's a parse error

* ok

* ok

* ok

* progress

* ok

* another binary shortcircuit test

* ok

* blue

* test

* ok

* passes

* pass

* fix

* kwargs fix

* wip

* src

* ok

* ok

* lazy op

* more fixes

* standalone binary

* comment out

* jfmt src

* for

* format

* another test

* kw

* simplify

* parameters

* Cleanup

* src done

* another fix

* fmt

* a

* fixes

* fmt

* fmt test files

* works

* rm line

* fix

* ok

* ok

* precompile

* merged from master

* ok

* ok

* ok

* wip

* updates docs

* fmt

* int/uint

* methods

* version check

* version checks

* fix

* fmt

* test

* ok

* format

* ok

* ok

* fixes

* using jet

* jet

* fmt

* wip

* nospecialize

* ok

* more stuff

* ok

* reduce precompilation time by a decent amount

* remove kwargs

* rename

* ok

* cleanup

* ok

* precompile

* progress

* allow hash eq comments to be placed whereever

* fix

* ok

* try this

* stuff

* this too

* more

* ok

* shouldn't go crazy with @nospecialize

* get rid of precompietools for now

* seems to be working

* ok

* seems good

* hmm

* jet

* hmm

* fmt

* allocs

* update

* type stable

* kwdef

* ok

* ok

* -1 -> 0

* ok

* style update

* another format change

* fix short-circuit to if pass ?

* format works

* ok

* update

* ok

* docs update

* simplify

* fix

* format

* this seems to be it

* keep semicolons in quote/begin blocks

* some updates

* format

* improve runtime of strings and docstring formatting

* remove @nospecialize

* reduce compilation time

* greater workload

* rm old format.jl file

* workload

* minor edit

* more precompilation stuff

* format

* fix test

* 1.10 is the new LTS

* tuple blocks

* format
  • Loading branch information
domluna authored Oct 16, 2024
1 parent 965ab02 commit 2242a32
Show file tree
Hide file tree
Showing 61 changed files with 7,650 additions and 5,877 deletions.
2 changes: 2 additions & 0 deletions .JuliaFormatter.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
remove_extra_newlines = true
always_for_in = true
conditional_to_if = true
separate_kwargs_with_semicolon = true
short_to_long_function_def = true
5 changes: 1 addition & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,8 @@ jobs:
strategy:
matrix:
version:
- '1.6'
- '1.7'
- '1.8'
- '1.9'
- '1.10'
- '1.11'
# - 'nightly'
arch: [x64, x86]
os: [ubuntu-latest, windows-latest, macos-13]
Expand Down
12 changes: 4 additions & 8 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
name = "JuliaFormatter"
uuid = "98e50ef6-434e-11e9-1051-2b60c6c9e899"
authors = ["Dominique Luna <[email protected]>"]
version = "1.0.62"
version = "2.0.0"

[deps]
CSTParser = "00ebfdb7-1f24-5e51-bd34-a7502290713f"
CommonMark = "a80b9123-70ca-4bc0-993e-6e3bcb318db6"
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
Glob = "c27321d9-0574-5035-807b-f59d2c89b15c"
JuliaSyntax = "70703baa-626e-46a2-a12c-08ffd08c73b4"
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
TOML = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
Tokenize = "0796e94c-ce3b-5d07-9a54-7f471281c624"

[compat]
CSTParser = "^3.4.2"
CommonMark = "0.5, 0.6, 0.7, 0.8"
DataStructures = "0.17, 0.18"
Glob = "1.3"
JuliaSyntax = "^0.4.10"
PrecompileTools = "1"
TOML = "1"
Tokenize = "^0.5.16"
julia = "1.0"
julia = "1.10"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Expand Down
107 changes: 0 additions & 107 deletions bin/format.jl

This file was deleted.

7 changes: 3 additions & 4 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using Documenter, JuliaFormatter

makedocs(
makedocs(;
sitename = "JuliaFormatter",
format = Documenter.HTML(prettyurls = get(ENV, "CI", nothing) == "true"),
format = Documenter.HTML(; prettyurls = get(ENV, "CI", nothing) == "true"),
modules = [JuliaFormatter],
pages = [
"Introduction" => "index.md",
Expand All @@ -11,7 +11,6 @@ makedocs(
"Skipping Formatting" => "skipping_formatting.md",
"Syntax Transforms" => "transforms.md",
"Custom Alignment" => "custom_alignment.md",
"Custom Styles" => "custom_styles.md",
"YAS Style" => "yas_style.md",
"Blue Style" => "blue_style.md",
"SciML Style" => "sciml_style.md",
Expand All @@ -21,4 +20,4 @@ makedocs(
warnonly = true,
)

deploydocs(repo = "github.com/domluna/JuliaFormatter.jl.git", push_preview = true)
deploydocs(; repo = "github.com/domluna/JuliaFormatter.jl.git", push_preview = true)
24 changes: 13 additions & 11 deletions docs/src/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,23 @@ margin = 100

then files under `somedir` will be formatted with 2 spaces indentation and the maximum line length 100.

!!! warning "Custom Style"
## Non Default Style

Currently the configuration file doesn't support user-defined [Custom Styles](@ref).
For the time being, we only provide specs for [YAS Style](@ref), [Blue Style](@ref) and [SciML Style](@ref) in configuration file.
In order to use YAS style instead of the default style, you can just specify:
If you would use another style, such as `YASStyle` you can write this in your configuration like so:

> .JuliaFormatter.toml
```toml
style = "yas"
```

Styles choices are:

- "default" (default choice if nothing is specified)
- "yas"
- "blue"
- "sciml"
- "minimal"

```toml
...
style = "yas"
...
```

In the same way as above, you can specify `style = "blue"` to use Blue style.

## Search Rule

Expand Down
66 changes: 0 additions & 66 deletions docs/src/custom_styles.md

This file was deleted.

28 changes: 19 additions & 9 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -527,18 +527,28 @@ end
You can convert short circuit expressions to the equivalent if expression.

```julia
b0 && foo()
b1 || bar()
```
function foo(a, b)
a || return "bar"

respectively become
"hello"

```julia
if b0
foo()
b && return "ooo"
end
if !b1
bar()

BECOMES

function foo(a, b)
if !(a)
return "bar"
end

"hello"

if b
return "ooo"
else
false
end
end
```

Expand Down
Loading

2 comments on commit 2242a32

@domluna
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register

This is a breaking release even though most of the formatting should remain the same but please report any issues.

See #870 for all the changes.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/117403

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v2.0.0 -m "<description of version>" 2242a3201d643aa56217317050e668747581bbb9
git push origin v2.0.0

Please sign in to comment.