Skip to content

Commit

Permalink
Add support for JSON with python3 -m json.tool (#257)
Browse files Browse the repository at this point in the history
  • Loading branch information
scop authored Dec 15, 2023
1 parent a382795 commit 41dff90
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ The format is based on [Keep a Changelog].
[HTML](https://en.wikipedia.org/wiki/HTML) and
[CSS](https://www.google.com/search?q=css)
([#229])
* [`python3-json`](https://docs.python.org/3/library/json.html#module-json.tool)
for JSON ([#257]).
* [`robotidy`](https://robotidy.readthedocs.io) for Robot Framework files
([#263]).
* [denofmt](https://docs.deno.com/runtime/manual/tools/formatter) for
Expand All @@ -24,6 +26,7 @@ The format is based on [Keep a Changelog].
clojurescript, edn files. ([#271])

[#229]: https://github.com/radian-software/apheleia/pull/229
[#257]: https://github.com/radian-software/apheleia/pull/257
[#260]: https://github.com/radian-software/apheleia/pull/260
[#261]: https://github.com/radian-software/apheleia/pull/261
[#263]: https://github.com/radian-software/apheleia/pull/263
Expand Down
3 changes: 3 additions & 0 deletions apheleia-formatters.el
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@
(robotidy . ("robotidy" "--no-color" "-"
(apheleia-formatters-indent nil "--indent")
(apheleia-formatters-fill-column "--line-length")))
(python3-json
. ("python3" "-m" "json.tool"
(apheleia-formatters-indent "--tab" "--indent")))
(rubocop . ("rubocop" "--stdin" filepath "--auto-correct"
"--stderr" "--format" "quiet" "--fail-level" "fatal"))
(ruby-standard . ("standardrb" "--stdin" filepath "--fix" "--stderr"
Expand Down
1 change: 1 addition & 0 deletions apheleia-utils.el
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ always returns nil to defer to the formatter."
(nxml-mode 'nxml-child-indent)
(robot-mode 'robot-mode-basic-offset)
(perl-mode 'perl-indent-level)
(python-mode 'python-indent-offset)
(scss-mode 'css-indent-offset)
(web-mode 'web-mode-indent-style)
(tsx-ts-mode 'typescript-ts-mode-indent-offset)
Expand Down
1 change: 1 addition & 0 deletions test/formatters/installers/python3-json.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
apt-get install -y python3
1 change: 1 addition & 0 deletions test/formatters/samplecode/python3-json/in.json
19 changes: 19 additions & 0 deletions test/formatters/samplecode/python3-json/out.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"arrowParens": "always",
"bracketSpacing": true,
"embeddedLanguageFormatting": "auto",
"htmlWhitespaceSensitivity": "css",
"insertPragma": false,
"jsxBracketSameLine": false,
"jsxSingleQuote": false,
"printWidth": 80,
"proseWrap": "preserve",
"quoteProps": "as-needed",
"requirePragma": false,
"semi": true,
"singleQuote": false,
"tabWidth": 2,
"trailingComma": "es5",
"useTabs": false,
"vueIndentScriptAndStyle": false
}

0 comments on commit 41dff90

Please sign in to comment.