如何使用godoc创建文档? [英] How to create document with godoc?

查看:70
本文介绍了如何使用godoc创建文档?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在应用程序中对函数和程序包创建了简单的注释我尝试了godoc -html和我的应用程序以及结果

I create simple go with comment in the application to the function and the package I tried godoc -html and my application and the result

<!--
    Copyright 2009 The Go Authors. All rights reserved.
    Use of this source code is governed by a BSD-style
    license that can be found in the LICENSE file.
-->

<!--
        Note: Static (i.e., not template-generated) href and id
        attributes start with "pkg-" to make it impossible for
        them to conflict with generated attributes (some of which
        correspond to Go identifiers).
-->

        <script type='text/javascript'>
        document.ANALYSIS_DATA = ;
        document.CALLGRAPH = ;
        </script>



                <p>
Package main provides logic ...
</p>

为什么我没有看到其他文件?以及为什么软件包的< p> 带有空格

why I didn't see my other document ? and why the <p> for the package has spaces

// Package main provides logic.
package main
import (

}

some types.....

func main() {
}

// doLogic .....
// .....
// ....
func (sm *myI) doLogic (s *myStruct) bool {

}

推荐答案

默认情况下未记录未导出的标识符.至少设置?m = all 才能看到它们:

Unexported identifiers are not documented by default. Set at least ?m=all to see them:

可以使用"m" URL参数来控制godoc服务的网页的显示方式;它接受以逗号分隔的标志名称列表作为值:

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:

all     show documentation for all declarations, not just the exported ones
methods show all embedded methods, not just those of unexported anonymous fields
src     show the original source code rather then the extracted documentation

例如, https://golang.org/pkg/math/big/?m = all 显示了big包的所有(不仅是导出的)声明的文档. https://godoc.org/golang.org/x/tools/cmd/godoc

For instance, https://golang.org/pkg/math/big/?m=all shows the documentation for all (not just the exported) declarations of package big. https://godoc.org/golang.org/x/tools/cmd/godoc

这篇关于如何使用godoc创建文档?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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