生成整个项目的godoc文档? [英] generate godoc documentation for an entire project?

查看:352
本文介绍了生成整个项目的godoc文档?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在与godoc搏斗,发现"go doc"更多地用于从命令行提供使用帮助,例如:

I've been wrestling with godoc and found that "go doc" is more for providing usage help from the command line for instance:

go doc -cmd -u

列出软件包注释和任何功能(或其他实体)

lists the package comment and any functions (or other entities)

go doc *function*

然后显示单个功能(或其他实体)的文档

then shows the documentation for an individual function (or other entity)

似乎有一个名为 godoc 的相关工具. godoc似乎还基于每个包和函数生成html. 例如

It seems there is a related tool called godoc. godoc also seems to generate html on a per package and function basis. E.g.

godoc -html hello

生成仅包含对stdout的包注释的html

Generates html containing the package comment only to stdout

godoc 是一个令人困惑的名称,因为我们也有 go doc

godoc is a really confusing name given we have go doc as well!

如何为整个项目创建静态文档?

这类似于 Godoc,为整个软件包创建html ,这可能被误解为询问软件包而不是项目的文档. 我想要一个可以在原则上包含许多软件包和应用程序的项目中使用的构建步骤.

This is similar to Godoc, create html for entire package which may have been misinterpreted as asking about documentation for packages rather than projects. I want a build step I can use in a project that may in principle contain many packages and apps.

推荐答案

即使使用godoc,有没有一种规范的方法可以生成供脱机使用的文档?

is there a canonical way to generate documentation for offline use even using godoc?

转到1.12版(2019年2月)在此方面更加清晰:

godocgo doc

在Go 1.12中,godoc不再具有命令行界面,而只是Web服务器.
用户应该使用go doc代替命令行帮助输出.

godoc and go doc

In Go 1.12, godoc no longer has a command-line interface and is only a web server.
Users should use go doc for command-line help output instead.

go doc现在支持-all标志,就像godoc命令行一样,这将导致它打印所有导出的API及其文档.

go doc now supports the -all flag, which will cause it to print all exported APIs and their documentation, as the godoc command line used to do.

cmd/doc:添加-all标志以打印软件包的所有文档

cmd/doc: add -all flag to print all documentation for package

与旧版godoc的符号不同,您需要-u标志才能看到未导出的符号.
这似乎是正确的行为:这是一致的.

Unlike the one for the old godoc, you need the -u flag to see unexported symbols.
This seems like the right behavior: it's consistent.

这篇关于生成整个项目的godoc文档?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆