如何只让go文档的一部分出现在godocs中
How to only make part of a go document show up in godocs
我正在使用 godocs 来记录我用 go/golang 编写的 API 并且我正在使用 godocs 来记录它,因为我生成了整个 [=14] 的 HTML 页面=] 文件,其中包含用于创建我的 API 的所有函数。但是,我不想显示有关我的所有辅助函数的信息,我只想显示有关文件中某些函数的 header 信息。有没有办法只允许文件中的某些函数成为文档的一部分,或者我是否必须为我的所有辅助函数创建另一个文件?
现在我正在本地端口 8000 上测试它:godoc -http=:8000
命令godoc及其堂兄go doc的default行为,显示包 导出声明 的文档。奇怪的是,我没有找到 link 的简单权威来源来明确记录这一事实,但是在改变默认行为的命令中引用了该事实的推论,例如来自 godoc package's documentation:
The presentation mode of web pages served by godoc can be controlled with the "m" URL parameter; it accepts a comma-separated list of flag names as value:
...
For instance, http://golang.org/pkg/math/big/?m=all,text shows the documentation for all (not just the exported) declarations of package big, in textual form (as it would appear when using godoc from the command line: "godoc -src math/big .*").
以及 https://golang.org/src/go/doc/doc.go 处的源代码,其中包括:
81 const (
82 // extract documentation for all package-level declarations,
83 // not just exported ones
84 AllDecls Mode = 1 << iota
...
89 )
并且 https://golang.org/src/go/doc/exports.go 记录一个函数:
241 // fileExports removes unexported declarations from src in place.
最后 运行 go doc -h
在终端中显示一个标志:
-u 显示未导出的符号以及导出的符号。
我正在使用 godocs 来记录我用 go/golang 编写的 API 并且我正在使用 godocs 来记录它,因为我生成了整个 [=14] 的 HTML 页面=] 文件,其中包含用于创建我的 API 的所有函数。但是,我不想显示有关我的所有辅助函数的信息,我只想显示有关文件中某些函数的 header 信息。有没有办法只允许文件中的某些函数成为文档的一部分,或者我是否必须为我的所有辅助函数创建另一个文件?
现在我正在本地端口 8000 上测试它:godoc -http=:8000
命令godoc及其堂兄go doc的default行为,显示包 导出声明 的文档。奇怪的是,我没有找到 link 的简单权威来源来明确记录这一事实,但是在改变默认行为的命令中引用了该事实的推论,例如来自 godoc package's documentation:
The presentation mode of web pages served by godoc can be controlled with the "m" URL parameter; it accepts a comma-separated list of flag names as value:
...
For instance, http://golang.org/pkg/math/big/?m=all,text shows the documentation for all (not just the exported) declarations of package big, in textual form (as it would appear when using godoc from the command line: "godoc -src math/big .*").
以及 https://golang.org/src/go/doc/doc.go 处的源代码,其中包括:
81 const (
82 // extract documentation for all package-level declarations,
83 // not just exported ones
84 AllDecls Mode = 1 << iota
...
89 )
并且 https://golang.org/src/go/doc/exports.go 记录一个函数:
241 // fileExports removes unexported declarations from src in place.
最后 运行 go doc -h
在终端中显示一个标志:
-u 显示未导出的符号以及导出的符号。