一、設置注釋不在首行
將第四步中的對勾√去掉
二、設置注釋模塊
前提:
用WebStrom不管寫HTML,還是JavaScript都會涉及到一些文檔說明。尤其是文檔的頭部注解說明。
只要是你寫的頁面,頭部注解說明基本一致。每次都寫一遍?這不像是一個玩計算機人的風格。
下面的方法。就解決了此問題。
同時提示:養成良好的代碼習慣,規范化代碼,規范的注釋便於后續維護。
實現效果 如下:
文檔說明注釋 :
Webstorm 中,自定義說明注釋模板,模板內容包括(文檔描述、作者、創建日期等信息):
自定義注釋模板開始:
一、在菜單欄 --->文檔中 ---> 找到 設置。
或者直接 快捷鍵 Ctrl + Alt + S
打開Webstorm設置,找不到的 可以 直接搜索 ‘Live Template
’,然后選擇進入到右側菜單,如下:
二、點擊右上角 “+
” --> Live Template
,添加注釋模板,出現以下界面,填寫相關的信息。參考如下:
<!-- @name: @description: @author: byx @time: $date$ -->
詳細信息圖如下:
第五步,“Edit variables” ,這里說一下,時間($date$)的具體格式,這個格式和 java中的還不一樣,百度也是一半對,一半錯,記錄下來。防止下回換電腦再應用到。
date("yyyy-MM-dd HH:mm:ss")
第六步,“Change” 選擇模板應用的范圍。一般不會的就全選就好了。嘿嘿。我只HTML中用到此快捷鍵。就只勾選了HTML相關。
選擇模板應用范圍項 為必選項,不選 會報錯。保存不了。
三、在HTML代碼中,輸入 /// + Tab 鍵即可 自動生成 自定的 文檔頭部 注釋模板了!!!
番外:最后,詳細介紹的一下第五步的 Edit variables 到底有哪些參數可用。如下圖:(圖片來源於網絡,byx收集記錄)
Item |
Description |
---|---|
|
Returns the characters that indicate the end of a block comment in the current language context.返回指示當前語言上下文中塊注釋結尾的字符。 |
|
Returns the characters that indicate the start of a block comment in the current language context.返回指示當前語言上下文中塊注釋開頭的字符。 |
camelCase(String) |
Converts a string into camelCase. For example, 將字符串轉換為駝色大小寫。例如, camelCase(my-text-file), camelCase(my text file), and camelCase(my_text_file) 這三種都返回 myTextFile. |
capitalize(String) |
Capitalizes the first letter of the parameter. 將參數的第一個字母大寫。 |
capitalizeAndUnderscore(sCamelCaseName) |
Capitalizes all the letters of a CamelCase name passed as the parameter, and inserts an underscore between the parts. For example, 將參數所有字母大寫,並在各部分之間插入下划線。例如,如 |
classNameComplete() |
This expression substitutes for the class name completion at the variable position. 此表達式在變量位置替換類名完成。 |
clipboard() |
Returns the contents of the system clipboard. 返回系統剪貼板的內容。 |
|
Returns the characters that indicate the end of a comment in the current language context. The return value is empty if line comments are defined in the current language. 返回指示當前語言上下文中注釋結尾的字符。如果行注釋是用當前語言定義的,則返回值為空。 |
|
Returns the characters that indicate the start of a comment in the current language context. If line comments are defined in the current language, their start indicator is preferable. 返回指示當前語言上下文中注釋開頭的字符。如果行注釋是用當前語言定義的,則它們的開始指示符更可取。 |
complete() |
Invokes code completion at the position of the variable. 在變量的位置自動識別代碼 |
completeSmart() |
Invokes smart type completion at the position of the variable. 在變量的位置調用智能類型完成。 |
|
Returns a concatenation of all the strings passed to the function as parameters. 返回串聯的所有參數 |
|
Returns the name of a variable that can be iterated. 返回可迭代的變量的名稱。 |
|
Returns a list of elements of an array. 返回數組元素的列表。 |
|
Returns a suggested name for an index variable from most commonly used ones: 返回最常用的索引變量的建議名稱:i、j、k等。當前作用域中尚未使用的名稱將首先顯示。 |
|
Returns the suggested name for a variable based on its variable type and initializer expression, according to your code style settings that refer to the variable naming rules. |
date(sDate) |
Returns the current system date in the specified format. Without a parameter, the current date is returned in the default system format. 以指定格式返回當前系統日期。 如果沒有參數,則以默認系統格式返回當前日期。 |
decapitalize(sName) |
Replaces the first letter of the parameter with the corresponding lowercase letter. 將參數的第一個字母替換為相應的小寫字母。 |
enum(sCompletionString1,sCompletionString2,...) |
Returns a list of comma-separated strings suggested for completion when the template is expanded. 返回在擴展模板時建議完成的逗號分隔字符串列表。 |
escapeString(sEscapeString) |
Escapes the string specified as the parameter. 轉義指定為參數的字符串。 |
expectedType() |
Returns the expected type of the expression into which the template expands. Makes sense if the template expands in the right part of an assignment, after 當模板擴展中返回表達式的預期類型,如果模板在分配的正確部分、返回后等進行擴展,則是有意義的。 |
fileName() |
Returns the name of the current file with its extension. 返回當前文件的名稱及其擴展名。 |
fileNameWithoutExtension() |
Returns the name of the current file without its extension. 返回不帶擴展名的當前文件的名稱。 |
firstWord(sFirstWord) |
Returns the first word of the string passed as the parameter. 返回作為參數傳遞的字符串的第一個字。 |
groovyScript("groovy code", arg1) |
Returns a Groovy script with the specified code. You can use the |
|
Returns the name of the current JavaScript array. |
jsClassName() |
Returns the name of the current JavaScript class. 返回當前javascript類的名稱。 |
|
Returns the type of the current JavaScript component. 返回當前javascript組件的類型。 |
|
Based on the name of the module, returns the parameter from 根據模塊的名稱,返回參數fromdefine([“module”]、function(<parameter_in_question>>))。 |
jsMethodName() |
Returns the name of the current JavaScript method. 返回當前javascript方法的名稱。 |
|
Returns the complete name of the current JavaScript class. |
|
Returns a suggested name for an index variable from most commonly used ones: |
|
Returns the suggested name for a variable based on its variable type and initializer expression, according to your code style settings that refer to the variable naming rules. |
|
The Boolean parameter determines whether constants are allowed or not in the current context. If no parameter is specified, constants are allowed. When the templates expands, a drop-down list is shown with |
|
Suggests the name for import statements of the type |
|
Returns the characters that indicate the start of a line comment in the current language context. 返回在當前語言上下文中指示行注釋開頭的字符。 |
lineNumber() |
Returns the current line number. 返回當前行號。 |
lowercaseAndDash(String) |
Converts a camelCase string into lower case and inserts n-dashes as separators. For example, 字符串轉換為小寫,並插入n個-作為分隔符,例如 lowercaseAndDash(MyExampleName) returns my-example-name |
|
Converts a string into snake_case. For example, 將字符串轉換為蛇形命名法。例如,snakecase(foo bar)返回foo_bar。 |
spaceSeparated(String) |
Converts a string into lowercase and inserts spaces as separators. For example, 將字符串轉換為小寫並插入空格作為分隔符。例如,spaceseparated(foo bar)返回foo bar。 |
substringBefore(String,Delimiter) |
Removes the extension after the specified delimiter and returns only the file name. This is helpful for test file names (for example, 刪除指定分隔符后的擴展名,並僅返回文件名。這有助於測試文件名(例如,$filename$,“.”之前的子字符串)返回component test in component test.js。 |
time(sSystemTime) |
Returns the current system time in the specified format. 以指定格式返回當前系統時間。 |
underscoresToCamelCase(String) |
Replaces underscores with camelCase letters in the string passed as the parameter. For example, 替換下划線。例如,underlinestocamelcase(foo_bar)返回foo bar。 |
underscoresToSpaces(sParameterWithUnderscores) |
Replaces underscores with spaces in the string passed as the parameter. For example, 將參數中的下划線替換成空格,如 |
user() |
Returns the name of the current user. 返回當前用戶的名稱。 |