Close #596. Improve README documentation

This commit is contained in:
Glavin Wiechert 2016-07-02 19:28:01 -03:00
parent fdc4eccdbf
commit 41ebc5ed93
44 changed files with 471 additions and 94 deletions

174
README-template.md Normal file
View File

@ -0,0 +1,174 @@
# :lipstick: [{{package.name}}](https://github.com/Glavin001/atom-beautify)
[![Build Status](https://travis-ci.org/Glavin001/atom-beautify.svg?branch=master)](https://travis-ci.org/Glavin001/atom-beautify)
[![Build status](https://ci.appveyor.com/api/projects/status/himnq7tjxl2fdc8u?svg=true)](https://ci.appveyor.com/project/Glavin001/atom-beautify)
[![Gitter chat](https://img.shields.io/badge/gitter-Glavin001%2Fatom--beautify-1dce73.svg)](https://gitter.im/Glavin001/atom-beautify)
[![Paypal Donations](https://www.paypalobjects.com/en_US/i/btn/btn_donate_SM.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=X2RK5DKN6YXPJ&lc=CA&item_name=Atom%2dBeautify&item_number=atom%2dbeautify&currency_code=CAD&bn=PP%2dDonationsBF%3abtn_donate_LG%2egif%3aNonHosted)
[![Throughput Graph](https://graphs.waffle.io/Glavin001/atom-beautify/throughput.svg)](https://waffle.io/Glavin001/atom-beautify/metrics)
> {{package.description}}
| Before | After |
| --- | ---- |
| Original HTML | Beautified HTML |
| ![image](https://cloud.githubusercontent.com/assets/1885333/16542239/dd92b766-4076-11e6-8667-0e66cd9f4515.png) | ![image](https://cloud.githubusercontent.com/assets/1885333/16542240/df9bedb6-4076-11e6-98c3-0cbac446583b.png) |
## Table of Contents
- [Installation](#installation)
- [Language Support](#language-support)
- [Usage](#usage)
- [Selection of Code](#selection-of-code)
- [Beautify On Save](#beautify-on-save)
- [Keyboard Shortcut](#keyboard-shortcut)
- [Custom Keyboard Shortcuts](#custom-keyboard-shortcuts)
- [Configuration](#configuration)
- [Simple](#simple)
- [Nested](#nested-recommended)
- [Troubleshooting](#troubleshooting)
- [Contributing](#contributing)
## Installation
Atom Package: https://atom.io/packages/atom-beautify
```bash
apm install atom-beautify
```
Or Settings/Preferences ➔ Packages ➔ Search for `atom-beautify`
## Language Support
See [all supported options in the documentation at `docs/options.md`](https://github.com/Glavin001/atom-beautify/blob/master/docs/options.md).
{{language-beautifiers-support languageOptions}}
## Usage
Open the [Command Palette](https://github.com/atom/command-palette), type `Beautify`, and run `Beautify Editor`.
![image](https://cloud.githubusercontent.com/assets/1885333/16542583/1c8d975c-4085-11e6-8307-e35df7430a10.png)
### Selection of Code
It will only beautify selected text if a selection is found -- if not, the whole file will be beautified.
| Selection of Code | Beautify Selection of Code | Beautify Entire File |
| --- | --- | --- |
| Select code in Atom editor | Only that selection is beautified | Without a selection all code is beautified |
| ![image](https://cloud.githubusercontent.com/assets/1885333/16542597/b3f90c84-4085-11e6-8a0e-1b8604ae385c.png) | ![image](https://cloud.githubusercontent.com/assets/1885333/16542598/b5a86b10-4085-11e6-80cf-0afaf1a819c3.png) | ![image](https://cloud.githubusercontent.com/assets/1885333/16542603/b798ec24-4085-11e6-880e-8d3a2741940f.png) |
### Beautify On Save
`Beautify On Save` can be enabled for each language individually.
For example, for language `HTML` go into Atom-Beautify's package settings (`Atom` ➔ `Preferences` ➔ Search for `atom-beautify`), find `HTML`, and toggle the `Beautify On Save` option.
![atom-beautify-setup-beautify-on-save](https://cloud.githubusercontent.com/assets/1885333/16542692/3e781e74-4089-11e6-9cf2-5a19af161093.gif)
### Keyboard Shortcut
You can also type <kbd>Ctrl</kbd>-<kbd>Alt</kbd>-<kbd>B</kbd> as a shortcut or click `Packages > Beautify` in the menu.
#### Custom Keyboard Shortcuts
See [Keymaps In-Depth](https://atom.io/docs/latest/behind-atom-keymaps-in-depth) for more details.
For example:
```coffeescript
'.editor':
'ctrl-alt-b': 'atom-beautify:beautify-editor'
```
## Configuration
Edit your `.jsbeautifyrc` file in any of the following locations:
- Atom Package Settings
`Atom``Preferences` ➔ Search for `atom-beautify`
- Same directory as current file
- Project root
`atom-beautify` will recursively look up from the current file's directory to find `.jsbeautifyrc`.
- Your user's home directory
**Note**: *Comments are supported in `.jsbeautifyrc` thanks to [strip-json-comments](https://github.com/sindresorhus/strip-json-comments).*
See examples of both ways inside [`examples/`](https://github.com/donaldpipowitch/atom-beautify/tree/master/examples)
See [all supported options in the documentation at `docs/options.md`](https://github.com/Glavin001/atom-beautify/blob/master/docs/options.md).
### Simple
See [examples/simple-jsbeautifyrc/.jsbeautifyrc](https://github.com/donaldpipowitch/atom-beautify/blob/master/examples/simple-jsbeautifyrc/.jsbeautifyrc).
```json
{
"indent_size": 2,
"indent_char": " ",
"other": " ",
"indent_level": 0,
"indent_with_tabs": false,
"preserve_newlines": true,
"max_preserve_newlines": 2,
"jslint_happy": true,
"indent_handlebars": true
}
```
### Nested (Recommended)
See [examples/nested-jsbeautifyrc/.jsbeautifyrc](https://github.com/donaldpipowitch/atom-beautify/blob/master/examples/nested-jsbeautifyrc/.jsbeautifyrc).
```json
{
"html": {
"brace_style": "collapse",
"indent_char": " ",
"indent_scripts": "normal",
"indent_size": 6,
"max_preserve_newlines": 1,
"preserve_newlines": true,
"unformatted": ["a", "sub", "sup", "b", "i", "u"],
"wrap_line_length": 0
},
"css": {
"indent_char": " ",
"indent_size": 4
},
"js": {
"indent_size": 2,
"indent_char": " ",
"indent_level": 0,
"indent_with_tabs": false,
"preserve_newlines": true,
"max_preserve_newlines": 2,
"jslint_happy": true
},
"sql": {
"indent_size": 4,
"indent_char": " ",
"indent_level": 0,
"indent_with_tabs": false
}
}
```
## Troubleshooting
Coming soon.
## Contributing
[See all contributors on GitHub](https://github.com/donaldpipowitch/atom-beautify/graphs/contributors).
Please update the [CHANGELOG.md](https://github.com/donaldpipowitch/atom-beautify/blob/master/CHANGELOG.md),
add yourself as a contributor to the [package.json](https://github.com/donaldpipowitch/atom-beautify/blob/master/package.json),
and submit a [Pull Request on GitHub](https://help.github.com/articles/using-pull-requests/).
## License
[MIT](https://github.com/donaldpipowitch/atom-beautify/blob/master/LICENSE.md) © [Glavin Wiechert](https://github.com/Glavin001)

169
README.md
View File

@ -1,4 +1,4 @@
# [atom-beautify](https://github.com/Glavin001/atom-beautify)
# :lipstick: [atom-beautify](https://github.com/Glavin001/atom-beautify)
[![Build Status](https://travis-ci.org/Glavin001/atom-beautify.svg?branch=master)](https://travis-ci.org/Glavin001/atom-beautify)
[![Build status](https://ci.appveyor.com/api/projects/status/himnq7tjxl2fdc8u?svg=true)](https://ci.appveyor.com/project/Glavin001/atom-beautify)
@ -7,10 +7,29 @@
[![Throughput Graph](https://graphs.waffle.io/Glavin001/atom-beautify/throughput.svg)](https://waffle.io/Glavin001/atom-beautify/metrics)
> [Beautify](https://github.com/beautify-web/js-beautify)
HTML (including [Handlebars](http://handlebarsjs.com/)),
CSS (including [Sass](http://sass-lang.com/) and [Less](http://lesscss.org/)),
JavaScript, and much more in Atom.
> Beautify HTML, CSS, JavaScript, PHP, Python, Ruby, Java, C, C++, C#, Objective-C, CoffeeScript, TypeScript, Coldfusion, SQL, and more in Atom
| Before | After |
| --- | ---- |
| Original HTML | Beautified HTML |
| ![image](https://cloud.githubusercontent.com/assets/1885333/16542727/db52adc6-408a-11e6-824e-04aed06bd2f7.png) | ![image](https://cloud.githubusercontent.com/assets/1885333/16542728/dcac3700-408a-11e6-8e35-9c8fc4432edc.png) |
## Table of Contents
- [Installation](#installation)
- [Language Support](#language-support)
- [Usage](#usage)
- [Selection of Code](#selection-of-code)
- [Beautify On Save](#beautify-on-save)
- [Keyboard Shortcut](#keyboard-shortcut)
- [Custom Keyboard Shortcuts](#custom-keyboard-shortcuts)
- [Configuration](#configuration)
- [Simple](#simple)
- [Nested](#nested-recommended)
- [Troubleshooting](#troubleshooting)
- [Contributing](#contributing)
## Installation
Atom Package: https://atom.io/packages/atom-beautify
@ -22,67 +41,91 @@ Or Settings/Preferences ➔ Packages ➔ Search for `atom-beautify`
## Language Support
- [x] JavaScript and JSON
- [x] HTML, including
- [x] [Handlebars](http://handlebarsjs.com/)
- [x] [Mustache](http://mustache.github.io)
- [x] [Embedded Ruby (ERB)](https://github.com/Glavin001/atom-beautify/issues/80)
- Requires [htmlbeautifier](https://github.com/threedaymonk/htmlbeautifier)
- [x] XML
- [x] SVG
- [x] [Marko](https://github.com/marko-js/marko)
- [x] CSS, including
- [Sass](http://sass-lang.com/)
- [Less](http://lesscss.org/)
- [x] [SQL](https://github.com/Glavin001/atom-beautify/pull/67)
- Requires [python-sqlparse](https://github.com/andialbrecht/sqlparse)
- [x] [Markdown](https://github.com/Glavin001/atom-beautify/issues/292)
- [x] [Perl](https://github.com/Glavin001/atom-beautify/issues/33)
- Requires [perltidy](http://perltidy.sourceforge.net/)
- [x] [PHP](https://github.com/Glavin001/atom-beautify/issues/26)
- Requires [php-cs-fixer](https://github.com/FriendsOfPHP/PHP-CS-Fixer) to be already installed.
- [x] [Python](https://github.com/Glavin001/atom-beautify/issues/24)
- Requires [autopep8](https://github.com/hhatto/autopep8) or [YAPF](https://github.com/google/yapf) to be already installed.
- Beautifies to [PEP 8](https://www.python.org/dev/peps/pep-0008/).
- [x] [Ruby](https://github.com/Glavin001/atom-beautify/issues/25)
- Requires [Ruby Beautify](https://github.com/erniebrodeur/ruby-beautify)
- [x] [CoffeeScript](https://github.com/Glavin001/atom-beautify/issues/31)
- [x] [Golang](https://github.com/Glavin001/atom-beautify/issues/176)
- [x] [Java](https://github.com/Glavin001/atom-beautify/issues/45)
- Requires [Uncrustify](http://sourceforge.net/projects/uncrustify/)
- [x] [C](https://github.com/Glavin001/atom-beautify/issues/57)
- Requires [Uncrustify](http://sourceforge.net/projects/uncrustify/)
- [x] [C++](https://github.com/Glavin001/atom-beautify/issues/57)
- Requires [Uncrustify](http://sourceforge.net/projects/uncrustify/)
- [x] [C#](https://github.com/Glavin001/atom-beautify/issues/57)
- Requires [Uncrustify](http://sourceforge.net/projects/uncrustify/)
- [x] [Objective-C](https://github.com/Glavin001/atom-beautify/issues/57)
- Requires [Uncrustify](http://sourceforge.net/projects/uncrustify/)
- [x] [D](https://github.com/Glavin001/atom-beautify/issues/57)
- Requires [Uncrustify](http://sourceforge.net/projects/uncrustify/) or [dfmt](https://github.com/Hackerpilot/dfmt)
- [x] [Fortran](https://github.com/Glavin001/atom-beautify/issues/300)
- Requires [GNU Emacs](http://www.gnu.org/software/emacs/)
- [x] [Pawn](https://github.com/Glavin001/atom-beautify/issues/57)
- Requires [Uncrustify](http://sourceforge.net/projects/uncrustify/)
- [x] [Vala](https://github.com/Glavin001/atom-beautify/issues/57)
- Requires [Uncrustify](http://sourceforge.net/projects/uncrustify/)
- [x] [TypeScript](https://github.com/Glavin001/atom-beautify/issues/49)
- [x] [Haskell](https://github.com/Glavin001/atom-beautify/issues/628)
- Requires [stylish-haskell](https://github.com/jaspervdj/stylish-haskell)
- [x] [Elm](https://github.com/Glavin001/atom-beautify/pull/700)
- Requires [Elm-Format](https://github.com/avh4/elm-format)
- [x] [Erlang](https://github.com/Glavin001/atom-beautify/pull/683)
- Requires erlang syntax_tools to be installed
- [x] [Crystal](https://github.com/Glavin001/atom-beautify/pull/900)
- [x] [Lua](https://github.com/Glavin001/atom-beautify/pull/973)
See [all supported options in the documentation at `docs/options.md`](https://github.com/Glavin001/atom-beautify/blob/master/docs/options.md).
| Language | Grammars | File Extensions | Supported Beautifiers |
| --- | --- | --- | ---- |
| Apex | `Apex` |`.cls`, `.trigger` | [`Uncrustify`](https://github.com/uncrustify/uncrustify) (Default) |
| Arduino | `Arduino` |`.ino`, `.pde` | [`Uncrustify`](https://github.com/uncrustify/uncrustify) (Default) |
| C | `C`, `opencl` |`.h`, `.c`, `.cl` | [`Uncrustify`](https://github.com/uncrustify/uncrustify) (Default), [`clang-format`](https://clang.llvm.org/docs/ClangFormat.html) |
| Coldfusion | `html` |`.cfm`, `.cfml`, `.cfc` | [`Pretty Diff`](https://github.com/prettydiff/prettydiff) (Default) |
| CoffeeScript | `CoffeeScript` |`.coffee` | [`Coffee Formatter`](https://github.com/Glavin001/Coffee-Formatter), [`coffee-fmt`](https://github.com/sterpe/coffee-fmt) (Default) |
| C++ | `C++` |`.h`, `.hh`, `.cc`, `.cpp`, `.cxx`, `.C`, `.c++`, `.hpp`, `.hxx`, `.h++` | [`Uncrustify`](https://github.com/uncrustify/uncrustify) (Default), [`clang-format`](https://clang.llvm.org/docs/ClangFormat.html) |
| Crystal | `Crystal` |`.cr` | [`Crystal`](http://crystal-lang.org) (Default) |
| C# | `C#` |`.cs` | [`Uncrustify`](https://github.com/uncrustify/uncrustify) (Default) |
| CSS | `CSS` |`.css` | [`CSScomb`](https://github.com/csscomb/csscomb.js), [`JS Beautify`](https://github.com/beautify-web/js-beautify) (Default), [`Pretty Diff`](https://github.com/prettydiff/prettydiff) |
| CSV | `CSV` |`.csv` | [`Pretty Diff`](https://github.com/prettydiff/prettydiff) (Default) |
| D | `D` |`.d` | [`Uncrustify`](https://github.com/uncrustify/uncrustify) (Default), [`dfmt`](https://github.com/Hackerpilot/dfmt) |
| EJS | `JavaScript Template`, `HTML (Angular)` | | [`Pretty Diff`](https://github.com/prettydiff/prettydiff) (Default) |
| Elm | `Elm` |`.elm` | [`elm-format`](https://github.com/avh4/elm-format) (Default) |
| ERB | `HTML (Ruby - ERB)`, `HTML (Rails)` |`.erb` | [`HTML Beautifier`](https://github.com/threedaymonk/htmlbeautifier), [`Pretty Diff`](https://github.com/prettydiff/prettydiff) (Default) |
| Erlang | `Erlang` |`.erl` | [`erl_tidy`](http://erlang.org/doc/man/erl_tidy.html) (Default) |
| Fortran | `Fortran - Modern` |`.f90` | [`Fortran Beautifier`](https://github.com/Glavin001/atom-beautify/blob/master/src/beautifiers/fortran-beautifier/emacs-fortran-formating-script.lisp) (Default) |
| gherkin | `Gherkin` |`.feature` | [`Gherkin formatter`](https://github.com/Glavin001/atom-beautify/blob/master/src/beautifiers/gherkin.coffee) (Default) |
| Go | `Go` |`.go` | [`gofmt`](https://golang.org/cmd/gofmt/) (Default) |
| Handlebars | `Handlebars`, `HTML (Handlebars)` |`.hbs`, `.handlebars` | [`JS Beautify`](https://github.com/beautify-web/js-beautify) (Default), [`Pretty Diff`](https://github.com/prettydiff/prettydiff) |
| Haskell | `Haskell` |`.hs` | [`stylish-haskell`](https://github.com/jaspervdj/stylish-haskell) (Default) |
| HTML | `HTML` |`.html` | [`JS Beautify`](https://github.com/beautify-web/js-beautify) (Default), [`Pretty Diff`](https://github.com/prettydiff/prettydiff) |
| Jade | `Jade`, `Pug` |`.jade`, `.pug` | [`Pug Beautify`](https://github.com/vingorius/pug-beautify) (Default) |
| Java | `Java` |`.java` | [`Uncrustify`](https://github.com/uncrustify/uncrustify) (Default) |
| JavaScript | `JavaScript` |`.js` | [`JS Beautify`](https://github.com/beautify-web/js-beautify) (Default), [`JSCS Fixer`](https://github.com/jscs-dev/node-jscs/), [`Pretty Diff`](https://github.com/prettydiff/prettydiff) |
| JSON | `JSON` |`.json` | [`JS Beautify`](https://github.com/beautify-web/js-beautify) (Default), [`Pretty Diff`](https://github.com/prettydiff/prettydiff) |
| JSX | `JSX`, `JavaScript (JSX)` |`.jsx`, `.js` | [`Pretty Diff`](https://github.com/prettydiff/prettydiff) (Default) |
| LaTeX | `LaTeX` |`.tex` | [`Latex Beautify`](https://github.com/cmhughes/latexindent.pl) (Default) |
| LESS | `LESS` |`.less` | [`CSScomb`](https://github.com/csscomb/csscomb.js), [`Pretty Diff`](https://github.com/prettydiff/prettydiff) (Default) |
| Lua | `Lua` |`.lua` | [`Lua beautifier`](https://github.com/Glavin001/atom-beautify/blob/master/src/beautifiers/lua-beautifier/beautifier.pl) (Default) |
| Markdown | `GitHub Markdown` |`.markdown`, `.md` | [`Remark`](https://github.com/wooorm/remark), [`Tidy Markdown`](https://github.com/slang800/tidy-markdown) (Default) |
| Marko | `Marko` |`.marko` | [`Marko Beautifier`](https://github.com/marko-js/marko-prettyprint) (Default) |
| Mustache | `HTML (Mustache)` |`.mustache` | [`JS Beautify`](https://github.com/beautify-web/js-beautify) (Default) |
| Objective-C | `Objective-C`, `Objective-C++` |`.m`, `.mm`, `.h` | [`Uncrustify`](https://github.com/uncrustify/uncrustify) (Default), [`clang-format`](https://clang.llvm.org/docs/ClangFormat.html) |
| OCaml | `OCaml` |`.ml` | [`ocp-indent`](https://www.typerex.org/ocp-indent.html) (Default) |
| Pawn | `Pawn` | | [`Uncrustify`](https://github.com/uncrustify/uncrustify) (Default) |
| Perl | `Perl`, `Perl 6` |`.pl` | [`Perltidy`](http://perltidy.sourceforge.net/) (Default) |
| PHP | `PHP` |`.php`, `.module`, `.inc` | [`PHP-CS-Fixer`](http://php.net/manual/en/install.php) (Default), [`PHPCBF`](http://php.net/manual/en/install.php) |
| Puppet | `Puppet` |`.pp` | [`puppet-lint`](http://puppet-lint.com/) (Default) |
| Python | `Python` |`.py` | [`autopep8`](https://github.com/hhatto/autopep8) (Default), [`yapf`](https://github.com/google/yapf) |
| Riot.js | `Riot.js`, `HTML (Riot Tag)` |`.tag` | [`Pretty Diff`](https://github.com/prettydiff/prettydiff) (Default) |
| Ruby | `Ruby`, `Ruby on Rails` |`.rb` | [`Rubocop`](https://github.com/bbatsov/rubocop) (Default), [`Ruby Beautify`](https://github.com/erniebrodeur/ruby-beautify) |
| Rust | `Rust` |`.rs`, `.rlib` | [`rustfmt`](https://github.com/nrc/rustfmt) (Default) |
| Sass | `Sass` |`.sass` | [`CSScomb`](https://github.com/csscomb/csscomb.js), [`Pretty Diff`](https://github.com/prettydiff/prettydiff) (Default) |
| SCSS | `SCSS` |`.scss` | [`CSScomb`](https://github.com/csscomb/csscomb.js), [`Pretty Diff`](https://github.com/prettydiff/prettydiff) (Default) |
| Spacebars | `Spacebars` | | [`Pretty Diff`](https://github.com/prettydiff/prettydiff) (Default) |
| SQL | `SQL (Rails)`, `SQL` |`.sql` | [`sqlformat`](https://github.com/andialbrecht/sqlparse) (Default) |
| SVG | `SVG` |`.svg` | [`Pretty Diff`](https://github.com/prettydiff/prettydiff) (Default) |
| Swig | `HTML (Swig)`, `SWIG` |`.swig` | [`Pretty Diff`](https://github.com/prettydiff/prettydiff) (Default) |
| TSS | `TSS` |`.tss` | [`Pretty Diff`](https://github.com/prettydiff/prettydiff) (Default) |
| Twig | `HTML (Twig)` |`.twig` | [`Pretty Diff`](https://github.com/prettydiff/prettydiff) (Default) |
| TypeScript | `TypeScript` |`.ts` | [`TypeScript Formatter`](https://github.com/vvakame/typescript-formatter) (Default) |
| Vala | `Vala` |`.vala`, `.vapi` | [`Uncrustify`](https://github.com/uncrustify/uncrustify) (Default) |
| Visualforce | `Visualforce` |`.page` | [`Pretty Diff`](https://github.com/prettydiff/prettydiff) (Default) |
| XML | `SLD`, `XML`, `XHTML`, `XSD`, `XSL`, `JSP` |`.sld`, `.xml`, `.xhtml`, `.xsd`, `.xsl`, `.jsp` | [`JS Beautify`](https://github.com/beautify-web/js-beautify), [`Pretty Diff`](https://github.com/prettydiff/prettydiff) (Default) |
| XTemplate | `XTemplate` |`.xtemplate` | [`Pretty Diff`](https://github.com/prettydiff/prettydiff) (Default) |
## Usage
Open the [Command Palette](https://github.com/atom/command-palette), and type `Beautify`.
Open the [Command Palette](https://github.com/atom/command-palette), type `Beautify`, and run `Beautify Editor`.
![image](https://cloud.githubusercontent.com/assets/1885333/16542583/1c8d975c-4085-11e6-8307-e35df7430a10.png)
### Selection of Code
It will only beautify selected text if a selection is found -- if not, the whole file will be beautified.
### Shortcut
| Selection of Code | Beautify Selection of Code | Beautify Entire File |
| --- | --- | --- |
| Select code in Atom editor | Only that selection is beautified | Without a selection all code is beautified |
| ![image](https://cloud.githubusercontent.com/assets/1885333/16542597/b3f90c84-4085-11e6-8a0e-1b8604ae385c.png) | ![image](https://cloud.githubusercontent.com/assets/1885333/16542598/b5a86b10-4085-11e6-80cf-0afaf1a819c3.png) | ![image](https://cloud.githubusercontent.com/assets/1885333/16542603/b798ec24-4085-11e6-880e-8d3a2741940f.png) |
### Beautify On Save
`Beautify On Save` can be enabled for each language individually.
For example, for language `HTML` go into Atom-Beautify's package settings (`Atom` ➔ `Preferences` ➔ Search for `atom-beautify`), find `HTML`, and toggle the `Beautify On Save` option.
![atom-beautify-setup-beautify-on-save](https://cloud.githubusercontent.com/assets/1885333/16542692/3e781e74-4089-11e6-9cf2-5a19af161093.gif)
### Keyboard Shortcut
You can also type <kbd>Ctrl</kbd>-<kbd>Alt</kbd>-<kbd>B</kbd> as a shortcut or click `Packages > Beautify` in the menu.
@ -132,7 +175,7 @@ See [examples/simple-jsbeautifyrc/.jsbeautifyrc](https://github.com/donaldpipowi
}
```
### Nested
### Nested (Recommended)
See [examples/nested-jsbeautifyrc/.jsbeautifyrc](https://github.com/donaldpipowitch/atom-beautify/blob/master/examples/nested-jsbeautifyrc/.jsbeautifyrc).
@ -170,6 +213,10 @@ See [examples/nested-jsbeautifyrc/.jsbeautifyrc](https://github.com/donaldpipowi
}
```
## Troubleshooting
Coming soon.
## Contributing
[See all contributors on GitHub](https://github.com/donaldpipowitch/atom-beautify/graphs/contributors).

View File

@ -5,12 +5,16 @@ Handlebars = require('handlebars')
Beautifiers = require("../src/beautifiers")
fs = require('fs')
_ = require('lodash')
path = require('path')
pkg = require('../package.json')
console.log('Generating options...')
beautifier = new Beautifiers()
languageOptions = beautifier.options
packageOptions = require('../src/config.coffee')
# Build options by Beautifier
beautifiersMap = _.keyBy(beautifier.beautifiers, 'name')
languagesMap = _.keyBy(beautifier.languages.languages, 'name')
beautifierOptions = {}
for lo, optionGroup of languageOptions
for optionName, optionDef of optionGroup.properties
@ -20,18 +24,23 @@ for lo, optionGroup of languageOptions
beautifierOptions[beautifierName][optionName] = optionDef
console.log('Loading options template...')
readmeTemplatePath = path.resolve(__dirname, '../README-template.md')
readmePath = path.resolve(__dirname, '../README.md')
optionsTemplatePath = __dirname + '/options-template.md'
optionTemplatePath = __dirname + '/option-template.md'
optionGroupTemplatePath = __dirname + '/option-group-template.md'
optionsPath = __dirname + '/options.md'
optionsTemplate = fs.readFileSync(optionsTemplatePath).toString()
optionGroupTemplate = fs.readFileSync(optionGroupTemplatePath).toString()
optionTemplate = fs.readFileSync(optionTemplatePath).toString()
readmeTemplate = fs.readFileSync(readmeTemplatePath).toString()
console.log('Building documentation from template and options...')
Handlebars.registerPartial('option', optionTemplate)
Handlebars.registerPartial('option-group', optionGroupTemplate)
template = Handlebars.compile(optionsTemplate)
readmeTemplate = Handlebars.compile(readmeTemplate)
linkifyTitle = (title) ->
title = title.toLowerCase()
@ -71,6 +80,41 @@ Handlebars.registerHelper('example-config', (key, option, options) ->
return new Handlebars.SafeString(results)
)
Handlebars.registerHelper('language-beautifiers-support', (languageOptions, options) ->
###
| Language | Supported Beautifiers |
| --- | ---- |
| JavaScript | Js-Beautify, Pretty Diff |
###
rows = _.map(languageOptions, (val, k) ->
name = val.title
defaultBeautifier = _.get(val, "properties.default_beautifier.default")
beautifiers = _.map(val.beautifiers, (b) ->
beautifier = beautifiersMap[b]
isDefault = b is defaultBeautifier
if beautifier.link
r = "[`#{b}`](#{beautifier.link})"
else
r = "`#{b}`"
if isDefault
r += " (Default)"
return r
)
grammars = _.map(val.grammars, (b) -> "`#{b}`")
extensions = _.map(val.extensions, (b) -> "`.#{b}`")
return "| #{name} | #{grammars.join(', ')} |#{extensions.join(', ')} | #{beautifiers.join(', ')} |"
)
results = """
| Language | Grammars | File Extensions | Supported Beautifiers |
| --- | --- | --- | ---- |
#{rows.join('\n')}
"""
return new Handlebars.SafeString(results)
)
sortKeysBy = (obj, comparator) ->
keys = _.sortBy(_.keys(obj), (key) ->
return if comparator then comparator(obj[key], key) else key
@ -93,13 +137,27 @@ sortSettings = (settings) ->
return r
context = {
package: pkg,
packageOptions: sortSettings(packageOptions)
languageOptions: sortSettings(languageOptions)
beautifierOptions: sortSettings(beautifierOptions)
}
result = template(context)
readmeResult = readmeTemplate(context)
console.log('Writing documentation to file...')
fs.writeFileSync(optionsPath, result)
fs.writeFileSync(readmePath, readmeResult)
# fs.writeFileSync(__dirname+'/context.json', JSON.stringify(context, undefined, 2))
console.log('Updating package.json')
# Add Language keywords
ls = _.map(Object.keys(languagesMap), (a)->a.toLowerCase())
# Add Beautifier keywords
bs = _.map(Object.keys(beautifiersMap), (a)->a.toLowerCase())
keywords = _.union(pkg.keywords, ls, bs)
pkg.keywords = keywords
fs.writeFileSync(path.resolve(__dirname,'../package.json'), JSON.stringify(pkg, undefined, 2))
console.log('Done.')

View File

@ -1181,7 +1181,7 @@ Path to uncrustify config file. i.e. uncrustify.cfg (Supported by Uncrustify)
#### [Crystal](#crystal)
**Supported Beautifiers**: [`crystal`](#crystal)
**Supported Beautifiers**: [`Crystal`](#crystal)
**Description**:
@ -1208,11 +1208,11 @@ Disable Crystal Beautification
**Important**: This option is only configurable from within Atom Beautify's setting panel.
**Default**: `crystal`
**Default**: `Crystal`
**Type**: `string`
**Enum**: `crystal`
**Enum**: `Crystal`
**Description**:
@ -5806,7 +5806,7 @@ Maximum amount of characters per line (0 = disable) (Supported by Pretty Diff)
#### [Lua](#lua)
**Supported Beautifiers**: [`lua`](#lua)
**Supported Beautifiers**: [`Lua beautifier`](#lua-beautifier)
**Description**:
@ -5833,11 +5833,11 @@ Disable Lua Beautification
**Important**: This option is only configurable from within Atom Beautify's setting panel.
**Default**: `lua`
**Default**: `Lua beautifier`
**Type**: `string`
**Enum**: `lua`
**Enum**: `Lua beautifier`
**Description**:

View File

@ -1,14 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html>
<html lang="en-us" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Test</title>
</head>
<body>
<ul>
<li><code>foo:bar</code></li>
<li>
<code>foo:bar</code>
</li>
</ul>
</body>
</html>

View File

@ -7,4 +7,5 @@
<ul>
<li><code>foo:bar</code></li>
</ul>
</body>
</html>

View File

@ -3,7 +3,7 @@
"main": "./src/beautify",
"version": "0.29.9",
"private": true,
"description": "Beautify HTML, CSS, JavaScript, PHP, Python, Ruby, Java, C, C++, C#, Objective-C, CoffeeScript, TypeScript, Coldfusion, and SQL in Atom",
"description": "Beautify HTML, CSS, JavaScript, PHP, Python, Ruby, Java, C, C++, C#, Objective-C, CoffeeScript, TypeScript, Coldfusion, SQL, and more in Atom",
"repository": {
"type": "git",
"url": "https://github.com/Glavin001/atom-beautify"
@ -163,7 +163,6 @@
"css",
"javascript",
"json",
"css",
"sass",
"scss",
"less",
@ -197,7 +196,62 @@
"golang",
"svg",
"elm",
"lua"
"lua",
"arduino",
"crystal",
"csv",
"ejs",
"erlang",
"gherkin",
"fortran",
"haskell",
"jade",
"jsx",
"latex",
"ocaml",
"perl",
"puppet",
"riot.js",
"rust",
"spacebars",
"swig",
"tss",
"twig",
"visualforce",
"xtemplate",
"autopep8",
"coffee formatter",
"coffee-fmt",
"clang-format",
"dfmt",
"elm-format",
"html beautifier",
"csscomb",
"gherkin formatter",
"gofmt",
"latex beautify",
"fortran beautifier",
"js beautify",
"jscs fixer",
"lua beautifier",
"ocp-indent",
"perltidy",
"php-cs-fixer",
"phpcbf",
"pretty diff",
"pug beautify",
"puppet-lint",
"remark",
"rubocop",
"ruby beautify",
"rustfmt",
"sqlformat",
"stylish-haskell",
"tidy markdown",
"typescript formatter",
"yapf",
"erl_tidy",
"marko beautifier"
],
"devDependencies": {
"coffeelint": "^1.10.1",

View File

@ -184,6 +184,8 @@ buildOptionsForBeautifiers = function(beautifiers, allLanguages) {
description: "Options for language " + lang.name,
collapsed: true,
beautifiers: [],
grammars: lang.grammars,
extensions: lang.extensions,
properties: {}
};
}

View File

@ -8,6 +8,7 @@ Beautifier = require('./beautifier')
module.exports = class Autopep8 extends Beautifier
name: "autopep8"
link: "https://github.com/hhatto/autopep8"
options: {
Python: true

View File

@ -10,6 +10,7 @@ fs = require('fs')
module.exports = class ClangFormat extends Beautifier
name: "clang-format"
link: "https://clang.llvm.org/docs/ClangFormat.html"
options: {
"C++": false

View File

@ -3,6 +3,7 @@ Beautifier = require('./beautifier')
module.exports = class CoffeeFmt extends Beautifier
name: "coffee-fmt"
link: "https://github.com/sterpe/coffee-fmt"
options: {
# Apply language-specific options

View File

@ -4,6 +4,7 @@ Beautifier = require('./beautifier')
module.exports = class CoffeeFormatter extends Beautifier
name: "Coffee Formatter"
link: "https://github.com/Glavin001/Coffee-Formatter"
options: {
CoffeeScript: true

View File

@ -6,7 +6,8 @@ Requires https://github.com/jaspervdj/stylish-haskell
Beautifier = require('./beautifier')
module.exports = class Crystal extends Beautifier
name: "crystal"
name: "Crystal"
link: "http://crystal-lang.org"
options: {
Crystal: true

View File

@ -3,6 +3,7 @@ Beautifier = require('./beautifier')
module.exports = class JSBeautify extends Beautifier
name: "CSScomb"
link: "https://github.com/csscomb/csscomb.js"
options: {
# TODO: Add support for options

View File

@ -6,6 +6,7 @@ Beautifier = require('./beautifier')
module.exports = class Dfmt extends Beautifier
name: "dfmt"
link: "https://github.com/Hackerpilot/dfmt"
options: {
D: false

View File

@ -6,6 +6,7 @@ Beautifier = require('./beautifier')
module.exports = class ElmFormat extends Beautifier
name: "elm-format"
link: "https://github.com/avh4/elm-format"
options: {
Elm: true

View File

@ -8,6 +8,7 @@ Beautifier = require('./beautifier')
module.exports = class ErlTidy extends Beautifier
name: "erl_tidy"
link: "http://erlang.org/doc/man/erl_tidy.html"
options: {
Erlang: true
@ -20,7 +21,9 @@ module.exports = class ErlTidy extends Beautifier
@run("erl", [
["-eval", 'erl_tidy:file("' + tempFile + '")']
["-noshell", "-s", "init", "stop"]
])
],
{ help: { link: "http://erlang.org/doc/man/erl_tidy.html" } }
)
).then(=>
@readFile(tempFile)
)

View File

@ -8,6 +8,7 @@ path = require("path")
module.exports = class FortranBeautifier extends Beautifier
name: "Fortran Beautifier"
link: "https://github.com/Glavin001/atom-beautify/blob/master/src/beautifiers/fortran-beautifier/emacs-fortran-formating-script.lisp"
options: {
Fortran: true

View File

@ -8,6 +8,7 @@ logger = require('../logger')(__filename)
module.exports = class Gherkin extends Beautifier
name: "Gherkin formatter"
link: "https://github.com/Glavin001/atom-beautify/blob/master/src/beautifiers/gherkin.coffee"
options: {
gherkin: true

View File

@ -7,6 +7,7 @@ Beautifier = require('./beautifier')
module.exports = class Gofmt extends Beautifier
name: "gofmt"
link: "https://golang.org/cmd/gofmt/"
options: {
Go: true

View File

@ -7,6 +7,7 @@ Beautifier = require('./beautifier')
module.exports = class HTMLBeautifier extends Beautifier
name: "HTML Beautifier"
link: "https://github.com/threedaymonk/htmlbeautifier"
options: {
ERB:
indent_size: true

View File

@ -3,6 +3,7 @@ Beautifier = require('./beautifier')
module.exports = class JSBeautify extends Beautifier
name: "JS Beautify"
link: "https://github.com/beautify-web/js-beautify"
options: {
HTML: true

View File

@ -7,6 +7,7 @@ checker = null
module.exports = class JSCSFixer extends Beautifier
name: "JSCS Fixer"
link: "https://github.com/jscs-dev/node-jscs/"
options: {
JavaScript: false

View File

@ -7,6 +7,7 @@ temp = require("temp").track()
module.exports = class LatexBeautify extends Beautifier
name: "Latex Beautify"
link: "https://github.com/cmhughes/latexindent.pl"
options: {
LaTeX: true

View File

@ -6,7 +6,8 @@ path = require("path")
Beautifier = require('../beautifier')
module.exports = class Lua extends Beautifier
name: "lua"
name: "Lua beautifier"
link: "https://github.com/Glavin001/atom-beautify/blob/master/src/beautifiers/lua-beautifier/beautifier.pl"
options: {
Lua: true

View File

@ -4,6 +4,7 @@ Beautifier = require('./beautifier')
module.exports = class MarkoBeautifier extends Beautifier
name: 'Marko Beautifier'
link: "https://github.com/marko-js/marko-prettyprint"
options:
Marko: true

View File

@ -7,6 +7,7 @@ Beautifier = require('./beautifier')
module.exports = class OCPIndent extends Beautifier
name: "ocp-indent"
link: "https://www.typerex.org/ocp-indent.html"
options: {
OCaml: true

View File

@ -6,6 +6,7 @@ Beautifier = require('./beautifier')
module.exports = class PerlTidy extends Beautifier
name: "Perltidy"
link: "http://perltidy.sourceforge.net/"
options: {
Perl: true

View File

@ -9,6 +9,7 @@ path = require('path')
module.exports = class PHPCSFixer extends Beautifier
name: 'PHP-CS-Fixer'
link: "http://php.net/manual/en/install.php"
options:
PHP: true

View File

@ -7,6 +7,7 @@ Beautifier = require('./beautifier')
module.exports = class PHPCBF extends Beautifier
name: "PHPCBF"
link: "http://php.net/manual/en/install.php"
options: {
_:

View File

@ -3,6 +3,7 @@ Beautifier = require('./beautifier')
module.exports = class PrettyDiff extends Beautifier
name: "Pretty Diff"
link: "https://github.com/prettydiff/prettydiff"
options: {
# Apply these options first / globally, for all languages
_:

View File

@ -3,6 +3,7 @@ Beautifier = require('./beautifier')
module.exports = class PugBeautify extends Beautifier
name: "Pug Beautify"
link: "https://github.com/vingorius/pug-beautify"
options: {
# Apply these options first / globally, for all languages
Jade:

View File

@ -7,6 +7,7 @@ Beautifier = require('./beautifier')
module.exports = class PuppetFix extends Beautifier
# this is what displays as your Default Beautifier in Language Config
name: "puppet-lint"
link: "http://puppet-lint.com/"
options: {
Puppet: true

View File

@ -3,6 +3,7 @@ Beautifier = require('./beautifier')
module.exports = class Remark extends Beautifier
name: "Remark"
link: "https://github.com/wooorm/remark"
options: {
_: {
gfm: true

View File

@ -7,6 +7,7 @@ Beautifier = require('./beautifier')
module.exports = class Rubocop extends Beautifier
name: "Rubocop"
link: "https://github.com/bbatsov/rubocop"
options: {
Ruby:

View File

@ -7,6 +7,7 @@ Beautifier = require('./beautifier')
module.exports = class RubyBeautify extends Beautifier
name: "Ruby Beautify"
link: "https://github.com/erniebrodeur/ruby-beautify"
options: {
Ruby:

View File

@ -10,6 +10,7 @@ versionCheckState = false
module.exports = class Rustfmt extends Beautifier
name: "rustfmt"
link: "https://github.com/nrc/rustfmt"
options: {
Rust: true

View File

@ -7,6 +7,7 @@ Beautifier = require('./beautifier')
module.exports = class Sqlformat extends Beautifier
name: "sqlformat"
link: "https://github.com/andialbrecht/sqlparse"
options: {
SQL: true

View File

@ -7,6 +7,7 @@ Beautifier = require('./beautifier')
module.exports = class StylishHaskell extends Beautifier
name: "stylish-haskell"
link: "https://github.com/jaspervdj/stylish-haskell"
options: {
Haskell: true
@ -15,4 +16,8 @@ module.exports = class StylishHaskell extends Beautifier
beautify: (text, language, options) ->
@run("stylish-haskell", [
@tempFile("input", text)
])
], {
help: {
link: "https://github.com/jaspervdj/stylish-haskell"
}
})

View File

@ -3,6 +3,7 @@ Beautifier = require('./beautifier')
module.exports = class TidyMarkdown extends Beautifier
name: "Tidy Markdown"
link: "https://github.com/slang800/tidy-markdown"
options: {
Markdown: false
}

View File

@ -3,6 +3,7 @@ Beautifier = require('./beautifier')
module.exports = class TypeScriptFormatter extends Beautifier
name: "TypeScript Formatter"
link: "https://github.com/vvakame/typescript-formatter"
options: {
TypeScript: true
}

View File

@ -10,6 +10,7 @@ _ = require('lodash')
module.exports = class Uncrustify extends Beautifier
name: "Uncrustify"
link: "https://github.com/uncrustify/uncrustify"
options: {
Apex: true
C: true

View File

@ -8,6 +8,7 @@ Beautifier = require('./beautifier')
module.exports = class Yapf extends Beautifier
name: "yapf"
link: "https://github.com/google/yapf"
options: {
Python: false

View File

@ -17,6 +17,6 @@ module.exports = {
'lua'
]
defaultBeautifier: "lua"
defaultBeautifier: "Lua beautifier"
}