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 = {}
|
||||
languages = {} # Hash map of languages with their names
|
||||
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
|
||||
options = langOptions[lang.name]
|
||||
|
||||
options = _.get(langOptions, "#{namespace}.properties")
|
||||
|
||||
# Init field for supported beautifiers
|
||||
lang.beautifiers = []
|
||||
|
||||
|
||||
# Process all language options
|
||||
for field, op of lang.options
|
||||
if not op.title?
|
||||
|
@ -121,7 +127,6 @@ module.exports = class Beautifiers extends EventEmitter
|
|||
.map(_plus.capitalize).join(' ')
|
||||
op.title = "#{lang.name} - #{op.title}"
|
||||
|
||||
|
||||
# Init field for supported beautifiers
|
||||
op.beautifiers = []
|
||||
|
||||
|
@ -138,11 +143,10 @@ module.exports = class Beautifiers extends EventEmitter
|
|||
for beautifier in beautifiers
|
||||
beautifierName = beautifier.name
|
||||
|
||||
|
||||
# Iterate over supported languages
|
||||
for languageName, options of beautifier.options
|
||||
laOp = langOptions[languageName]
|
||||
|
||||
namespace = languages[languageName].namespace
|
||||
laOp = _.get(langOptions, "#{namespace}.properties")
|
||||
|
||||
# Is a valid Language name
|
||||
if typeof options is "boolean"
|
||||
|
@ -151,7 +155,6 @@ module.exports = class Beautifiers extends EventEmitter
|
|||
# Add Beautifier support to Language
|
||||
languages[languageName]?.beautifiers.push(beautifierName)
|
||||
|
||||
|
||||
# Check for beautifier's options support
|
||||
if options is true
|
||||
|
||||
|
@ -191,7 +194,6 @@ module.exports = class Beautifiers extends EventEmitter
|
|||
# Complex Function
|
||||
[fields..., fn] = op
|
||||
|
||||
|
||||
# Add beautifier support to all required fields
|
||||
languages[languageName]?.beautifiers.push(beautifierName)
|
||||
for f in fields
|
||||
|
@ -203,55 +205,13 @@ module.exports = class Beautifiers extends EventEmitter
|
|||
# Unsupported
|
||||
logger.warn("Unsupported option:", beautifierName, languageName, field, op, langOptions)
|
||||
|
||||
# Prefix language's options with namespace
|
||||
for langName, ops of langOptions
|
||||
|
||||
# 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)
|
||||
# Improve descriptions to each language option
|
||||
for g,group of langOptions
|
||||
for o,optionDef of group.properties
|
||||
if optionDef.beautifiers.length > 0
|
||||
|
||||
# optionDef.title = "
|
||||
optionDef.description = "#{optionDef.description} (Supported by #{optionDef.beautifiers.join(', ')})"
|
||||
else
|
||||
|
||||
# optionDef.title = "(DEPRECATED)
|
||||
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
|
||||
# logger.verbose('languages', languages)
|
||||
|
@ -259,32 +219,33 @@ module.exports = class Beautifiers extends EventEmitter
|
|||
|
||||
# logger.verbose(langName, lang)
|
||||
name = lang.name
|
||||
namespace = lang.namespace
|
||||
beautifiers = lang.beautifiers
|
||||
optionName = "language_#{lang.namespace}"
|
||||
optionName = "language_#{namespace}"
|
||||
|
||||
# Add Language configurations
|
||||
flatOptions["#{optionName}_disabled"] = {
|
||||
_.set(langOptions, "#{namespace}.disabled", {
|
||||
title : "Language Config - #{name} - Disable Beautifying Language"
|
||||
type : 'boolean'
|
||||
default : false
|
||||
description : "Disable #{name} Beautification"
|
||||
}
|
||||
flatOptions["#{optionName}_default_beautifier"] = {
|
||||
})
|
||||
_.set(langOptions, "#{namespace}.default_beautifier", {
|
||||
title : "Language Config - #{name} - Default Beautifier"
|
||||
type : 'string'
|
||||
default : lang.defaultBeautifier ? beautifiers[0]
|
||||
description : "Default Beautifier to be used for #{name}"
|
||||
enum : _.uniq(beautifiers)
|
||||
}
|
||||
flatOptions["#{optionName}_beautify_on_save"] = {
|
||||
})
|
||||
_.set(langOptions, "#{namespace}.beautify_on_save", {
|
||||
title : "Language Config - #{name} - Beautify On Save"
|
||||
type : 'boolean'
|
||||
default : false
|
||||
description : "Automatically beautify #{name} files on save"
|
||||
}
|
||||
})
|
||||
|
||||
# logger.verbose('flatOptions', flatOptions)
|
||||
return flatOptions
|
||||
# logger.verbose('langOptions', langOptions)
|
||||
return langOptions
|
||||
|
||||
|
||||
###
|
||||
|
|
|
@ -1,37 +1,43 @@
|
|||
module.exports = {
|
||||
analytics :
|
||||
title: 'Anonymous 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 :
|
||||
title: 'Analytics User Id'
|
||||
type : 'string'
|
||||
default : ""
|
||||
description : "Unique identifier for this user for tracking usage analytics"
|
||||
_loggerLevel :
|
||||
title: "Logger Level"
|
||||
type : 'string'
|
||||
default : 'warn'
|
||||
description : 'Set the level for the logger'
|
||||
enum : ['verbose', 'debug', 'info', 'warn', 'error']
|
||||
beautifyEntireFileOnSave :
|
||||
title: "Beautify Entire File On Save"
|
||||
type : 'boolean'
|
||||
default : true
|
||||
description : "When beautifying on save, use the entire file, even if there is selected text in the editor"
|
||||
muteUnsupportedLanguageErrors :
|
||||
title: "Mute Unsupported Language Errors"
|
||||
type : 'boolean'
|
||||
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"
|
||||
}
|
||||
_general:
|
||||
title: 'General'
|
||||
type: 'object'
|
||||
collapsed: true
|
||||
description: 'General options for Atom Beautify'
|
||||
properties:
|
||||
analytics :
|
||||
title: 'Anonymous 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 :
|
||||
title: 'Analytics User Id'
|
||||
type : 'string'
|
||||
default : ""
|
||||
description : "Unique identifier for this user for tracking usage analytics"
|
||||
_loggerLevel :
|
||||
title: "Logger Level"
|
||||
type : 'string'
|
||||
default : 'warn'
|
||||
description : 'Set the level for the logger'
|
||||
enum : ['verbose', 'debug', 'info', 'warn', 'error']
|
||||
beautifyEntireFileOnSave :
|
||||
title: "Beautify Entire File On Save"
|
||||
type : 'boolean'
|
||||
default : true
|
||||
description : "When beautifying on save, use the entire file, even if there is selected text in the editor"
|
||||
muteUnsupportedLanguageErrors :
|
||||
title: "Mute Unsupported Language Errors"
|
||||
type : 'boolean'
|
||||
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