Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Jan-Cornelius Molnar 2015-06-01 23:19:03 +02:00
commit 9024f2b2f7
16 changed files with 2018 additions and 218 deletions

View File

@ -86,35 +86,6 @@ For example:
'ctrl-alt-b': 'atom-beautify:beautify-editor'
```
### Package Options
Each language and its beautifier's options are fully documented in the Atom
Beautify package settings panel. There are far too many to document them all
here. Here are a few key options that you may use:
- `beautifyOnSave` (Default *false*)
You can also choose to beautify on every file save.
- `beautifyEntireFileOnSave` (Default *true*)
Beautification will normally only beautify your selected text.
However, when beautification occurs on save then it will
be forced to beautify the entire file's contents,
not just selected text.
- `muteUnsupportedLanguageErrors` (Default *false*)
Mute only *unsupported language* errors.
- `muteAllErrors` (Default *false*)
Do not show the *Atom Beautify Error Messages* panel
for any of the errors occurring while beautifying.
- `analytics` (Default *true*)
There is [Segment.io](https://segment.io/) which forwards data to [Google
Analytics](http://www.google.com/analytics/) to track what languages are being
used the most, as well as other stats. Everything is anonymized and no personal
information, such as source code, is sent.
See https://github.com/Glavin001/atom-beautify/issues/47 for more details.
## Configuration
Edit your `.jsbeautifyrc` file in any of the following locations:
@ -130,7 +101,7 @@ Edit your `.jsbeautifyrc` file in any of the following locations:
See examples of both ways inside [`examples/`](https://github.com/donaldpipowitch/atom-beautify/tree/master/examples)
An option table is available at the [js-beautify repo](https://github.com/beautify-web/js-beautify#options).
See [all supported options in the documentation at `docs/options.md`](https://github.com/Glavin001/atom-beautify/blob/master/docs/options.md).
### Simple

3
docs/README.md Normal file
View File

@ -0,0 +1,3 @@
# Atom Beautify Documentation
See [options.md](options.md) for supported beautification options.

32
docs/index.coffee Executable file
View File

@ -0,0 +1,32 @@
#!/usr/bin/env coffee
# Dependencies
Handlebars = require('handlebars')
Beautifiers = require("../src/beautifiers")
fs = require('fs')
console.log('Generating options...')
beautifier = new Beautifiers()
languageOptions = beautifier.options
packageOptions = require('../src/config.coffee')
console.log('Loading options template...')
optionsTemplatePath = __dirname + '/options-template.md'
optionTemplatePath = __dirname + '/option-template.md'
optionsPath = __dirname + '/options.md'
optionsTemplate = fs.readFileSync(optionsTemplatePath).toString()
optionTemplate = fs.readFileSync(optionTemplatePath).toString()
console.log('Building documentation from template and options...')
Handlebars.registerPartial('option', optionTemplate)
template = Handlebars.compile(optionsTemplate)
context = {
packageOptions: packageOptions
languageOptions: languageOptions
}
result = template(context)
console.log('Writing documentation to file...')
fs.writeFileSync(optionsPath, result)
console.log('Done.')

17
docs/option-template.md Normal file
View File

@ -0,0 +1,17 @@
### {{#if title}} {{title}} {{else}} `{{@key}}` {{/if}}
**Key**: `{{@key}}`
{{#if default}}
**Default**: `{{default}}`
{{/if}}
**Type**: `{{type}}`
{{#if enum}}
**Enum**: {{#each enum}} `{{this}}` {{/each}}
{{/if}}
**Description**:
{{description}}

23
docs/options-template.md Normal file
View File

@ -0,0 +1,23 @@
# Options
Automatically generated documentation for Atom Beautify's options.
## Package Options
Configurable options for Atom Beautify.
---
{{#each packageOptions}}
{{> option}}
{{/each}}
## Language Options
Supported options for each language.
---
{{#each languageOptions}}
{{> option}}
{{/each}}

1732
docs/options.md Normal file

File diff suppressed because it is too large Load Diff

View File

@ -17,37 +17,29 @@
"email": "glavin.wiechert@gmail.com",
"url": "https://github.com/Glavin001"
},
"contributors": [
{
"contributors": [{
"name": "Donald Pipowitch",
"email": "pipo@senaeh.de",
"url": "https://github.com/donaldpipowitch"
},
{
}, {
"name": "László Károlyi",
"url": "https://github.com/karolyi"
},
{
}, {
"name": "Marco Tanzi",
"url": "https://github.com/mtanzi"
},
{
}, {
"name": "gvn lazar suntop",
"url": "https://github.com/gvn"
},
{
}, {
"name": "Vadim K.",
"url": "https://github.com/vadirn"
},
{
}, {
"name": "Filipe Silva",
"url": "https://github.com/filipesilva"
},
{
}, {
"name": "Ramón Cahenzli",
"url": "https://github.com/psy-q"
}
],
}],
"engines": {
"atom": ">=0.174.0 <2.0.0"
},
@ -139,5 +131,43 @@
"marko",
"go",
"golang"
]
],
"dependencies": {
"analytics-node": "^1.2.2",
"async": "^1.0.0",
"atom-message-panel": "^1.2.4",
"atom-space-pen-views": "^2.0.5",
"bluebird": "^2.9.26",
"coffee-fmt": "0.10.2",
"coffee-formatter": "^0.1.2",
"csscomb": "^3.1.5",
"diff": "^1.4.0",
"editorconfig": "^0.12.2",
"emissary": "^1.3.3",
"event-kit": "^1.2.0",
"expand-home-dir": "0.0.2",
"extend": "^2.0.1",
"js-beautify": "^1.5.6",
"lodash": "3.9.3",
"loophole": "^1.0.0",
"node-dir": "^0.1.8",
"node-uuid": "^1.4.3",
"prettydiff": "^1.11.21",
"space-pen": "^5.1.1",
"strip-json-comments": "^1.0.2",
"temp": "^0.8.1",
"tidy-markdown": "^0.3.2",
"typescript-formatter": "~0.3.2",
"underscore-plus": "^1.6.6",
"winston": "^1.0.0",
"yaml-front-matter": "^3.2.3"
},
"devDependencies": {
"coffee-script": "^1.9.3",
"handlebars": "^3.0.3"
},
"scripts": {
"prepublish": "npm run docs",
"docs": "coffee docs/"
}
}

View File

@ -426,38 +426,7 @@ handleSaveEvent = =>
plugin.subscribe disposable
{Subscriber} = require path.join(atom.packages.resourcePath, 'node_modules', 'emissary')
Subscriber.extend plugin
plugin.config = _.merge(
analytics :
type : 'boolean'
default : true
description : "Automatically send usage information (NEVER CODE) to Google Analytics"
_analyticsUserId :
type : 'string'
default : ""
description : "Unique identifier for this user for tracking usage analytics"
_loggerLevel :
type : 'string'
default : 'warn'
description : 'Set the level for the logger'
enum : ['verbose', 'debug', 'info', 'warn', 'error']
beautifyOnSave :
title : "DEPRECATED: Beautfy On Save"
type : 'boolean'
default : false
description : "Beautify active editor on save"
beautifyEntireFileOnSave :
type : 'boolean'
default : true
description : "When beautifying on save, use the entire file, even if there is selected text in the editor"
muteUnsupportedLanguageErrors :
type : 'boolean'
default : false
description : "Do not show \"Unsupported Language\" errors when they occur"
muteAllErrors :
type : 'boolean'
default : false
description : "Do not show any/all errors when they occur"
, defaultLanguageOptions)
plugin.config = _.merge(require('./config.coffee'), defaultLanguageOptions)
plugin.activate = ->
handleSaveEvent()
plugin.subscribe atom.config.observe("atom-beautify.beautifyOnSave", handleSaveEvent)

31
src/config.coffee Normal file
View File

@ -0,0 +1,31 @@
module.exports = {
analytics :
type : 'boolean'
default : true
description : "There is [Segment.io](https://segment.io/) which forwards data to [Google
Analytics](http://www.google.com/analytics/) to track what languages are being
used the most, as well as other stats. Everything is anonymized and no personal
information, such as source code, is sent.
See https://github.com/Glavin001/atom-beautify/issues/47 for more details."
_analyticsUserId :
type : 'string'
default : ""
description : "Unique identifier for this user for tracking usage analytics"
_loggerLevel :
type : 'string'
default : 'warn'
description : 'Set the level for the logger'
enum : ['verbose', 'debug', 'info', 'warn', 'error']
beautifyEntireFileOnSave :
type : 'boolean'
default : true
description : "When beautifying on save, use the entire file, even if there is selected text in the editor"
muteUnsupportedLanguageErrors :
type : 'boolean'
default : false
description : "Do not show \"Unsupported Language\" errors when they occur"
muteAllErrors :
type : 'boolean'
default : false
description : "Do not show any/all errors when they occur"
}

View File

@ -1,6 +1,6 @@
# Get Atom defaults
tabLength = atom.config.get('editor.tabLength')
softTabs = atom.config.get('editor.softTabs')
tabLength = atom?.config.get('editor.tabLength') ? 4
softTabs = atom?.config.get('editor.softTabs') ? true
defaultIndentSize = (if softTabs then tabLength else 1)
defaultIndentChar = (if softTabs then " " else "\t")
defaultIndentWithTabs = not softTabs

View File

@ -1,6 +1,6 @@
# Get Atom defaults
tabLength = atom.config.get('editor.tabLength')
softTabs = atom.config.get('editor.softTabs')
tabLength = atom?.config.get('editor.tabLength') ? 4
softTabs = atom?.config.get('editor.softTabs') ? true
defaultIndentSize = (if softTabs then tabLength else 1)
defaultIndentChar = (if softTabs then " " else "\t")
defaultIndentWithTabs = not softTabs

View File

@ -6,13 +6,6 @@ Language Support and default options.
_ = require('lodash')
extend = null
# Get Atom defaults
tabLength = atom.config.get('editor.tabLength')
softTabs = atom.config.get('editor.softTabs')
defaultIndentSize = (if softTabs then tabLength else 1)
defaultIndentChar = (if softTabs then " " else "\t")
defaultIndentWithTabs = not softTabs
#
module.exports = class Languages

View File

@ -1,6 +1,6 @@
# Get Atom defaults
tabLength = atom.config.get('editor.tabLength')
softTabs = atom.config.get('editor.softTabs')
tabLength = atom?.config.get('editor.tabLength') ? 4
softTabs = atom?.config.get('editor.softTabs') ? true
defaultIndentSize = (if softTabs then tabLength else 1)
defaultIndentChar = (if softTabs then " " else "\t")
defaultIndentWithTabs = not softTabs

View File

@ -1,6 +1,6 @@
# Get Atom defaults
tabLength = atom.config.get('editor.tabLength')
softTabs = atom.config.get('editor.softTabs')
tabLength = atom?.config.get('editor.tabLength') ? 4
softTabs = atom?.config.get('editor.softTabs') ? true
defaultIndentSize = (if softTabs then tabLength else 1)
defaultIndentChar = (if softTabs then " " else "\t")
defaultIndentWithTabs = not softTabs

View File

@ -1,6 +1,6 @@
# Get Atom defaults
tabLength = atom.config.get('editor.tabLength')
softTabs = atom.config.get('editor.softTabs')
tabLength = atom?.config.get('editor.tabLength') ? 4
softTabs = atom?.config.get('editor.softTabs') ? true
defaultIndentSize = (if softTabs then tabLength else 1)
defaultIndentChar = (if softTabs then " " else "\t")
defaultIndentWithTabs = not softTabs

View File

@ -9,13 +9,12 @@ module.exports = do ->
# See http://stackoverflow.com/a/21583831/2578205
winston = require('winston')
stream = require('stream')
writable = new stream.Writable({
write: (chunk, encoding, next) ->
writable = new stream.Writable()
writable._write = (chunk, encoding, next) ->
msg = chunk.toString()
# console.log(msg)
emitter.emit('logging', msg)
next()
})
levels = {
silly: 0,
@ -48,7 +47,7 @@ module.exports = do ->
]
})
wlogger.on('logging', (transport, level, msg, meta)->
loggerLevel = atom.config.get('atom-beautify._loggerLevel')
loggerLevel = atom?.config.get('atom-beautify._loggerLevel') ? "warn"
# console.log('logging', loggerLevel, arguments)
loggerLevelNum = levels[loggerLevel]
levelNum = levels[level]