首页  >  All Categories  >  Notes  >  如何对代码进行注释

如何对代码进行注释

不同编程语言有不同的方式进行注释,本文将举例说明

在你的代码中添加注释是一个很好的做法,因为它使你的代码更具有可读性,易于理解。

注释不会运行,因为它们会被编译器和解释器忽略。

总结起来,基本就是 // # /** */ <!----> ,实在不行,遍历 (逃)

vue🔗

一、template 标签中的注释

<!-- 注释,单行或多行 -->

二、 style标签中的注释

/*
    多行注释
*/

三、script标签中的注释

// 单行注释
/*
    多行注释
    多行注释
*/

四、方法注释规范

vue文件中method中的方法注释

/**
  * @description: 方法描述
  * @param {参数类型} 参数名称
  * @param {参数类型} 参数名称
  * @return 没有返回信息写 void / 有返回信息 {返回类型} 描述信息
  */

五、文件注释规范 单个文件注释规范,每个独立的VUE文件开头都要进行注释,表明该文件的描述信息、作者、创建时间等。

 <!--
 * @FileDescription: 该文件的描述信息
 * @Author: 作者信息
 * @Date: 文件创建时间
 * @LastEditors: 最后更新作者
 * @LastEditTime: 最后更新时间
 -->

C, C++, Java, Kotlin, and Rust🔗

C🔗

/**
this is a multiline comment or comment block
*/

// C99 uses the single-line comment

CPP🔗

/**
same as C-style comment block
*/

// single line comment

Java🔗

// same as C . . . !

/**
all the same
*/

Kotlin🔗

/**
 * might as well include Kotlin!
 */

Rust🔗

// rust comments are like C

#! cargo documentation comments

JavaScript, Python, Ruby, Perl, PHP, and BASH🔗

Javascript🔗

// JS is also like Java, but more dynamic

/*
Notice there's only 1 star on the leading comment symbol?
C/C++ and Java use 2 stars
*/

Python🔗

# Its a pound sign, or hash tag, or octothorpe, or a musical sharp symbol

"""
a multilin string comment literal thing
"""

Ruby🔗

# hey its another scripting language hash tag comment symbol

Perl🔗

# a language known for its regex capacity and one-liners

Bash🔗

# similar to python

PHP🔗

// c style one line comment
# shell style one line comment
/*
a multi line comment
*/

HTML and CSS🔗

HTML🔗

<!-- nobody saw this comming -->

CSS🔗

/*
here we go again
*/
// we don't deal with GLSL shader langauges much, but here it is
 ; comment with a semicolon, MIPS assembly is similar

参考资料🔗

分类: Notes 
标签CommentCodding
发布于: