文件頭注釋
開源項目:
/*** @file robot_base.cpp* @author Mr.Wu* @date 2025-05-28* @version 1.0.0* @brief Robot basic drive to communicate with controller** @copyright Copyright (c) 2025 google.** 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.*/
不開源項目
沒有許可證:
/*** @file robot_base.cpp* @author Mr.Wu* @date 2025-05-28* @version 1.0.0* @brief Robot basic drive to communicate with controller** @copyright Copyright (c) 2025 google.*/
有許可證:
/*** @file robot_base.cpp* @author Mr.Wu* @date 2025-05-28* @version 1.0.0* @brief Robot basic drive to communicate with controller** @copyright Copyright (c) 2025 google.** 許可證說明*/
(c)的作用
(c)
是 版權符號 ? 的文本表示形式。
-
Doxygen 會自動將
(c)
轉換為標準版權符號?
在生成的文檔(如 HTML/PDF)中顯示。 -
示例:
輸入@copyright (c) 2025 google
?→ 輸出? 2025 google
。
copyright---版權
copyright的作用:
1. 核心作用
用途 | 說明 |
---|---|
法律聲明 | 明確代碼的版權歸屬方(個人、公司或組織),避免所有權糾紛。 |
許可證關聯 | 與項目中的 LICENSE 文件配合,聲明代碼的使用條款(如開源協議)。 |
文檔生成 | Doxygen 會將 @copyright 內容提取到生成的文檔中(如 HTML/PDF 的頁腳)。 |
代碼溯源 | 幫助后續開發者了解代碼的來源和修改歷史。 |
公共許可證
Apache License 2.0
Apache License 2.0(Apache 2.0 許可證)是一種 寬松的開源軟件許可證,由 Apache 軟件基金會(ASF)制定,廣泛用于允許商業使用、修改和分發的開源項目。
所以對于公司項目,不可使用這個許可證。
在 Doxygen 的文件頭注釋中,指令(如 @file
、@brief
等)的先后順序沒有嚴格的技術限制,但為了代碼的可讀性和一致性,建議遵循一定的邏輯順序。以下是 Google C++ 風格和常見實踐中的推薦順序:
/*** @file <文件名> // 文件標識(通常放最前)* @author <作者> // 作者信息* @date <日期> // 創建/修改日期* @version <版本號> // 版本控制* @brief <簡要描述> // 核心功能摘要* * @details <詳細描述> // 可選:擴展說明* @copyright <版權信息> // 版權聲明(通常放最后)*/
對象注釋
函數注釋
教程
doxygen