mirror of
https://github.com/atom/atom.git
synced 2026-01-23 22:08:08 -05:00
Actually make doc: work
This commit is contained in:
@@ -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) ->
|
||||
|
||||
@@ -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) ->
|
||||
|
||||
Reference in New Issue
Block a user