Ejemplo n.º 1
0
func untangleDoc(dpkg *doc.Package) {
	for _, t := range dpkg.Types {
		dpkg.Consts = append(dpkg.Consts, t.Consts...)
		t.Consts = nil
		dpkg.Vars = append(dpkg.Vars, t.Vars...)
		t.Vars = nil
		dpkg.Funcs = append(dpkg.Funcs, t.Funcs...)
		t.Funcs = nil
	}
}
Ejemplo n.º 2
0
func untangleDoc(pkg *godoc.Package) {
	for _, t := range pkg.Types {
		pkg.Consts = append(pkg.Consts, t.Consts...)
		t.Consts = nil
		pkg.Vars = append(pkg.Vars, t.Vars...)
		t.Vars = nil
		pkg.Funcs = append(pkg.Funcs, t.Funcs...)
		t.Funcs = nil
	}
}
Ejemplo n.º 3
0
func removeAssociations(dpkg *doc.Package) {
	for _, t := range dpkg.Types {
		dpkg.Funcs = append(dpkg.Funcs, t.Funcs...)
		t.Funcs = nil
	}
	sort.Sort(byFuncName(dpkg.Funcs))
}
Ejemplo n.º 4
0
func trPackage(lang, importPath string, pkg *doc.Package) *doc.Package {
	key := mapKey(lang, pkg.ImportPath, __pkg__)
	localPkg, _ := pkgDocTable[key]
	if localPkg == nil {
		return nil
	}

	pkg.Name = localPkg.Name
	pkg.Doc = localPkg.Doc

	for k, _ := range pkg.Notes {
		if notes, _ := localPkg.Notes[k]; notes != nil {
			pkg.Notes[k] = notes
		}
	}

	for i := 0; i < len(pkg.Consts); i++ {
		key := mapKey(lang, pkg.ImportPath, pkg.Consts[i].Names[0])
		if s, _ := pkgDocIndexTable[key]; s != "" {
			pkg.Consts[i].Doc = s
		}
	}
	for i := 0; i < len(pkg.Types); i++ {
		key := mapKey(lang, pkg.ImportPath, pkg.Types[i].Name)
		if s, _ := pkgDocIndexTable[key]; s != "" {
			pkg.Types[i].Doc = s
		}

		for j := 0; j < len(pkg.Types[i].Consts); j++ {
			key := mapKey(lang, pkg.ImportPath, pkg.Types[i].Consts[j].Names[0])
			if s, _ := pkgDocIndexTable[key]; s != "" {
				pkg.Types[i].Consts[j].Doc = s
			}
		}
		for j := 0; j < len(pkg.Types[i].Vars); j++ {
			key := mapKey(lang, pkg.ImportPath, pkg.Types[i].Vars[j].Names[0])
			if s, _ := pkgDocIndexTable[key]; s != "" {
				pkg.Types[i].Vars[j].Doc = s
			}
		}
		for j := 0; j < len(pkg.Types[i].Funcs); j++ {
			key := mapKey(lang, pkg.ImportPath, pkg.Types[i].Funcs[j].Name)
			if s, _ := pkgDocIndexTable[key]; s != "" {
				pkg.Types[i].Funcs[j].Doc = s
			}
		}
		for j := 0; j < len(pkg.Types[i].Methods); j++ {
			id := methodId(pkg.Types[i].Name, pkg.Types[i].Methods[j].Name)
			key := mapKey(lang, pkg.ImportPath, id)
			if s, _ := pkgDocIndexTable[key]; s != "" {
				pkg.Types[i].Methods[j].Doc = s
			}
		}
	}
	for i := 0; i < len(pkg.Vars); i++ {
		key := mapKey(lang, pkg.ImportPath, pkg.Vars[i].Names[0])
		if s, _ := pkgDocIndexTable[key]; s != "" {
			pkg.Vars[i].Doc = s
		}
	}
	for i := 0; i < len(pkg.Funcs); i++ {
		key := mapKey(lang, pkg.ImportPath, pkg.Funcs[i].Name)
		if s, _ := pkgDocIndexTable[key]; s != "" {
			pkg.Funcs[i].Doc = s
		}
	}
	return pkg
}