Actually make doc: work

This commit is contained in:
John Barnette
2013-03-13 21:30:00 -07:00
parent 460577d9ae
commit eb5d0fe3f5
2 changed files with 11 additions and 15 deletions

View File

@@ -80,13 +80,8 @@ $.fn.events = ->
else
events
# Valid calling styles:
# command(eventName, handler)
# command(eventName, selector, handler)
# command(eventName, options, handler)
# command(eventName, selector, options, handler)
$.fn.command = (eventName, selector, options, handler) ->
if not options? and not handler?
if not options?
handler = selector
selector = null
else if not handler?
@@ -94,11 +89,10 @@ $.fn.command = (eventName, selector, options, handler) ->
options = null
if selector? and typeof(selector) is 'object'
handler = options
options = selector
selector = null
@document(eventName, _.humanizeEventName(eventName, options?["xxx"]))
@document(eventName, _.humanizeEventName(eventName, options?["doc"]))
@on(eventName, selector, options?['data'], handler)
$.fn.iconSize = (size) ->

View File

@@ -52,17 +52,16 @@ _.mixin
regex = RegExp('[' + specials.join('\\') + ']', 'g')
string.replace(regex, "\\$&");
humanizeEventName: (eventName, optionalDocString) ->
humanizeEventName: (eventName, eventDoc) ->
return "GitHub" if eventName.toLowerCase() is "github"
if /:/.test(eventName)
[namespace, name] = eventName.split(':')
return "#{@humanizeEventName(namespace)}: #{@humanizeEventName(name, optionalDocString)}"
[namespace, event] = eventName.split(':')
return _.capitalize(namespace) unless event?
return optionalDocString if not _.isEmpty(optionalDocString)
namespaceDoc = _.undasherize(namespace)
eventDoc ||= _.undasherize(event)
words = eventName.split('-')
words.map(_.capitalize).join(' ')
"#{namespaceDoc}: #{eventDoc}"
capitalize: (word) ->
word[0].toUpperCase() + word[1..]
@@ -84,6 +83,9 @@ _.mixin
else
"-"
undasherize: (string) ->
string.split('-').map(_.capitalize).join(' ')
underscore: (string) ->
string = string[0].toLowerCase() + string[1..]
string.replace /([A-Z])|(-)/g, (m, letter, dash) ->