~ubuntu-branches/ubuntu/utopic/golang/utopic

« back to all changes in this revision

Viewing changes to src/cmd/godoc/dirtrees.go

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2013-08-20 14:06:23 UTC
  • mfrom: (14.1.23 saucy-proposed)
  • Revision ID: package-import@ubuntu.com-20130820140623-b414jfxi3m0qkmrq
Tags: 2:1.1.2-2ubuntu1
* Merge from Debian unstable (LP: #1211749, #1202027). Remaining changes:
  - 016-armhf-elf-header.patch: Use correct ELF header for armhf binaries.
  - d/control,control.cross: Update Breaks/Replaces for Ubuntu
    versions to ensure smooth upgrades, regenerate control file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
74
74
        // determine number of subdirectories and if there are package files
75
75
        ndirs := 0
76
76
        hasPkgFiles := false
77
 
        var synopses [4]string // prioritized package documentation (0 == highest priority)
 
77
        var synopses [3]string // prioritized package documentation (0 == highest priority)
78
78
        for _, d := range list {
79
79
                switch {
80
80
                case isPkgDir(d):
95
95
                                                switch file.Name.Name {
96
96
                                                case name:
97
97
                                                        i = 0 // normal case: directory name matches package name
98
 
                                                case fakePkgName:
99
 
                                                        i = 1 // synopses for commands
100
98
                                                case "main":
101
 
                                                        i = 2 // directory contains a main package
 
99
                                                        i = 1 // directory contains a main package
102
100
                                                default:
103
 
                                                        i = 3 // none of the above
 
101
                                                        i = 2 // none of the above
104
102
                                                }
105
103
                                                if 0 <= i && i < len(synopses) && synopses[i] == "" {
106
104
                                                        synopses[i] = doc.Synopsis(file.Doc.Text())
229
227
}
230
228
 
231
229
func splitPath(p string) []string {
232
 
        if strings.HasPrefix(p, "/") {
233
 
                p = p[1:]
234
 
        }
 
230
        p = strings.TrimPrefix(p, "/")
235
231
        if p == "" {
236
232
                return nil
237
233
        }
264
260
        Height   int    // = DirList.MaxHeight - Depth, > 0
265
261
        Path     string // directory path; includes Name, relative to DirList root
266
262
        Name     string // directory name
267
 
        HasPkg   bool   // true if the directory contains at least one package 
 
263
        HasPkg   bool   // true if the directory contains at least one package
268
264
        Synopsis string // package documentation, if any
269
265
}
270
266
 
310
306
                // the path is relative to root.Path - remove the root.Path
311
307
                // prefix (the prefix should always be present but avoid
312
308
                // crashes and check)
313
 
                path := d.Path
314
 
                if strings.HasPrefix(d.Path, root.Path) {
315
 
                        path = d.Path[len(root.Path):]
316
 
                }
 
309
                path := strings.TrimPrefix(d.Path, root.Path)
317
310
                // remove leading separator if any - path must be relative
318
 
                if len(path) > 0 && path[0] == '/' {
319
 
                        path = path[1:]
320
 
                }
 
311
                path = strings.TrimPrefix(path, "/")
321
312
                p.Path = path
322
313
                p.Name = d.Name
323
314
                p.HasPkg = d.HasPkg