当前位置: 首页>>代码示例>>Golang>>正文


Golang Package.IsHasExample方法代码示例

本文整理汇总了Golang中github.com/Unknwon/gowalker/hv.Package.IsHasExample方法的典型用法代码示例。如果您正苦于以下问题:Golang Package.IsHasExample方法的具体用法?Golang Package.IsHasExample怎么用?Golang Package.IsHasExample使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/Unknwon/gowalker/hv.Package的用法示例。


在下文中一共展示了Package.IsHasExample方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: ConvertDataFormat

// ConvertDataFormat converts data from database acceptable format to useable format.
func ConvertDataFormat(pdoc *hv.Package, pdecl *models.PkgDecl) error {
	if pdoc.PkgDecl == nil {
		pdoc.PkgDecl = &hv.PkgDecl{}
	}

	pdoc.JsNum = pdecl.JsNum
	pdoc.IsHasExport = pdecl.IsHasExport
	pdoc.IsHasConst = pdecl.IsHasConst
	pdoc.IsHasVar = pdecl.IsHasVar
	pdoc.IsHasExample = pdecl.IsHasExample
	pdoc.IsHasFile = pdecl.IsHasFile
	pdoc.IsHasSubdir = pdecl.IsHasSubdir

	// Imports.
	pdoc.Imports = strings.Split(pdecl.Imports, "|")
	if len(pdoc.Imports) == 1 && len(pdoc.Imports[0]) == 0 {
		// No import.
		pdoc.Imports = nil
	}
	return nil
}
开发者ID:John-Appleseed,项目名称:gowalker,代码行数:22,代码来源:home.go

示例2: renderDoc

func renderDoc(this *HomeRouter, pdoc *hv.Package, q, tag, docPath string) bool {
	this.Data["PkgFullIntro"] = pdoc.Doc

	var buf bytes.Buffer
	links := make([]*utils.Link, 0, len(pdoc.Types)+len(pdoc.Imports)+len(pdoc.TestImports)+
		len(pdoc.Funcs)+10)
	// Get all types, functions and import packages
	for _, t := range pdoc.Types {
		links = append(links, &utils.Link{
			Name:    t.Name,
			Comment: template.HTMLEscapeString(t.Doc),
		})
		buf.WriteString("'" + t.Name + "',")
	}

	for _, f := range pdoc.Funcs {
		links = append(links, &utils.Link{
			Name:    f.Name,
			Comment: template.HTMLEscapeString(f.Doc),
		})
		buf.WriteString("'" + f.Name + "',")
	}

	for _, t := range pdoc.Types {
		for _, f := range t.Funcs {
			links = append(links, &utils.Link{
				Name:    f.Name,
				Comment: template.HTMLEscapeString(f.Doc),
			})
			buf.WriteString("'" + f.Name + "',")
		}

		for _, m := range t.Methods {
			buf.WriteString("'" + t.Name + "_" + m.Name + "',")
		}
	}

	// Ignore C.
	for _, v := range append(pdoc.Imports, pdoc.TestImports...) {
		if v != "C" {
			links = append(links, &utils.Link{
				Name: path.Base(v) + ".",
				Path: v,
			})
		}
	}

	// Set exported objects type-ahead.
	exportDataSrc := buf.String()
	if len(exportDataSrc) > 0 {
		pdoc.IsHasExport = true
		this.Data["IsHasExports"] = true
		exportDataSrc = exportDataSrc[:len(exportDataSrc)-1]
		this.Data["ExportDataSrc"] = "<script>$('.search-export').typeahead({local: [" +
			exportDataSrc + "],limit: 10});</script>"
	}

	pdoc.UserExamples = getUserExamples(pdoc.ImportPath)

	pdoc.IsHasConst = len(pdoc.Consts) > 0
	pdoc.IsHasVar = len(pdoc.Vars) > 0
	if len(pdoc.Examples)+len(pdoc.UserExamples) > 0 {
		pdoc.IsHasExample = true
		this.Data["IsHasExample"] = pdoc.IsHasExample
		this.Data["Examples"] = append(pdoc.Examples, pdoc.UserExamples...)
	}

	// Commented and total objects number.
	var comNum, totalNum int

	// Constants.
	this.Data["IsHasConst"] = pdoc.IsHasConst
	this.Data["Consts"] = pdoc.Consts
	for i, v := range pdoc.Consts {
		if len(v.Doc) > 0 {
			buf.Reset()
			godoc.ToHTML(&buf, v.Doc, nil)
			v.Doc = buf.String()
		}
		buf.Reset()
		v.Decl = template.HTMLEscapeString(v.Decl)
		v.Decl = strings.Replace(v.Decl, "&#34;", "\"", -1)
		utils.FormatCode(&buf, &v.Decl, links)
		v.FmtDecl = buf.String()
		pdoc.Consts[i] = v
	}

	// Variables.
	this.Data["IsHasVar"] = pdoc.IsHasVar
	this.Data["Vars"] = pdoc.Vars
	for i, v := range pdoc.Vars {
		if len(v.Doc) > 0 {
			buf.Reset()
			godoc.ToHTML(&buf, v.Doc, nil)
			v.Doc = buf.String()
		}
		buf.Reset()
		utils.FormatCode(&buf, &v.Decl, links)
		v.FmtDecl = buf.String()
		pdoc.Vars[i] = v
//.........这里部分代码省略.........
开发者ID:John-Appleseed,项目名称:gowalker,代码行数:101,代码来源:home.go


注:本文中的github.com/Unknwon/gowalker/hv.Package.IsHasExample方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。