2015-04-16 13:34:40 +00:00
|
|
|
_ = require('lodash')
|
|
|
|
ent = require('ent')
|
|
|
|
utils = require('./utils')
|
|
|
|
|
|
|
|
exports.command = (command) ->
|
|
|
|
result = """
|
|
|
|
## #{ent.encode(command.signature)}
|
|
|
|
|
|
|
|
#{command.help}\n
|
|
|
|
"""
|
|
|
|
|
|
|
|
if not _.isEmpty(command.options)
|
|
|
|
result += '\n### Options'
|
|
|
|
|
|
|
|
for option in command.options
|
|
|
|
result += """
|
|
|
|
\n\n#### #{utils.parseSignature(option)}
|
|
|
|
|
|
|
|
#{option.description}
|
|
|
|
"""
|
|
|
|
|
|
|
|
result += '\n'
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
|
|
|
exports.category = (category) ->
|
|
|
|
result = """
|
2015-04-16 14:42:09 +00:00
|
|
|
# #{category.title}\n
|
2015-04-16 13:34:40 +00:00
|
|
|
"""
|
|
|
|
|
|
|
|
for command in category.commands
|
|
|
|
result += '\n' + exports.command(command)
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
|
|
|
exports.toc = (toc) ->
|
|
|
|
result = '''
|
|
|
|
# Table of contents\n
|
|
|
|
'''
|
|
|
|
|
|
|
|
for category in toc
|
|
|
|
|
|
|
|
result += """
|
|
|
|
\n- #{category.title}\n\n
|
|
|
|
"""
|
|
|
|
|
|
|
|
for command in category.commands
|
|
|
|
result += """
|
2015-04-16 14:42:09 +00:00
|
|
|
\t- [#{ent.encode(command.signature)}](#{command.anchor})\n
|
2015-04-16 13:34:40 +00:00
|
|
|
"""
|
|
|
|
|
|
|
|
return result
|
|
|
|
|
|
|
|
exports.display = (doc) ->
|
|
|
|
result = """
|
|
|
|
# #{doc.title}
|
|
|
|
|
|
|
|
#{doc.introduction}
|
|
|
|
|
|
|
|
#{exports.toc(doc.toc)}
|
|
|
|
"""
|
|
|
|
|
|
|
|
for category in doc.categories
|
|
|
|
result += '\n' + exports.category(category)
|
|
|
|
|
|
|
|
return result
|