2012-09-06 2 views
0

누구나 플러그인 방향으로 또는 다른 방법으로 코멘트를 지정할 수 있습니까?덧글 서식 지정을위한 플러그인

저는 coffeescript를 사용하고 있습니다. 주석 달기는 python (#line, ### block ###)과 동일하지만 javascript 주석도 컴파일러를 통해 곧바로 전달됩니다.

답변

-1

있다, 내가 플러그인을하지 않아도하지만 난 내가 쓴 파이썬 스크립트를 제공 할 수있는 자동 서식 Alt + Mayus + F를

0

있습니다. '사용자가 입력 한 주석'(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() 
관련 문제