See #58. Add automatic documentation generation for Options

npm run docs
This commit is contained in:
Glavin Wiechert 2015-06-01 15:52:33 -03:00
parent d18ef3ee50
commit 9e90708a55
11 changed files with 1532 additions and 153 deletions

26
docs/index.coffee Executable file
View File

@ -0,0 +1,26 @@
#!/usr/bin/env coffee
# Dependencies
Handlebars = require('handlebars')
Beautifiers = require("../src/beautifiers")
fs = require('fs')
console.log('Generating options...')
beautifier = new Beautifiers()
defaultLanguageOptions = beautifier.options
console.log('Loading options template...')
templatePath = __dirname + '/options-template.md'
optionsPath = __dirname + '/options.md'
source = fs.readFileSync(templatePath).toString()
console.log('Building documentation from template and options...')
template = Handlebars.compile(source)
context = {
options: defaultLanguageOptions
}
result = template(context)
console.log('Writing documentation to file...')
fs.writeFileSync(optionsPath, result)
console.log('Done.')

23
docs/options-template.md Normal file
View File

@ -0,0 +1,23 @@
# Options
Automatically generated documentation for language and beautifier options.
## Supported Options
{{#each options}}
### {{title}} (`{{@key}}`)
{{#if default}}
**Default**: `{{default}}`
{{/if}}
**Type**: `{{type}}`
{{#if enum}}
**Enum**: {{#each enum}} `{{this}}` {{/each}}
{{/if}}
#### Description
{{description}}
{{/each}}

1337
docs/options.md Normal file

File diff suppressed because it is too large Load Diff

View File

@ -17,33 +17,26 @@
"email": "glavin.wiechert@gmail.com", "email": "glavin.wiechert@gmail.com",
"url": "https://github.com/Glavin001" "url": "https://github.com/Glavin001"
}, },
"contributors": [ "contributors": [{
{
"name": "Donald Pipowitch", "name": "Donald Pipowitch",
"email": "pipo@senaeh.de", "email": "pipo@senaeh.de",
"url": "https://github.com/donaldpipowitch" "url": "https://github.com/donaldpipowitch"
}, }, {
{
"name": "László Károlyi", "name": "László Károlyi",
"url": "https://github.com/karolyi" "url": "https://github.com/karolyi"
}, }, {
{
"name": "Marco Tanzi", "name": "Marco Tanzi",
"url": "https://github.com/mtanzi" "url": "https://github.com/mtanzi"
}, }, {
{
"name": "gvn lazar suntop", "name": "gvn lazar suntop",
"url": "https://github.com/gvn" "url": "https://github.com/gvn"
}, }, {
{
"name": "Vadim K.", "name": "Vadim K.",
"url": "https://github.com/vadirn" "url": "https://github.com/vadirn"
}, }, {
{
"name": "Filipe Silva", "name": "Filipe Silva",
"url": "https://github.com/filipesilva" "url": "https://github.com/filipesilva"
} }],
],
"engines": { "engines": {
"atom": ">=0.174.0 <2.0.0" "atom": ">=0.174.0 <2.0.0"
}, },
@ -135,5 +128,13 @@
"marko", "marko",
"go", "go",
"golang" "golang"
] ],
"devDependencies": {
"coffee-script": "^1.9.3",
"handlebars": "^3.0.3"
},
"scripts": {
"prepublish": "npm run docs",
"docs": "coffee docs/"
}
} }

View File

@ -1,6 +1,6 @@
# Get Atom defaults # Get Atom defaults
tabLength = atom.config.get('editor.tabLength') tabLength = atom?.config.get('editor.tabLength') ? 4
softTabs = atom.config.get('editor.softTabs') softTabs = atom?.config.get('editor.softTabs') ? true
defaultIndentSize = (if softTabs then tabLength else 1) defaultIndentSize = (if softTabs then tabLength else 1)
defaultIndentChar = (if softTabs then " " else "\t") defaultIndentChar = (if softTabs then " " else "\t")
defaultIndentWithTabs = not softTabs defaultIndentWithTabs = not softTabs

View File

@ -1,6 +1,6 @@
# Get Atom defaults # Get Atom defaults
tabLength = atom.config.get('editor.tabLength') tabLength = atom?.config.get('editor.tabLength') ? 4
softTabs = atom.config.get('editor.softTabs') softTabs = atom?.config.get('editor.softTabs') ? true
defaultIndentSize = (if softTabs then tabLength else 1) defaultIndentSize = (if softTabs then tabLength else 1)
defaultIndentChar = (if softTabs then " " else "\t") defaultIndentChar = (if softTabs then " " else "\t")
defaultIndentWithTabs = not softTabs defaultIndentWithTabs = not softTabs

View File

@ -6,13 +6,6 @@ Language Support and default options.
_ = require('lodash') _ = require('lodash')
extend = null extend = null
# Get Atom defaults
tabLength = atom.config.get('editor.tabLength')
softTabs = atom.config.get('editor.softTabs')
defaultIndentSize = (if softTabs then tabLength else 1)
defaultIndentChar = (if softTabs then " " else "\t")
defaultIndentWithTabs = not softTabs
# #
module.exports = class Languages module.exports = class Languages

View File

@ -1,6 +1,6 @@
# Get Atom defaults # Get Atom defaults
tabLength = atom.config.get('editor.tabLength') tabLength = atom?.config.get('editor.tabLength') ? 4
softTabs = atom.config.get('editor.softTabs') softTabs = atom?.config.get('editor.softTabs') ? true
defaultIndentSize = (if softTabs then tabLength else 1) defaultIndentSize = (if softTabs then tabLength else 1)
defaultIndentChar = (if softTabs then " " else "\t") defaultIndentChar = (if softTabs then " " else "\t")
defaultIndentWithTabs = not softTabs defaultIndentWithTabs = not softTabs

View File

@ -1,6 +1,6 @@
# Get Atom defaults # Get Atom defaults
tabLength = atom.config.get('editor.tabLength') tabLength = atom?.config.get('editor.tabLength') ? 4
softTabs = atom.config.get('editor.softTabs') softTabs = atom?.config.get('editor.softTabs') ? true
defaultIndentSize = (if softTabs then tabLength else 1) defaultIndentSize = (if softTabs then tabLength else 1)
defaultIndentChar = (if softTabs then " " else "\t") defaultIndentChar = (if softTabs then " " else "\t")
defaultIndentWithTabs = not softTabs defaultIndentWithTabs = not softTabs

View File

@ -1,6 +1,6 @@
# Get Atom defaults # Get Atom defaults
tabLength = atom.config.get('editor.tabLength') tabLength = atom?.config.get('editor.tabLength') ? 4
softTabs = atom.config.get('editor.softTabs') softTabs = atom?.config.get('editor.softTabs') ? true
defaultIndentSize = (if softTabs then tabLength else 1) defaultIndentSize = (if softTabs then tabLength else 1)
defaultIndentChar = (if softTabs then " " else "\t") defaultIndentChar = (if softTabs then " " else "\t")
defaultIndentWithTabs = not softTabs defaultIndentWithTabs = not softTabs

View File

@ -9,13 +9,12 @@ module.exports = do ->
# See http://stackoverflow.com/a/21583831/2578205 # See http://stackoverflow.com/a/21583831/2578205
winston = require('winston') winston = require('winston')
stream = require('stream') stream = require('stream')
writable = new stream.Writable({ writable = new stream.Writable()
write: (chunk, encoding, next) -> writable._write = (chunk, encoding, next) ->
msg = chunk.toString() msg = chunk.toString()
# console.log(msg) # console.log(msg)
emitter.emit('logging', msg) emitter.emit('logging', msg)
next() next()
})
levels = { levels = {
silly: 0, silly: 0,
@ -48,7 +47,7 @@ module.exports = do ->
] ]
}) })
wlogger.on('logging', (transport, level, msg, meta)-> wlogger.on('logging', (transport, level, msg, meta)->
loggerLevel = atom.config.get('atom-beautify._loggerLevel') loggerLevel = atom?.config.get('atom-beautify._loggerLevel') ? "warn"
# console.log('logging', loggerLevel, arguments) # console.log('logging', loggerLevel, arguments)
loggerLevelNum = levels[loggerLevel] loggerLevelNum = levels[loggerLevel]
levelNum = levels[level] levelNum = levels[level]