Closes #529. Improve documentation generation for package options

Show difference between Atom Beautify package option and
language config options in generated documentation
This commit is contained in:
Glavin Wiechert 2015-08-31 19:25:40 -03:00
parent 330abeedc9
commit 4e528809f0
5 changed files with 3072 additions and 289 deletions

View File

@ -40,6 +40,31 @@ Handlebars.registerHelper('linkify', (title, options) ->
) )
) )
exampleConfig = (option) ->
# console.log(option)
t = option.type
d = switch
when option.default? then option.default
when t is "string" then ""
when t is "integer" then 0
when t is "boolean" then false
else null
json = {}
namespace = option.language.namespace
k = option.key
c = {}
c[k] = d
json[namespace] = c
return """```json
#{JSON.stringify(json, undefined, 4)}
```"""
Handlebars.registerHelper('example-config', (key, option, options) ->
results = exampleConfig(key, option)
# console.log(results)
return new Handlebars.SafeString(results)
)
context = { context = {
packageOptions: packageOptions packageOptions: packageOptions

View File

@ -1,6 +1,12 @@
#### {{#if title}} {{#linkify title}}{{title}}{{/linkify}} {{else}} {{#linkify @key}}`{{@key}}`{{/linkify}} {{/if}} #### {{#if title}} {{#linkify title}}{{title}}{{/linkify}} {{else}} {{#linkify @key}}`{{@key}}`{{/linkify}} {{/if}}
**Key**: `{{@key}}` {{#if beautifiers}}
**Namespace**: `{{language.namespace}}`
**Key**: `{{key}}`
{{else}}
**Important**: This option is only configurable from within Atom Beautify's setting panel.
{{/if}}
{{#if default}} {{#if default}}
**Default**: `{{default}}` **Default**: `{{default}}`
@ -20,3 +26,17 @@
{{description}} {{description}}
{{#if beautifiers}}
**Example `.jsbeautifyrc` Configuration**
{{example-config this}}
{{else}}
**How to Configure**
1. You can open the [Settings View](https://github.com/atom/settings-view) by navigating to
*Edit > Preferences (Linux)*, *Atom > Preferences (OS X)*, or *File > Preferences (Windows)*.
2. Go into *Packages* and search for "*Atom Beautify*" package.
3. Find the option "*{{title}}*" and change it to your desired configuration.
{{/if}}

File diff suppressed because it is too large Load Diff

View File

@ -117,6 +117,11 @@ module.exports = class Beautifiers extends EventEmitter
# Init field for supported beautifiers # Init field for supported beautifiers
op.beautifiers = [] op.beautifiers = []
# Remember Option's Key
op.key = field
# Remember Option's Language
op.language = lang
# Add option # Add option
options[field] = op options[field] = op

View File

@ -1,5 +1,6 @@
module.exports = { module.exports = {
analytics : analytics :
title: 'Anonymous Analytics'
type : 'boolean' type : 'boolean'
default : true default : true
description : "There is [Segment.io](https://segment.io/) which forwards data to [Google description : "There is [Segment.io](https://segment.io/) which forwards data to [Google
@ -8,23 +9,28 @@ module.exports = {
information, such as source code, is sent. information, such as source code, is sent.
See https://github.com/Glavin001/atom-beautify/issues/47 for more details." See https://github.com/Glavin001/atom-beautify/issues/47 for more details."
_analyticsUserId : _analyticsUserId :
title: 'Analytics User Id'
type : 'string' type : 'string'
default : "" default : ""
description : "Unique identifier for this user for tracking usage analytics" description : "Unique identifier for this user for tracking usage analytics"
_loggerLevel : _loggerLevel :
title: "Logger Level"
type : 'string' type : 'string'
default : 'warn' default : 'warn'
description : 'Set the level for the logger' description : 'Set the level for the logger'
enum : ['verbose', 'debug', 'info', 'warn', 'error'] enum : ['verbose', 'debug', 'info', 'warn', 'error']
beautifyEntireFileOnSave : beautifyEntireFileOnSave :
title: "Beautify Entire File On Save"
type : 'boolean' type : 'boolean'
default : true default : true
description : "When beautifying on save, use the entire file, even if there is selected text in the editor" description : "When beautifying on save, use the entire file, even if there is selected text in the editor"
muteUnsupportedLanguageErrors : muteUnsupportedLanguageErrors :
title: "Mute Unsupported Language Errors"
type : 'boolean' type : 'boolean'
default : false default : false
description : "Do not show \"Unsupported Language\" errors when they occur" description : "Do not show \"Unsupported Language\" errors when they occur"
muteAllErrors : muteAllErrors :
title: "Mute All Errors"
type : 'boolean' type : 'boolean'
default : false default : false
description : "Do not show any/all errors when they occur" description : "Do not show any/all errors when they occur"