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

Wolfram Language formatter #575

Open
maxitg opened this issue Dec 15, 2020 · 2 comments
Open

Wolfram Language formatter #575

maxitg opened this issue Dec 15, 2020 · 2 comments
Assignees
Labels
feature New functionality, or change in existing functionality infrastructure Has to do with changes to the development process, e.g., build scripts, CI, testing utilities wolfram language Requires Wolfram Language implementation

Comments

@maxitg
Copy link
Owner

maxitg commented Dec 15, 2020

The problem

Wolfram Language formatting should be included in the ./lint.sh script and run in the git hooks and CI.

Possible solution

There are two candidates I am aware of:

The official formatter seems to have some trouble with respecting the specified line width. If not fixed, that will make it unusable as it will be in conflict with ./checkLineWidth.sh.

The formatter by @Lshift has another issue in that it formats the code for the StandardForm, which means there are, e.g., no spaces around + or @.

It's not clear which of these issues is easier to fix, so the one we pick will depend on that.

@maxitg maxitg added feature New functionality, or change in existing functionality infrastructure Has to do with changes to the development process, e.g., build scripts, CI, testing utilities wolfram language Requires Wolfram Language implementation labels Dec 15, 2020
@maxitg maxitg self-assigned this Dec 15, 2020
@maxitg maxitg mentioned this issue Dec 15, 2020
12 tasks
@lshifr
Copy link

lshifr commented Dec 15, 2020

The official formatter might be a more future-proof solution in the long term. OTOH, for my version, in principle it should be easier to write extensions with specific formatting rules (which is a state I've been originally planning to bring it to) , since it is all written in top-level WL and has zero dependencies.

Depending on the time frame when this is needed, I may be able to fix specific issues mentioned - I do have some uncommitted work in progress.

@maxitg
Copy link
Owner Author

maxitg commented Dec 28, 2020

Thanks for your reply, @lshifr!

I tried using your formatter on one of our files, and there are quite a few issues. Here is what it looks like (see the last cell):

CodeFormatterTesting-01.nb.zip

Some of the issues:

  • An empty line in the beginning.
  • No spaces before or after ->, = and commas.
  • The string in SetUsage exceeds the width limit.
  • A comma appeared and spaces disappeared from the (* options processing *) and other comments.
  • Semicolons on the new lines.

If you already have something that fixes these issues, it would be great if you could push it. But otherwise, I'm going to focus on other issues for the time being (the official formatter has serious issues as well, e.g., it does not seem to respect the line width whatsoever).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New functionality, or change in existing functionality infrastructure Has to do with changes to the development process, e.g., build scripts, CI, testing utilities wolfram language Requires Wolfram Language implementation
Projects
None yet
Development

No branches or pull requests

2 participants