本文整理汇总了Golang中github.com/Unknwon/gowalker/hv.Package.ViewDirPath方法的典型用法代码示例。如果您正苦于以下问题:Golang Package.ViewDirPath方法的具体用法?Golang Package.ViewDirPath怎么用?Golang Package.ViewDirPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/Unknwon/gowalker/hv.Package
的用法示例。
在下文中一共展示了Package.ViewDirPath方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: generatePage
// generatePage genarates documentation page for project.
// it returns false when it's a invaild(empty) project.
func generatePage(this *HomeRouter, pdoc *hv.Package, q, tag string) bool {
docPath := pdoc.ImportPath + utils.TagSuffix("-", tag)
if pdoc.IsNeedRender {
if !renderDoc(this, pdoc, q, tag, docPath) {
return false
}
} else {
pdecl, err := models.LoadProject(pdoc.Id, tag)
if err != nil {
beego.Error("HomeController.generatePage ->", err)
return false
}
err = ConvertDataFormat(pdoc, pdecl)
if err != nil {
beego.Error("HomeController.generatePage -> ConvertDataFormat:", err)
return false
}
this.Data["UtcTime"] = time.Unix(pdoc.Created, 0).UTC()
this.Data["TimeSince"] = calTimeSince(time.Unix(pdoc.Created, 0))
}
// Add create time for JS files' link to prevent cache in case the page is recreated.
this.Data["Timestamp"] = pdoc.Created
proName := path.Base(pdoc.ImportPath)
if i := strings.Index(proName, "?"); i > -1 {
proName = proName[:i]
}
this.Data["ProName"] = proName
// Check if need to show Hacker View.
f := this.Input().Get("f")
hvJs := utils.HvJsPath + pdoc.ImportPath + "/" + f + ".js"
if len(tag) == 0 && (pdoc.IsCmd || pdoc.IsGoRepo || pdoc.IsGoSubrepo) &&
len(f) > 0 && com.IsExist("."+hvJs) {
this.TplNames = "hv.html"
var query string
if i := strings.Index(pdoc.ViewDirPath, "?"); i > -1 {
query = pdoc.ViewDirPath[i:]
pdoc.ViewDirPath = pdoc.ViewDirPath[:i]
}
this.Data["ViewDirPath"] = strings.TrimSuffix(pdoc.ViewDirPath, "/")
this.Data["Query"] = query
this.Data["FileName"] = f
this.Data["HvJs"] = hvJs
return true
}
// Set properties.
this.TplNames = "docs.html"
this.Data["PkgDesc"] = pdoc.Synopsis
this.Data["Pid"] = pdoc.Id
this.Data["IsGoRepo"] = pdoc.IsGoRepo
if len(tag) == 0 && (pdoc.IsCmd || pdoc.IsGoRepo || pdoc.IsGoSubrepo) {
this.Data["IsHasHv"] = true
}
// Refresh (within 10 seconds).
this.Data["IsRefresh"] = time.Unix(pdoc.Created, 0).Add(10 * time.Second).After(time.Now())
this.Data["VCS"] = pdoc.Vcs
proPath := pdoc.ProjectPath
// Introduction.
this.Data["ImportPath"] = pdoc.ImportPath
// README.
lang := this.Data["Lang"].(string)[:2]
readmePath := utils.DocsJsPath + docPath + "_RM_" + lang + ".js"
if com.IsFile("." + readmePath) {
this.Data["IsHasReadme"] = true
this.Data["PkgDocPath"] = readmePath
}
// Index.
this.Data["IsHasExports"] = pdoc.IsHasExport
this.Data["IsHasConst"] = pdoc.IsHasConst
this.Data["IsHasVar"] = pdoc.IsHasVar
if !pdoc.IsCmd {
this.Data["IsHasExams"] = pdoc.IsHasExample
tags := strings.Split(pdoc.Tags, "|||")
// Tags.
if len(tag) == 0 {
tag = tags[0]
}
this.Data["CurTag"] = tag
this.Data["Tags"] = tags
if strings.HasPrefix(proPath, "github.com") {
offset := 6
if len(tag) == 0 {
//.........这里部分代码省略.........