https://github.com/wolframresearch/codeformatter
Format Wolfram Language source code
https://github.com/wolframresearch/codeformatter
codeformatter codetools formatter formatting formatting-wolfram-language mathematica wolfram-language wolfram-mathematica
Last synced: 2 months ago
JSON representation
Format Wolfram Language source code
- Host: GitHub
- URL: https://github.com/wolframresearch/codeformatter
- Owner: WolframResearch
- License: mit
- Created: 2020-10-05T16:16:37.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-11-14T11:05:47.000Z (over 2 years ago)
- Last Synced: 2025-02-02T18:25:16.983Z (4 months ago)
- Topics: codeformatter, codetools, formatter, formatting, formatting-wolfram-language, mathematica, wolfram-language, wolfram-mathematica
- Language: Mathematica
- Homepage:
- Size: 1.52 MB
- Stars: 46
- Watchers: 19
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# CodeFormatter
CodeFormatter is a package that provides functionality for formatting Wolfram Language code.
```
Needs["CodeFormatter`"]CodeFormat["If[a,f/@b,g/@c]"]
```
```
Out[2]= If[a,
f /@ b
,
g /@ c
]```
[Formatting the Wolfram Language from WTC 2020: Watch Video (youtube)](https://www.youtube.com/watch?v=eGvvKlfaPsQ)
## Setup
CodeFormatter depends on [CodeParser paclet](https://github.com/WolframResearch/codeparser).
CodeFormatter and its dependencies are included in Mathematica 12.2 and above.
For older versions, install CodeFormatter paclet and dependencies from the public paclet server:
```
PacletInstall["CodeParser"]
PacletInstall["CodeFormatter"]
```[Build and install the CodeFormatter paclet locally](HowToBuild.md)
## Using CodeFormatter
After CodeFormatter is installed, it can be used.
```
Needs["CodeFormatter`"]CodeFormat["If[a,f/@b,g/@c]"]
```
```
Out[2]= If[a,
f /@ b
,
g /@ c
]```
The input to `CodeFormat` may be a string, a `File`, or a list of bytes.
## Troubleshooting
Make sure that the paclets can be found on your system:
```
Needs["CodeFormatter`"]
```and try a basic example:
```
CodeFormat["If[a, b, c]"]
```