See #58. Add package options to autogenerated documentation

This commit is contained in:
Glavin Wiechert 2015-06-01 16:50:09 -03:00
parent f10f414296
commit 5c663cd9e0
8 changed files with 866 additions and 474 deletions

View File

@ -84,35 +84,6 @@ For example:
'ctrl-alt-b': 'atom-beautify:beautify-editor' '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 ## Configuration
Edit your `.jsbeautifyrc` file in any of the following locations: Edit your `.jsbeautifyrc` file in any of the following locations:
@ -128,7 +99,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) 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 ### 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.

View File

@ -7,16 +7,22 @@ fs = require('fs')
console.log('Generating options...') console.log('Generating options...')
beautifier = new Beautifiers() beautifier = new Beautifiers()
defaultLanguageOptions = beautifier.options languageOptions = beautifier.options
packageOptions = require('../src/config.coffee')
console.log('Loading options template...') console.log('Loading options template...')
templatePath = __dirname + '/options-template.md' optionsTemplatePath = __dirname + '/options-template.md'
optionTemplatePath = __dirname + '/option-template.md'
optionsPath = __dirname + '/options.md' optionsPath = __dirname + '/options.md'
source = fs.readFileSync(templatePath).toString() optionsTemplate = fs.readFileSync(optionsTemplatePath).toString()
optionTemplate = fs.readFileSync(optionTemplatePath).toString()
console.log('Building documentation from template and options...') console.log('Building documentation from template and options...')
template = Handlebars.compile(source) Handlebars.registerPartial('option', optionTemplate)
template = Handlebars.compile(optionsTemplate)
context = { context = {
options: defaultLanguageOptions packageOptions: packageOptions
languageOptions: languageOptions
} }
result = template(context) result = template(context)

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}}

View File

@ -1,23 +1,23 @@
# Options # Options
Automatically generated documentation for language and beautifier options. Automatically generated documentation for Atom Beautify's options.
## Supported Options ## Package Options
{{#each options}} Configurable options for Atom Beautify.
### {{title}} (`{{@key}}`)
{{#if default}}
**Default**: `{{default}}` ---
{{/if}}
**Type**: `{{type}}`
{{#if enum}}
**Enum**: {{#each enum}} `{{this}}` {{/each}}
{{/if}}
#### Description
{{description}}
{{#each packageOptions}}
{{> option}}
{{/each}}
## Language Options
Supported options for each language.
---
{{#each languageOptions}}
{{> option}}
{{/each}} {{/each}}

File diff suppressed because it is too large Load Diff

View File

@ -426,38 +426,7 @@ handleSaveEvent = =>
plugin.subscribe disposable plugin.subscribe disposable
{Subscriber} = require path.join(atom.packages.resourcePath, 'node_modules', 'emissary') {Subscriber} = require path.join(atom.packages.resourcePath, 'node_modules', 'emissary')
Subscriber.extend plugin Subscriber.extend plugin
plugin.config = _.merge( plugin.config = _.merge(require('./config.coffee'), defaultLanguageOptions)
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.activate = -> plugin.activate = ->
handleSaveEvent() handleSaveEvent()
plugin.subscribe atom.config.observe("atom-beautify.beautifyOnSave", 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"
}