See #1980. Improve VHDL beautifier based on PR review

This commit is contained in:
Glavin Wiechert 2018-03-01 21:10:48 -04:00
parent 9a761f7957
commit c8e5baf53f
5 changed files with 36 additions and 108 deletions

View File

@ -137,6 +137,7 @@ Some of the supported beautifiers are developed for Node.js and are automaticall
| Tidy Markdown | :white_check_mark: | :ok_hand: Not necessary | :smiley: Nothing! | | Tidy Markdown | :white_check_mark: | :ok_hand: Not necessary | :smiley: Nothing! |
| TypeScript Formatter | :white_check_mark: | :ok_hand: Not necessary | :smiley: Nothing! | | TypeScript Formatter | :white_check_mark: | :ok_hand: Not necessary | :smiley: Nothing! |
| Uncrustify | :warning: 1 executable | :white_check_mark: :100:% of executables | :whale: With [Docker](https://www.docker.com/):<br/>1. Install [Uncrustify (`uncrustify`)](http://uncrustify.sourceforge.net/) with `docker pull unibeautify/uncrustify`<br/><br/>:bookmark_tabs: Manually:<br/>1. Install [Uncrustify (`uncrustify`)](http://uncrustify.sourceforge.net/) by following https://github.com/uncrustify/uncrustify<br/> | | Uncrustify | :warning: 1 executable | :white_check_mark: :100:% of executables | :whale: With [Docker](https://www.docker.com/):<br/>1. Install [Uncrustify (`uncrustify`)](http://uncrustify.sourceforge.net/) with `docker pull unibeautify/uncrustify`<br/><br/>:bookmark_tabs: Manually:<br/>1. Install [Uncrustify (`uncrustify`)](http://uncrustify.sourceforge.net/) by following https://github.com/uncrustify/uncrustify<br/> |
| VHDL Beautifier | :warning: 1 executable | :x: No Docker support | :bookmark_tabs: Manually:<br/>1. Install [Emacs (`emacs`)](https://www.gnu.org/software/emacs/) by following https://www.gnu.org/software/emacs/<br/> |
| Vue Beautifier | :white_check_mark: | :ok_hand: Not necessary | :smiley: Nothing! | | Vue Beautifier | :white_check_mark: | :ok_hand: Not necessary | :smiley: Nothing! |
| yapf | :warning: Manual installation | :construction: Not an executable | :page_facing_up: Go to https://github.com/google/yapf and follow the instructions. | | yapf | :warning: Manual installation | :construction: Not an executable | :page_facing_up: Go to https://github.com/google/yapf and follow the instructions. |
@ -209,6 +210,7 @@ See [all supported options in the documentation at `docs/options.md`](docs/opti
| UX Markup | `UX` |`.ux` | **[`Pretty Diff`](https://github.com/prettydiff/prettydiff)** | | UX Markup | `UX` |`.ux` | **[`Pretty Diff`](https://github.com/prettydiff/prettydiff)** |
| Vala | `Vala` |`.vala`, `.vapi` | **[`Uncrustify`](https://github.com/uncrustify/uncrustify)** | | Vala | `Vala` |`.vala`, `.vapi` | **[`Uncrustify`](https://github.com/uncrustify/uncrustify)** |
| Verilog | `Verilog` |`.svh`, `.v`, `.sv` | **[`Emacs Verilog Mode`](https://www.veripool.org/projects/verilog-mode/)** | | Verilog | `Verilog` |`.svh`, `.v`, `.sv` | **[`Emacs Verilog Mode`](https://www.veripool.org/projects/verilog-mode/)** |
| VHDL | `VHDL 2008` |`.vhd`, `.VHD` | **[`VHDL Beautifier`](https://www.gnu.org/software/emacs/)** |
| Visualforce | `Visualforce` |`.page` | **[`Pretty Diff`](https://github.com/prettydiff/prettydiff)** | | Visualforce | `Visualforce` |`.page` | **[`Pretty Diff`](https://github.com/prettydiff/prettydiff)** |
| Vue | `Vue Component` |`.vue` | **[`Vue Beautifier`](https://github.com/Glavin001/atom-beautify/blob/master/src/beautifiers/vue-beautifier.coffee)**, [`Prettier`](https://github.com/prettier/prettier) | | Vue | `Vue Component` |`.vue` | **[`Vue Beautifier`](https://github.com/Glavin001/atom-beautify/blob/master/src/beautifiers/vue-beautifier.coffee)**, [`Prettier`](https://github.com/prettier/prettier) |
| XML | `SLD`, `XML`, `XHTML`, `XSD`, `XSL`, `JSP`, `GSP` |`.sld`, `.xml`, `.xhtml`, `.xsd`, `.xsl`, `.jsp`, `.gsp`, `.plist`, `.recipe`, `.config` | **[`Pretty Diff`](https://github.com/prettydiff/prettydiff)**, [`JS Beautify`](https://github.com/beautify-web/js-beautify) | | XML | `SLD`, `XML`, `XHTML`, `XSD`, `XSL`, `JSP`, `GSP` |`.sld`, `.xml`, `.xhtml`, `.xsd`, `.xsl`, `.jsp`, `.gsp`, `.plist`, `.recipe`, `.config` | **[`Pretty Diff`](https://github.com/prettydiff/prettydiff)**, [`JS Beautify`](https://github.com/beautify-web/js-beautify) |

View File

@ -13219,21 +13219,20 @@ Path to emacs init.el script with formatting settings. (Leave blank to use defau
} }
``` ```
#### [Vhdl](#vhdl) #### [VHDL](#vhdl)
**Supported Beautifiers**: [`Vhdl Beautifier`](#vhdl-beautifier) **Supported Beautifiers**: [`VHDL Beautifier`](#vhdl-beautifier)
| Option | Vhdl Beautifier | | Option | VHDL Beautifier |
| --- | --- | | --- | --- |
| `disabled` | :white_check_mark: | | `disabled` | :white_check_mark: |
| `default_beautifier` | :white_check_mark: | | `default_beautifier` | :white_check_mark: |
| `beautify_on_save` | :white_check_mark: | | `beautify_on_save` | :white_check_mark: |
| `emacs_path` | :white_check_mark: |
| `emacs_script_path` | :white_check_mark: | | `emacs_script_path` | :white_check_mark: |
**Description**: **Description**:
Options for language Vhdl Options for language VHDL
##### [Disable Beautifying Language](#disable-beautifying-language) ##### [Disable Beautifying Language](#disable-beautifying-language)
@ -13243,7 +13242,7 @@ Options for language Vhdl
**Description**: **Description**:
Disable Vhdl Beautification Disable VHDL Beautification
**How to Configure** **How to Configure**
@ -13256,15 +13255,15 @@ Disable Vhdl Beautification
**Important**: This option is only configurable from within Atom Beautify's setting panel. **Important**: This option is only configurable from within Atom Beautify's setting panel.
**Default**: `Vhdl Beautifier` **Default**: `VHDL Beautifier`
**Type**: `string` **Type**: `string`
**Enum**: `Vhdl Beautifier` **Enum**: `VHDL Beautifier`
**Description**: **Description**:
Default Beautifier to be used for Vhdl Default Beautifier to be used for VHDL
**How to Configure** **How to Configure**
@ -13281,7 +13280,7 @@ Default Beautifier to be used for Vhdl
**Description**: **Description**:
Automatically beautify Vhdl files on save Automatically beautify VHDL files on save
**How to Configure** **How to Configure**
@ -13290,30 +13289,6 @@ Automatically beautify Vhdl files on save
2. Go into *Packages* and search for "*Atom Beautify*" package. 2. Go into *Packages* and search for "*Atom Beautify*" package.
3. Find the option "*Beautify On Save*" and change it to your desired configuration. 3. Find the option "*Beautify On Save*" and change it to your desired configuration.
##### [Emacs path](#emacs-path)
**Namespace**: `vhdl`
**Key**: `emacs_path`
**Type**: `string`
**Supported Beautifiers**: [`Vhdl Beautifier`](#vhdl-beautifier)
**Description**:
Path to the `emacs` executable (Supported by Vhdl Beautifier)
**Example `.jsbeautifyrc` Configuration**
```json
{
"vhdl": {
"emacs_path": ""
}
}
```
##### [Emacs script path](#emacs-script-path) ##### [Emacs script path](#emacs-script-path)
**Namespace**: `vhdl` **Namespace**: `vhdl`
@ -13322,11 +13297,11 @@ Path to the `emacs` executable (Supported by Vhdl Beautifier)
**Type**: `string` **Type**: `string`
**Supported Beautifiers**: [`Vhdl Beautifier`](#vhdl-beautifier) **Supported Beautifiers**: [`VHDL Beautifier`](#vhdl-beautifier)
**Description**: **Description**:
Path to the emacs script (Supported by Vhdl Beautifier) Path to the emacs script (Supported by VHDL Beautifier)
**Example `.jsbeautifyrc` Configuration** **Example `.jsbeautifyrc` Configuration**
@ -18045,31 +18020,7 @@ Path to uncrustify config file. i.e. uncrustify.cfg (Supported by Uncrustify)
``` ```
### Vhdl Beautifier ### VHDL Beautifier
##### [Emacs path](#emacs-path)
**Namespace**: `vhdl`
**Key**: `emacs_path`
**Type**: `string`
**Supported Beautifiers**: [`Vhdl Beautifier`](#vhdl-beautifier)
**Description**:
Path to the `emacs` executable (Supported by Vhdl Beautifier)
**Example `.jsbeautifyrc` Configuration**
```json
{
"vhdl": {
"emacs_path": ""
}
}
```
##### [Emacs script path](#emacs-script-path) ##### [Emacs script path](#emacs-script-path)
@ -18079,11 +18030,11 @@ Path to the `emacs` executable (Supported by Vhdl Beautifier)
**Type**: `string` **Type**: `string`
**Supported Beautifiers**: [`Vhdl Beautifier`](#vhdl-beautifier) **Supported Beautifiers**: [`VHDL Beautifier`](#vhdl-beautifier)
**Description**: **Description**:
Path to the emacs script (Supported by Vhdl Beautifier) Path to the emacs script (Supported by VHDL Beautifier)
**Example `.jsbeautifyrc` Configuration** **Example `.jsbeautifyrc` Configuration**

View File

@ -7,7 +7,7 @@ Beautifier = require('../beautifier')
path = require("path") path = require("path")
module.exports = class VhdlBeautifier extends Beautifier module.exports = class VhdlBeautifier extends Beautifier
name: "Vhdl Beautifier" name: "VHDL Beautifier"
link: "https://www.gnu.org/software/emacs/" link: "https://www.gnu.org/software/emacs/"
executables: [ executables: [
{ {
@ -22,14 +22,15 @@ module.exports = class VhdlBeautifier extends Beautifier
] ]
options: { options: {
Vhdl: true VHDL: {
emacs_script_path: true
}
} }
beautify: (text, language, options) -> beautify: (text, language, options) ->
@debug('vhdl-beautifier', options) @debug('vhdl-beautifier', options)
emacs = @exe("emacs") emacs = @exe("emacs")
emacs_path = options.emacs_path
emacs_script_path = options.emacs_script_path emacs_script_path = options.emacs_script_path
if not emacs_script_path if not emacs_script_path
@ -46,14 +47,7 @@ module.exports = class VhdlBeautifier extends Beautifier
tempFile = @tempFile("temp", text) tempFile = @tempFile("temp", text)
] ]
if emacs_path emacs.run(args, {ignoreReturnCode: false})
@deprecateOptionForExecutable("Emacs", "emacs_path", "Path") .then(=>
@run(emacs_path, args, {ignoreReturnCode: false}) @readFile(tempFile)
.then(=> )
@readFile(tempFile)
)
else
emacs.run(args, {ignoreReturnCode: false})
.then(=>
@readFile(tempFile)
)

View File

@ -1,6 +1,6 @@
module.exports = { module.exports = {
name: "Vhdl" name: "VHDL"
namespace: "vhdl" namespace: "vhdl"
### ###
@ -22,11 +22,6 @@ module.exports = {
### ###
options: options:
# JavaScript
emacs_path:
type: 'string'
default: ""
description: "Path to the `emacs` executable"
emacs_script_path: emacs_script_path:
type: 'string' type: 'string'
default: "" default: ""

View File

@ -8193,12 +8193,12 @@
} }
}, },
"vhdl": { "vhdl": {
"title": "Vhdl", "title": "VHDL",
"type": "object", "type": "object",
"description": "Options for language Vhdl", "description": "Options for language VHDL",
"collapsed": true, "collapsed": true,
"beautifiers": [ "beautifiers": [
"Vhdl Beautifier" "VHDL Beautifier"
], ],
"grammars": [ "grammars": [
"VHDL 2008" "VHDL 2008"
@ -8208,31 +8208,17 @@
"VHD" "VHD"
], ],
"properties": { "properties": {
"emacs_path": {
"type": "string",
"default": "",
"description": "Path to the `emacs` executable (Supported by Vhdl Beautifier)",
"title": "Emacs path",
"beautifiers": [
"Vhdl Beautifier"
],
"key": "emacs_path",
"language": {
"name": "Vhdl",
"namespace": "vhdl"
}
},
"emacs_script_path": { "emacs_script_path": {
"type": "string", "type": "string",
"default": "", "default": "",
"description": "Path to the emacs script (Supported by Vhdl Beautifier)", "description": "Path to the emacs script (Supported by VHDL Beautifier)",
"title": "Emacs script path", "title": "Emacs script path",
"beautifiers": [ "beautifiers": [
"Vhdl Beautifier" "VHDL Beautifier"
], ],
"key": "emacs_script_path", "key": "emacs_script_path",
"language": { "language": {
"name": "Vhdl", "name": "VHDL",
"namespace": "vhdl" "namespace": "vhdl"
} }
}, },
@ -8241,16 +8227,16 @@
"order": -3, "order": -3,
"type": "boolean", "type": "boolean",
"default": false, "default": false,
"description": "Disable Vhdl Beautification" "description": "Disable VHDL Beautification"
}, },
"default_beautifier": { "default_beautifier": {
"title": "Default Beautifier", "title": "Default Beautifier",
"order": -2, "order": -2,
"type": "string", "type": "string",
"default": "Vhdl Beautifier", "default": "VHDL Beautifier",
"description": "Default Beautifier to be used for Vhdl", "description": "Default Beautifier to be used for VHDL",
"enum": [ "enum": [
"Vhdl Beautifier" "VHDL Beautifier"
] ]
}, },
"beautify_on_save": { "beautify_on_save": {
@ -8258,7 +8244,7 @@
"order": -1, "order": -1,
"type": "boolean", "type": "boolean",
"default": false, "default": false,
"description": "Automatically beautify Vhdl files on save" "description": "Automatically beautify VHDL files on save"
} }
} }
}, },