Merge branch 'bug/2-automatic-exclusion' into 'master'
partial fix of #2: automatic exclusion See merge request tslocum/godoc-static!1
This commit is contained in:
commit
23cd784460
19
main.go
19
main.go
|
@ -69,6 +69,21 @@ func main() {
|
|||
}
|
||||
}
|
||||
|
||||
func filterPkgsWithExcludes(pkgs []string) []string {
|
||||
excludePackagesSplit := strings.Split(excludePackages, " ")
|
||||
var tmpPkgs []string
|
||||
PACKAGEINDEX:
|
||||
for _, pkg := range pkgs {
|
||||
for _, excludePackage := range excludePackagesSplit {
|
||||
if strings.Contains(pkg, "\\") || strings.Contains(pkg, "testdata") || strings.Contains(pkg, "internal") || pkg == "cmd" || pkg == excludePackage || strings.HasPrefix(pkg, excludePackage+"/") {
|
||||
continue PACKAGEINDEX
|
||||
}
|
||||
}
|
||||
tmpPkgs = append(tmpPkgs, pkg)
|
||||
}
|
||||
return tmpPkgs
|
||||
}
|
||||
|
||||
func getTmpDir() string {
|
||||
tmpDir := os.TempDir()
|
||||
if _, err := os.Stat(tmpDir); os.IsNotExist(err) {
|
||||
|
@ -272,7 +287,7 @@ func run() error {
|
|||
pkgs = append(pkgs, strings.Join(subPkgs[0:i+1], "/"))
|
||||
}
|
||||
}
|
||||
pkgs = uniqueStrings(pkgs)
|
||||
pkgs = filterPkgsWithExcludes(uniqueStrings(pkgs))
|
||||
|
||||
sort.Slice(pkgs, func(i, j int) bool {
|
||||
return strings.ToLower(pkgs[i]) < strings.ToLower(pkgs[j])
|
||||
|
@ -355,6 +370,8 @@ func run() error {
|
|||
return fmt.Errorf("failed to make directory lib: %s", err)
|
||||
}
|
||||
|
||||
filterPkgs = filterPkgsWithExcludes(filterPkgs)
|
||||
|
||||
for _, pkg := range filterPkgs {
|
||||
if verbose {
|
||||
log.Printf("Copying %s sources...", pkg)
|
||||
|
|
8
page.go
8
page.go
|
@ -224,15 +224,7 @@ func writeIndex(buf *bytes.Buffer, pkgs []string, filterPkgs []string) error {
|
|||
var padding int
|
||||
var lastPkg string
|
||||
var pkgBuf bytes.Buffer
|
||||
excludePackagesSplit := strings.Split(excludePackages, " ")
|
||||
PACKAGEINDEX:
|
||||
for _, pkg := range pkgs {
|
||||
for _, excludePackage := range excludePackagesSplit {
|
||||
if pkg == excludePackage || strings.HasPrefix(pkg, excludePackage+"/") {
|
||||
continue PACKAGEINDEX
|
||||
}
|
||||
}
|
||||
|
||||
pkgBuf.Reset()
|
||||
cmd := exec.Command("go", "list", "-find", "-f", `{{ .Doc }}`, pkg)
|
||||
cmd.Dir = os.TempDir()
|
||||
|
|
Loading…
Reference in New Issue