mirror of
https://github.com/atom/atom.git
synced 2026-01-24 14:28:14 -05:00
Add $.fn.command method which ensures event is documented
For now, we auto-generate the documentation string by humanizing the event name. In the future, we may provide the option to provide more documentation, such as info about any arguments to the event, extended documentation, etc.
This commit is contained in:
@@ -74,11 +74,11 @@ class RootView extends View
|
||||
@project.setPath(path) unless @project.getRootDirectory()
|
||||
@setTitle(path)
|
||||
|
||||
@on 'root-view:increase-font-size', => @setFontSize(@getFontSize() + 1)
|
||||
@on 'root-view:decrease-font-size', => @setFontSize(@getFontSize() - 1)
|
||||
@on 'root-view:focus-next-pane', => @focusNextPane()
|
||||
@on 'root-view:save-all', => @saveAll()
|
||||
@on 'root-view:toggle-invisibles', => @setShowInvisibles(not @showInvisibles)
|
||||
@command 'root-view:increase-font-size', => @setFontSize(@getFontSize() + 1)
|
||||
@command 'root-view:decrease-font-size', => @setFontSize(@getFontSize() - 1)
|
||||
@command 'root-view:focus-next-pane', => @focusNextPane()
|
||||
@command 'root-view:save-all', => @saveAll()
|
||||
@command 'root-view:toggle-invisibles', => @setShowInvisibles(not @showInvisibles)
|
||||
|
||||
afterAttach: (onDom) ->
|
||||
@focus() if onDom
|
||||
|
||||
@@ -65,3 +65,10 @@ $.fn.events = ->
|
||||
_.extend(@parent().events(), events)
|
||||
else
|
||||
events
|
||||
|
||||
$.fn.command = (args...) ->
|
||||
eventName = args[0]
|
||||
documentation = {}
|
||||
documentation[eventName] = _.humanizeEventName(eventName)
|
||||
@document(documentation)
|
||||
@on(args...)
|
||||
|
||||
Reference in New Issue
Block a user