Revert "Revert "Organize settings/options into groups that will be collapsable""
This reverts commit d97b2d2e4d
.
This commit is contained in:
parent
7eab25e46f
commit
5c3d21cc70
|
@ -105,15 +105,21 @@ module.exports = class Beautifiers extends EventEmitter
|
||||||
langOptions = {}
|
langOptions = {}
|
||||||
languages = {} # Hash map of languages with their names
|
languages = {} # Hash map of languages with their names
|
||||||
for lang in @languages.languages
|
for lang in @languages.languages
|
||||||
langOptions[lang.name] ?= {}
|
# Use the namespace from language as key prefix
|
||||||
|
namespace = lang.namespace
|
||||||
|
langOptions[namespace] ?= {
|
||||||
|
title: lang.name,
|
||||||
|
type: 'object',
|
||||||
|
description: "Options for language #{lang.name}"
|
||||||
|
collapsed: true
|
||||||
|
properties: {}
|
||||||
|
}
|
||||||
languages[lang.name] ?= lang
|
languages[lang.name] ?= lang
|
||||||
options = langOptions[lang.name]
|
options = _.get(langOptions, "#{namespace}.properties")
|
||||||
|
|
||||||
|
|
||||||
# Init field for supported beautifiers
|
# Init field for supported beautifiers
|
||||||
lang.beautifiers = []
|
lang.beautifiers = []
|
||||||
|
|
||||||
|
|
||||||
# Process all language options
|
# Process all language options
|
||||||
for field, op of lang.options
|
for field, op of lang.options
|
||||||
if not op.title?
|
if not op.title?
|
||||||
|
@ -121,7 +127,6 @@ module.exports = class Beautifiers extends EventEmitter
|
||||||
.map(_plus.capitalize).join(' ')
|
.map(_plus.capitalize).join(' ')
|
||||||
op.title = "#{lang.name} - #{op.title}"
|
op.title = "#{lang.name} - #{op.title}"
|
||||||
|
|
||||||
|
|
||||||
# Init field for supported beautifiers
|
# Init field for supported beautifiers
|
||||||
op.beautifiers = []
|
op.beautifiers = []
|
||||||
|
|
||||||
|
@ -138,11 +143,10 @@ module.exports = class Beautifiers extends EventEmitter
|
||||||
for beautifier in beautifiers
|
for beautifier in beautifiers
|
||||||
beautifierName = beautifier.name
|
beautifierName = beautifier.name
|
||||||
|
|
||||||
|
|
||||||
# Iterate over supported languages
|
# Iterate over supported languages
|
||||||
for languageName, options of beautifier.options
|
for languageName, options of beautifier.options
|
||||||
laOp = langOptions[languageName]
|
namespace = languages[languageName].namespace
|
||||||
|
laOp = _.get(langOptions, "#{namespace}.properties")
|
||||||
|
|
||||||
# Is a valid Language name
|
# Is a valid Language name
|
||||||
if typeof options is "boolean"
|
if typeof options is "boolean"
|
||||||
|
@ -151,7 +155,6 @@ module.exports = class Beautifiers extends EventEmitter
|
||||||
# Add Beautifier support to Language
|
# Add Beautifier support to Language
|
||||||
languages[languageName]?.beautifiers.push(beautifierName)
|
languages[languageName]?.beautifiers.push(beautifierName)
|
||||||
|
|
||||||
|
|
||||||
# Check for beautifier's options support
|
# Check for beautifier's options support
|
||||||
if options is true
|
if options is true
|
||||||
|
|
||||||
|
@ -191,7 +194,6 @@ module.exports = class Beautifiers extends EventEmitter
|
||||||
# Complex Function
|
# Complex Function
|
||||||
[fields..., fn] = op
|
[fields..., fn] = op
|
||||||
|
|
||||||
|
|
||||||
# Add beautifier support to all required fields
|
# Add beautifier support to all required fields
|
||||||
languages[languageName]?.beautifiers.push(beautifierName)
|
languages[languageName]?.beautifiers.push(beautifierName)
|
||||||
for f in fields
|
for f in fields
|
||||||
|
@ -203,55 +205,13 @@ module.exports = class Beautifiers extends EventEmitter
|
||||||
# Unsupported
|
# Unsupported
|
||||||
logger.warn("Unsupported option:", beautifierName, languageName, field, op, langOptions)
|
logger.warn("Unsupported option:", beautifierName, languageName, field, op, langOptions)
|
||||||
|
|
||||||
# Prefix language's options with namespace
|
# Improve descriptions to each language option
|
||||||
for langName, ops of langOptions
|
for g,group of langOptions
|
||||||
|
for o,optionDef of group.properties
|
||||||
# Get language with name
|
|
||||||
lang = languages[langName]
|
|
||||||
|
|
||||||
|
|
||||||
# Use the namespace from language as key prefix
|
|
||||||
prefix = lang.namespace
|
|
||||||
|
|
||||||
|
|
||||||
# logger.verbose(langName, lang, prefix, ops)
|
|
||||||
# Iterate over all language options and rename fields
|
|
||||||
for field, op of ops
|
|
||||||
|
|
||||||
# Rename field
|
|
||||||
delete ops[field]
|
|
||||||
ops["#{prefix}_#{field}"] = op
|
|
||||||
|
|
||||||
# Flatten Options per language to array of all options
|
|
||||||
allOptions = _.values(langOptions)
|
|
||||||
|
|
||||||
|
|
||||||
# logger.verbose('allOptions', allOptions)
|
|
||||||
# Flatten array of objects to single object for options
|
|
||||||
flatOptions = _.reduce(allOptions, ((result, languageOptions, language) ->
|
|
||||||
|
|
||||||
# Iterate over fields (keys) in Language's Options
|
|
||||||
# and merge them into single result
|
|
||||||
# logger.verbose('language options', language, languageOptions, result)
|
|
||||||
return _.reduce(languageOptions, ((result, optionDef, optionName) ->
|
|
||||||
|
|
||||||
# TODO: Add supported beautifiers to option description
|
|
||||||
# logger.verbose('optionDef', optionDef, optionName)
|
|
||||||
if optionDef.beautifiers.length > 0
|
if optionDef.beautifiers.length > 0
|
||||||
|
|
||||||
# optionDef.title = "
|
|
||||||
optionDef.description = "#{optionDef.description} (Supported by #{optionDef.beautifiers.join(', ')})"
|
optionDef.description = "#{optionDef.description} (Supported by #{optionDef.beautifiers.join(', ')})"
|
||||||
else
|
else
|
||||||
|
|
||||||
# optionDef.title = "(DEPRECATED)
|
|
||||||
optionDef.description = "#{optionDef.description} (Not supported by any beautifiers)"
|
optionDef.description = "#{optionDef.description} (Not supported by any beautifiers)"
|
||||||
if result[optionName]?
|
|
||||||
logger.warn("Duplicate option detected: ", optionName, optionDef)
|
|
||||||
result[optionName] = optionDef
|
|
||||||
return result
|
|
||||||
), result)
|
|
||||||
), {})
|
|
||||||
|
|
||||||
|
|
||||||
# Generate Language configurations
|
# Generate Language configurations
|
||||||
# logger.verbose('languages', languages)
|
# logger.verbose('languages', languages)
|
||||||
|
@ -259,32 +219,33 @@ module.exports = class Beautifiers extends EventEmitter
|
||||||
|
|
||||||
# logger.verbose(langName, lang)
|
# logger.verbose(langName, lang)
|
||||||
name = lang.name
|
name = lang.name
|
||||||
|
namespace = lang.namespace
|
||||||
beautifiers = lang.beautifiers
|
beautifiers = lang.beautifiers
|
||||||
optionName = "language_#{lang.namespace}"
|
optionName = "language_#{namespace}"
|
||||||
|
|
||||||
# Add Language configurations
|
# Add Language configurations
|
||||||
flatOptions["#{optionName}_disabled"] = {
|
_.set(langOptions, "#{namespace}.disabled", {
|
||||||
title : "Language Config - #{name} - Disable Beautifying Language"
|
title : "Language Config - #{name} - Disable Beautifying Language"
|
||||||
type : 'boolean'
|
type : 'boolean'
|
||||||
default : false
|
default : false
|
||||||
description : "Disable #{name} Beautification"
|
description : "Disable #{name} Beautification"
|
||||||
}
|
})
|
||||||
flatOptions["#{optionName}_default_beautifier"] = {
|
_.set(langOptions, "#{namespace}.default_beautifier", {
|
||||||
title : "Language Config - #{name} - Default Beautifier"
|
title : "Language Config - #{name} - Default Beautifier"
|
||||||
type : 'string'
|
type : 'string'
|
||||||
default : lang.defaultBeautifier ? beautifiers[0]
|
default : lang.defaultBeautifier ? beautifiers[0]
|
||||||
description : "Default Beautifier to be used for #{name}"
|
description : "Default Beautifier to be used for #{name}"
|
||||||
enum : _.uniq(beautifiers)
|
enum : _.uniq(beautifiers)
|
||||||
}
|
})
|
||||||
flatOptions["#{optionName}_beautify_on_save"] = {
|
_.set(langOptions, "#{namespace}.beautify_on_save", {
|
||||||
title : "Language Config - #{name} - Beautify On Save"
|
title : "Language Config - #{name} - Beautify On Save"
|
||||||
type : 'boolean'
|
type : 'boolean'
|
||||||
default : false
|
default : false
|
||||||
description : "Automatically beautify #{name} files on save"
|
description : "Automatically beautify #{name} files on save"
|
||||||
}
|
})
|
||||||
|
|
||||||
# logger.verbose('flatOptions', flatOptions)
|
# logger.verbose('langOptions', langOptions)
|
||||||
return flatOptions
|
return langOptions
|
||||||
|
|
||||||
|
|
||||||
###
|
###
|
||||||
|
|
|
@ -1,37 +1,43 @@
|
||||||
module.exports = {
|
module.exports = {
|
||||||
analytics :
|
_general:
|
||||||
title: 'Anonymous Analytics'
|
title: 'General'
|
||||||
type : 'boolean'
|
type: 'object'
|
||||||
default : true
|
collapsed: true
|
||||||
description : "There is [Segment.io](https://segment.io/) which forwards data to [Google
|
description: 'General options for Atom Beautify'
|
||||||
Analytics](http://www.google.com/analytics/) to track what languages are being
|
properties:
|
||||||
used the most, as well as other stats. Everything is anonymized and no personal
|
analytics :
|
||||||
information, such as source code, is sent.
|
title: 'Anonymous Analytics'
|
||||||
See https://github.com/Glavin001/atom-beautify/issues/47 for more details."
|
type : 'boolean'
|
||||||
_analyticsUserId :
|
default : true
|
||||||
title: 'Analytics User Id'
|
description : "There is [Segment.io](https://segment.io/) which forwards data to [Google
|
||||||
type : 'string'
|
Analytics](http://www.google.com/analytics/) to track what languages are being
|
||||||
default : ""
|
used the most, as well as other stats. Everything is anonymized and no personal
|
||||||
description : "Unique identifier for this user for tracking usage analytics"
|
information, such as source code, is sent.
|
||||||
_loggerLevel :
|
See https://github.com/Glavin001/atom-beautify/issues/47 for more details."
|
||||||
title: "Logger Level"
|
_analyticsUserId :
|
||||||
type : 'string'
|
title: 'Analytics User Id'
|
||||||
default : 'warn'
|
type : 'string'
|
||||||
description : 'Set the level for the logger'
|
default : ""
|
||||||
enum : ['verbose', 'debug', 'info', 'warn', 'error']
|
description : "Unique identifier for this user for tracking usage analytics"
|
||||||
beautifyEntireFileOnSave :
|
_loggerLevel :
|
||||||
title: "Beautify Entire File On Save"
|
title: "Logger Level"
|
||||||
type : 'boolean'
|
type : 'string'
|
||||||
default : true
|
default : 'warn'
|
||||||
description : "When beautifying on save, use the entire file, even if there is selected text in the editor"
|
description : 'Set the level for the logger'
|
||||||
muteUnsupportedLanguageErrors :
|
enum : ['verbose', 'debug', 'info', 'warn', 'error']
|
||||||
title: "Mute Unsupported Language Errors"
|
beautifyEntireFileOnSave :
|
||||||
type : 'boolean'
|
title: "Beautify Entire File On Save"
|
||||||
default : false
|
type : 'boolean'
|
||||||
description : "Do not show \"Unsupported Language\" errors when they occur"
|
default : true
|
||||||
muteAllErrors :
|
description : "When beautifying on save, use the entire file, even if there is selected text in the editor"
|
||||||
title: "Mute All Errors"
|
muteUnsupportedLanguageErrors :
|
||||||
type : 'boolean'
|
title: "Mute Unsupported Language Errors"
|
||||||
default : false
|
type : 'boolean'
|
||||||
description : "Do not show any/all errors when they occur"
|
default : false
|
||||||
}
|
description : "Do not show \"Unsupported Language\" errors when they occur"
|
||||||
|
muteAllErrors :
|
||||||
|
title: "Mute All Errors"
|
||||||
|
type : 'boolean'
|
||||||
|
default : false
|
||||||
|
description : "Do not show any/all errors when they occur"
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue