mirror of
https://github.com/atom/atom.git
synced 2026-01-25 06:48:28 -05:00
Only show events w/ descriptions in EventPalette
Also, auto-generate human readable event name in editor. This is a good example of how we could do this automatically for some kind of `onCommand`, `command`, `onInteractiveEvent` method that combines the event name, documentation string, and handler in one shot.
This commit is contained in:
@@ -56,10 +56,12 @@ $.fn.document = (eventDescriptions) ->
|
||||
|
||||
$.fn.events = ->
|
||||
documentation = @data('documentation') ? {}
|
||||
events = _.keys(@data('events') ? {}).map (eventName) ->
|
||||
_.compact([eventName, documentation[eventName]])
|
||||
events = {}
|
||||
|
||||
for eventName of @data('events') ? {}
|
||||
events[eventName] = documentation[eventName] ? null
|
||||
|
||||
if @hasParent()
|
||||
events.concat(@parent().events())
|
||||
_.extend(@parent().events(), events)
|
||||
else
|
||||
events
|
||||
|
||||
@@ -51,3 +51,14 @@ _.mixin
|
||||
# even though only some strictly require it when inside of []
|
||||
regex = RegExp('[' + specials.join('\\') + ']', 'g')
|
||||
string.replace(regex, "\\$&");
|
||||
|
||||
humanizeEventName: (eventName) ->
|
||||
if /:/.test(eventName)
|
||||
[namespace, name] = eventName.split(':')
|
||||
return "#{@humanizeEventName(namespace)}: #{@humanizeEventName(name)}"
|
||||
|
||||
words = eventName.split('-')
|
||||
words.map(_.capitalize).join(' ')
|
||||
|
||||
capitalize: (word) ->
|
||||
word[0].toUpperCase() + word[1..]
|
||||
Reference in New Issue
Block a user