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:
Corey Johnson & Nathan Sobo
2012-10-19 12:14:02 -06:00
parent d420585b11
commit 191164ed4c
2 changed files with 12 additions and 5 deletions

View File

@@ -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

View File

@@ -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...)