2012-09-06 73 views
0

任何人都可以指向插件方向或格式化評論嗎?用於格式化評論的插件

我正在使用coffeescript,註釋與python(#line,### block ###)相同,儘管javascript註釋也直接通過了編譯器。

回答

-1

您可以使用NetBeans,它具有自動套用格式Alt + Mayus + F

0

我沒有一個插件,但我可以提供,我寫了一個python腳本。在「用戶輸入的評論」(uec)變量中輸入您的評論作爲字符串,保存並運行。它將格式化一個包含80個字符的英鎊符號的塊引用。如果您需要更短或更長的區塊報價,則只需更改80,78和76.

def first2lines(): return str(('#' * 80) + '\n' + '#' + (' ' * 78) + '#') # first two lines 
def leftSide(): return '# '            # left side of border 
def rightSide(): return ' #'            # right side of border 
def last2lines(): return str('#' + (' ' * 78) + '#' + '\n' + ('#' * 80)) # last two lines 

# user entered comment 
uec = "This program will neatly format a programming comment block so that it's surrounded by pound signs (#). It does this by splitting the comment into a list and then concatenating strings each no longer than 76 characters long including the correct amount of right side space padding. " 

if len(uec) > 0: 
    eosm = '<<<EOSM>>>'         # end of string marker 
    comment = uec + ' ' + eosm 
    wordList = comment.split()       # load the comment into a list 
    tmpString = ''          # temporarily holds loaded elements 
    loadComment = ''          # holds the elements that will be printed 
    counter = 0           # keeps track of the number of elements/words processed 
    space = 0            # holds right side space padding 
    last = wordList.index(wordList[-1])     # numerical position of last element 

    print first2lines() 
    for word in wordList: 
     tmpString += word + ' '       # load the string until length is greater than 76 

     # processes and prints all comment lines except the last one 
     if len(tmpString.rstrip()) > 76: 
      tmpList = tmpString.split() 
      tmpString = tmpList[-1] + ' '     # before popping last element load it for the beginning of the next cycle 
      tmpList.pop() 
      for tmp in tmpList: 
       loadComment += tmp + ' ' 
      loadComment = loadComment.rstrip() 
      space = 76 - len(loadComment) 
      print leftSide() + loadComment + (space * ' ') + rightSide() 
      loadComment = '' 

     # processes and prints the last comment line 
     elif len(tmpString.rstrip()) <= 76 and counter == last: 
      tmpList = tmpString.split() 
      tmpList.pop() 
      for tmp in tmpList: 
       loadComment += tmp + ' ' 
      loadComment = loadComment.rstrip() 
      space = 76 - len(loadComment) 
      print leftSide() + loadComment + (space * ' ') + rightSide() 

     counter += 1 
    print last2lines() 

else: 
    print first2lines() 
    print leftSide() + "The length of your comment is zero, it must be at least one character long. " + rightSide() 
    print last2lines()