GoDoc 添加换行符
GoDoc add newline character
我知道 Golang 支持通过以函数名称(拼写 "func")开头的单行注释来记录函数。然而,有一个令人作呕的副作用:有多个单行注释不会产生一个用换行符分隔每行文本的 GoDoc
这里有一张图片来说明:
这是函数及其文档:
//GetFunctionName gets function name
// Parameters:
// - `i` : Function
// **NOTE** this func fails if `i` is a variable set to a func
// (they're called "anonymous functions" in JavaScript)
func GetFunctionName(i interface{}) string {
return runtime.FuncForPC(reflect.ValueOf(i).Pointer()).Name()
}
如何在生成的文档中插入换行符? (如果这是 Javadoc,我会像 <br>
这样一切都会很好)
插入一个空注释行,这将是一个新段落,这意味着它将在新行开始:
// GetFunctionName gets function name
//
// Parameters:
// - `i` : Function
//
// **NOTE** this func fails if `i` is a variable set to a func
// (they're called "anonymous functions" in JavaScript)
func GetFunctionName(i interface{}) string {
return runtime.FuncForPC(reflect.ValueOf(i).Pointer()).Name()
}
推荐博客post:Godoc: documenting Go code
相关栏目:
There are a few formatting rules that Godoc uses when converting comments to HTML:
- Subsequent lines of text are considered part of the same paragraph; you must leave a blank line to separate paragraphs.
- Pre-formatted text must be indented relative to the surrounding comment text (see gob's doc.go for an example).
- URLs will be converted to HTML links; no special markup is necessary.
我知道 Golang 支持通过以函数名称(拼写 "func")开头的单行注释来记录函数。然而,有一个令人作呕的副作用:有多个单行注释不会产生一个用换行符分隔每行文本的 GoDoc
这里有一张图片来说明:
这是函数及其文档:
//GetFunctionName gets function name
// Parameters:
// - `i` : Function
// **NOTE** this func fails if `i` is a variable set to a func
// (they're called "anonymous functions" in JavaScript)
func GetFunctionName(i interface{}) string {
return runtime.FuncForPC(reflect.ValueOf(i).Pointer()).Name()
}
如何在生成的文档中插入换行符? (如果这是 Javadoc,我会像 <br>
这样一切都会很好)
插入一个空注释行,这将是一个新段落,这意味着它将在新行开始:
// GetFunctionName gets function name
//
// Parameters:
// - `i` : Function
//
// **NOTE** this func fails if `i` is a variable set to a func
// (they're called "anonymous functions" in JavaScript)
func GetFunctionName(i interface{}) string {
return runtime.FuncForPC(reflect.ValueOf(i).Pointer()).Name()
}
推荐博客post:Godoc: documenting Go code
相关栏目:
There are a few formatting rules that Godoc uses when converting comments to HTML:
- Subsequent lines of text are considered part of the same paragraph; you must leave a blank line to separate paragraphs.
- Pre-formatted text must be indented relative to the surrounding comment text (see gob's doc.go for an example).
- URLs will be converted to HTML links; no special markup is necessary.