Merge pull request #1600 from Glavin001/feature/312

See #312. Add align-yaml as YAML beautifier
This commit is contained in:
Glavin Wiechert 2017-04-15 21:09:29 -03:00 committed by GitHub
commit 65dba9c30e
10 changed files with 189 additions and 3 deletions

View File

@ -62,6 +62,7 @@ Some of the supported beautifiers are developed for Node.js and are automaticall
| Beautifier | Is Pre-Installed? | Installation Instructions |
| --- | --- | --- |
| align-yaml | :white_check_mark: | Nothing! |
| autopep8 | :x: | Go to https://github.com/hhatto/autopep8 and follow the instructions. |
| beautysh | :x: | Go to https://github.com/bemeurer/beautysh and follow the instructions. |
| clang-format | :x: | Go to https://clang.llvm.org/docs/ClangFormat.html and follow the instructions. |
@ -177,6 +178,7 @@ See [all supported options in the documentation at `docs/options.md`](docs/opti
| Vue | `Vue Component` |`.vue` | [`Vue Beautifier`](https://github.com/Glavin001/atom-beautify/blob/master/src/beautifiers/vue-beautifier.coffee) (Default) |
| XML | `SLD`, `XML`, `XHTML`, `XSD`, `XSL`, `JSP`, `GSP` |`.sld`, `.xml`, `.xhtml`, `.xsd`, `.xsl`, `.jsp`, `.gsp`, `.plist`, `.recipe` | [`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) |
| YAML | `YAML` |`.yml`, `.yaml` | [`align-yaml`](https://github.com/jonschlinkert/align-yaml) (Default) |
## Usage

View File

@ -14902,6 +14902,100 @@ Maximum characters per line (0 disables) (Supported by Pretty Diff)
}
```
#### [YAML](#yaml)
**Supported Beautifiers**: [`align-yaml`](#align-yaml)
| Option | align-yaml |
| --- | --- |
| `disabled` | :white_check_mark: |
| `default_beautifier` | :white_check_mark: |
| `beautify_on_save` | :white_check_mark: |
| `padding` | :white_check_mark: |
**Description**:
Options for language YAML
##### [Disable Beautifying Language](#disable-beautifying-language)
**Important**: This option is only configurable from within Atom Beautify's setting panel.
**Type**: `boolean`
**Description**:
Disable YAML Beautification
**How to Configure**
1. You can open the [Settings View](https://github.com/atom/settings-view) by navigating to
*Edit > Preferences (Linux)*, *Atom > Preferences (OS X)*, or *File > Preferences (Windows)*.
2. Go into *Packages* and search for "*Atom Beautify*" package.
3. Find the option "*Disable Beautifying Language*" and change it to your desired configuration.
##### [Default Beautifier](#default-beautifier)
**Important**: This option is only configurable from within Atom Beautify's setting panel.
**Default**: `align-yaml`
**Type**: `string`
**Enum**: `align-yaml`
**Description**:
Default Beautifier to be used for YAML
**How to Configure**
1. You can open the [Settings View](https://github.com/atom/settings-view) by navigating to
*Edit > Preferences (Linux)*, *Atom > Preferences (OS X)*, or *File > Preferences (Windows)*.
2. Go into *Packages* and search for "*Atom Beautify*" package.
3. Find the option "*Default Beautifier*" and change it to your desired configuration.
##### [Beautify On Save](#beautify-on-save)
**Important**: This option is only configurable from within Atom Beautify's setting panel.
**Type**: `boolean`
**Description**:
Automatically beautify YAML files on save
**How to Configure**
1. You can open the [Settings View](https://github.com/atom/settings-view) by navigating to
*Edit > Preferences (Linux)*, *Atom > Preferences (OS X)*, or *File > Preferences (Windows)*.
2. Go into *Packages* and search for "*Atom Beautify*" package.
3. Find the option "*Beautify On Save*" and change it to your desired configuration.
##### [Padding](#padding)
**Namespace**: `yaml`
**Key**: `padding`
**Type**: `integer`
**Supported Beautifiers**: [`align-yaml`](#align-yaml)
**Description**:
The amount of padding to add next to each line. (Supported by align-yaml)
**Example `.jsbeautifyrc` Configuration**
```json
{
"yaml": {
"padding": 0
}
}
```
## Beautifier Options
@ -19179,6 +19273,33 @@ List of tags (defaults to [head,body,/html] that should have an extra newline be
```
### align-yaml
##### [Padding](#padding)
**Namespace**: `yaml`
**Key**: `padding`
**Type**: `integer`
**Supported Beautifiers**: [`align-yaml`](#align-yaml)
**Description**:
The amount of padding to add next to each line. (Supported by align-yaml)
**Example `.jsbeautifyrc` Configuration**
```json
{
"yaml": {
"padding": 0
}
}
```
### autopep8
##### [Max line length](#max-line-length)

View File

@ -64,3 +64,5 @@
space_before_conditional: false
space_after_anon_function: false
jslint_happy: false
yaml:
padding: 5

View File

@ -0,0 +1,3 @@
one: two
three: four
seventeen: five

View File

@ -0,0 +1,3 @@
one: two
three: four
seventeen: five

View File

@ -140,6 +140,7 @@
"atom": ">=1.6.0 <2.0.0"
},
"dependencies": {
"align-yaml": "^0.1.8",
"async": "^2.0.1",
"atom-message-panel": "^1.2.4",
"atom-space-pen-views": "^2.0.5",
@ -162,8 +163,8 @@
"loophole": "^1.0.0",
"marko-prettyprint": "^1.2.0",
"nginxbeautify": "^2.0.0",
"node-dir": "^0.1.16",
"node-cljfmt": "^0.5.3-1",
"node-dir": "^0.1.16",
"node-uuid": "^1.4.3",
"open": "0.0.5",
"prettydiff": "^1.16.27",
@ -319,7 +320,8 @@
"hh_format",
"nginx",
"nginx beautify",
"golang template"
"golang template",
"align-yaml"
],
"devDependencies": {
"coffeelint": "^1.10.1",
@ -332,4 +334,4 @@
"lint": "coffeelint src/ spec/",
"code-docs": "codo && open docs/code/index.html"
}
}
}

View File

@ -0,0 +1,18 @@
"use strict"
Beautifier = require('./beautifier')
module.exports = class AlignYaml extends Beautifier
name: "align-yaml"
link: "https://github.com/jonschlinkert/align-yaml"
options: {
YAML:
padding: true
}
beautify: (text, language, options) ->
return new @Promise((resolve, reject) ->
align = require('align-yaml')
result = align(text, options.padding)
resolve(result)
)

View File

@ -35,6 +35,7 @@ module.exports = class Beautifiers extends EventEmitter
###
beautifierNames : [
'uncrustify'
'align-yaml'
'autopep8'
'coffee-formatter'
'coffee-fmt'

View File

@ -76,6 +76,7 @@ module.exports = class Languages
"visualforce"
"xml"
"xtemplate"
"yaml"
]
###

33
src/languages/yaml.coffee Normal file
View File

@ -0,0 +1,33 @@
module.exports = {
name: "YAML"
namespace: "yaml"
fallback: []
scope: ['source.yaml']
###
Supported Grammars
###
grammars: [
"YAML"
]
###
Supported extensions
###
extensions: [
"yml",
"yaml"
]
defaultBeautifier: "align-yaml"
options: {
padding:
type: 'integer'
default: null
minimum: 0
description: "The amount of padding to add next to each line."
}
}