Permalink
Browse files

fixed optional arguments [, ]

  • Loading branch information...
1 parent 9aece7d commit bbc5bc29b60b5ecbc568f9bf34c7358362bb4bb8 ilan committed Mar 19, 2013
Showing with 15 additions and 4 deletions.
  1. +7 −2 app/assets/javascripts/entry.js.coffee
  2. +8 −2 app/assets/javascripts/header.js.coffee
@@ -82,10 +82,15 @@ class jqapi.Entry
joinArr = [] # generate the comma seperated string with join
for arg in argsArr
- joinArr.push arg.name if arg and arg.name # push argument name to join array
+ comma = ""
+ comma = ", " unless joinArr.length is 0
+ if arg and arg.optional
+ joinArr.push "[#{comma}#{arg.name}]" if arg and arg.name
+ else
+ joinArr.push "#{comma}#{arg.name}" if arg and arg.name
methodName = title.substr(0, title.length - 2) # cut out the empty ()
- sigTitle = "#{methodName}(#{joinArr.join(', ')})" # and fill it with arguments
+ sigTitle = "#{methodName}(#{joinArr.join(' ')})" # and fill it with arguments
sigTitle # return full title
@@ -43,8 +43,14 @@ class jqapi.Header
joinArr = []
for arg in argsArr
- joinArr.push arg.name if arg and arg.name
+ comma = ""
+ comma = ", " unless joinArr.length is 0
+ if arg and arg.optional
+ joinArr.push "[#{comma}#{arg.name}]" if arg and arg.name
+ else
+ joinArr.push "#{comma}#{arg.name}" if arg and arg.name
+
+ retArr.push joinArr.join(' ')
- retArr.push joinArr.join(', ')
retArr

0 comments on commit bbc5bc2

Please sign in to comment.