HarmonyOS 鸿蒙Next DevEco Studio配置:自定义头部代码注释

HarmonyOS 鸿蒙Next DevEco Studio配置:自定义头部代码注释

DevEco Studio配置:自定义头部代码注释

1.实现效果

/*
 * Copyright (c) 2022 JianGuo Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/**
 * @ProjectName : nutsStudy
 * @FileName :  setting
 * @Author : 坚果
 * @Time : 2022/8/5 13:51
 * @Description : 文件描述 
 */

2.实现步骤

依次操作File – Settings – Editor – File and Code Templates,在详细展示窗口点击includes选项卡,找到

FileHeader点击,在编辑窗口输入自定义的注释模板即可。如下图:

3. 总结

参数 描述
${PACKAGE_NAME} 新建文件所在包名
${USER} 用户名
${DATE} 创建文件时当前系统的日期(格式:yyyy/MM/dd)
${TIME} 创建文件时当前系统的时间(格式:hh:mm)
${YEAR} 创建文件时当前系统的年份
${MONTH} 创建文件时当前系统的月份
${MONTH_NAME_SHORT} 当前月份的前三位字符缩写,例如: Jan, Feb, etc
${MONTH_NAME_FULL} 当前月份的字母全写,例如: January, February, etc
${DAY} 当前时间所属月份的天数
${HOUR} 当前的小时数
${MINUTE} 当前的分钟数
${PROJECT_NAME} 当前的项目名
${NAME} 当前的文件名

4.我添加的内容

/*
 * Copyright (c) 2022 JianGuo Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/**
 * @ProjectName : ${PROJECT_NAME}
 * @FileName : ${NAME}
 * @Author : 坚果
 * @Time : ${DATE} ${TIME}
 * @Description : 文件描述 
 */

效果:


更多关于HarmonyOS 鸿蒙Next DevEco Studio配置:自定义头部代码注释的实战教程也可以访问 https://www.itying.com/category-93-b0.html

1 回复

更多关于HarmonyOS 鸿蒙Next DevEco Studio配置:自定义头部代码注释的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html


在HarmonyOS(鸿蒙)系统中,DevEco Studio是用于开发鸿蒙应用的集成开发环境(IDE)。关于“HarmonyOS 鸿蒙Next DevEco Studio配置:自定义头部代码注释”的问题,具体操作步骤如下:

  1. 打开DevEco Studio: 启动DevEco Studio,并打开你需要配置的项目。

  2. 编辑文件模板: 在DevEco Studio中,导航到“File”菜单,选择“Settings”(对于Mac用户,可能是“Preferences”)。在设置窗口中,搜索“File and Code Templates”或“文件与代码模板”。

  3. 设置自定义头部注释: 在“File and Code Templates”中,你会看到各种类型的文件模板,如Java类、Kotlin类、C/C++类等(注意,虽然鸿蒙开发可能涉及多种语言,但此问题要求不涉及Java和C语言内容,这里假设你正在配置的是其他类型文件的模板,如XML布局文件或其他配置文件)。找到你想要添加自定义头部注释的文件类型,点击它,然后在右侧的编辑器中输入你的自定义头部注释内容。

  4. 应用并保存: 输入完注释后,点击“Apply”或“OK”保存设置。

  5. 测试: 创建一个新的文件,检查是否自动生成了你设置的头部注释。

如果问题依旧没法解决请联系官网客服,官网地址是:https://www.itying.com/category-93-b0.html

回到顶部