-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/main'
- Loading branch information
Showing
8 changed files
with
195 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
|
||
# Comment specification of proto file | ||
|
||
Avoid adding empty lines between comments symbols `//`.If there is a blank line in the comments, the tool(protoc-gen-doc) will generate malformed documents. | ||
bad case: | ||
``` | ||
message BadCase{ | ||
// XXXXXXXX | ||
// | ||
// XX | ||
// | ||
// XXXXXX | ||
field A | ||
} | ||
``` | ||
good case: | ||
``` | ||
message GoodCase{ | ||
// XXXXXXXX | ||
// XX | ||
// XXXXXX | ||
field A | ||
} | ||
``` | ||
Or you can use another annotation symbol directly `/* */` | ||
|
||
|
||
If you want to have some comment in your proto files, but don't want them to be part of the docs, you can simply prefix the comment with `@exclude`. | ||
Example: include only the comment for the id field | ||
``` | ||
/** | ||
* @exclude | ||
* This comment won't be rendered | ||
*/ | ||
message ExcludedMessage { | ||
string id = 1; // the id of this message. | ||
string name = 2; // @exclude the name of this message | ||
/* @exclude the value of this message. */ | ||
int32 value = 3; | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
|
||
# proto文件注释规范 | ||
|
||
避免在注释符号`//`之间添加空行,否则生成工具protoc-gen-doc会生成格式错乱的文档。 | ||
一个坏示例: | ||
``` | ||
message BadCase{ | ||
// XXXXXXXX | ||
// | ||
// XX | ||
// | ||
// XXXXXX | ||
field A | ||
} | ||
``` | ||
一个好示例: | ||
``` | ||
message GoodCase{ | ||
// XXXXXXXX | ||
// XX | ||
// XXXXXX | ||
field A | ||
} | ||
``` | ||
或者你可以直接使用另一种注释符号:`/* */` | ||
|
||
假如你想添加一些注释在proto文件里,但不想让它们出现在生成的文档里,你可以在注释里使用`@exclude`前缀。 | ||
示例:只包括id字段的注释 | ||
``` | ||
/** | ||
* @exclude | ||
* This comment won't be rendered | ||
*/ | ||
message ExcludedMessage { | ||
string id = 1; // the id of this message. | ||
string name = 2; // @exclude the name of this message | ||
/* @exclude the value of this message. */ | ||
int32 value = 3; | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters