Revert "Organize settings/options into groups that will be collapsable"

This reverts commit f2968b797f.
This commit is contained in:
Glavin Wiechert 2016-02-25 23:20:36 -04:00
parent 33b5410321
commit d97b2d2e4d
2 changed files with 101 additions and 67 deletions

View File

@ -105,21 +105,15 @@ module.exports = class Beautifiers extends EventEmitter
langOptions = {}
languages = {} # Hash map of languages with their names
for lang in @languages.languages
# 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: {}
}
langOptions[lang.name] ?= {}
languages[lang.name] ?= lang
options = _.get(langOptions, "#{namespace}.properties")
options = langOptions[lang.name]
# Init field for supported beautifiers
lang.beautifiers = []
# Process all language options
for field, op of lang.options
if not op.title?
@ -127,6 +121,7 @@ module.exports = class Beautifiers extends EventEmitter
.map(_plus.capitalize).join(' ')
op.title = "#{lang.name} - #{op.title}"
# Init field for supported beautifiers
op.beautifiers = []
@ -143,10 +138,11 @@ module.exports = class Beautifiers extends EventEmitter
for beautifier in beautifiers
beautifierName = beautifier.name
# Iterate over supported languages
for languageName, options of beautifier.options
namespace = languages[languageName].namespace
laOp = _.get(langOptions, "#{namespace}.properties")
laOp = langOptions[languageName]
# Is a valid Language name
if typeof options is "boolean"
@ -155,6 +151,7 @@ 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
@ -194,6 +191,7 @@ 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
@ -205,13 +203,55 @@ module.exports = class Beautifiers extends EventEmitter
# Unsupported
logger.warn("Unsupported option:", beautifierName, languageName, field, op, langOptions)
# Improve descriptions to each language option
for g,group of langOptions
for o,optionDef of group.properties
# 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)
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)
@ -219,33 +259,33 @@ module.exports = class Beautifiers extends EventEmitter
# logger.verbose(langName, lang)
name = lang.name
namespace = lang.namespace
beautifiers = lang.beautifiers
optionName = "language_#{namespace}"
optionName = "language_#{lang.namespace}"
# Add Language configurations
_.set(langOptions, "#{namespace}.disabled", {
flatOptions["#{optionName}_disabled"] = {
title : "Language Config - #{name} - Disable Beautifying Language"
type : 'boolean'
default : false
description : "Disable #{name} Beautification"
})
_.set(langOptions, "#{namespace}.default_beautifier", {
}
flatOptions["#{optionName}_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)
})
_.set(langOptions, "#{namespace}.beautify_on_save", {
}
flatOptions["#{optionName}_beautify_on_save"] = {
title : "Language Config - #{name} - Beautify On Save"
type : 'boolean'
default : false
description : "Automatically beautify #{name} files on save"
})
}
# logger.verbose('langOptions', langOptions)
return langOptions
# logger.verbose('flatOptions', flatOptions)
return flatOptions
###

View File

@ -1,43 +1,37 @@
module.exports = {
_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"
}
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"
}