~ubuntu-branches/ubuntu/vivid/golang/vivid

« back to all changes in this revision

Viewing changes to src/cmd/godoc/template.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:
3
3
// license that can be found in the LICENSE file.
4
4
 
5
5
// Template support for writing HTML documents.
6
 
// Documents that include Template: true in their 
 
6
// Documents that include Template: true in their
7
7
// metadata are executed as input to text/template.
8
8
//
9
9
// This file defines functions for those templates to invoke.
57
57
        return string(file)
58
58
}
59
59
 
60
 
// format returns a textual representation of the arg, formatted according to its nature.
61
 
func format(arg interface{}) string {
 
60
// stringFor returns a textual representation of the arg, formatted according to its nature.
 
61
func stringFor(arg interface{}) string {
62
62
        switch arg := arg.(type) {
63
63
        case int:
64
64
                return fmt.Sprintf("%d", arg)
87
87
                // text is already whole file.
88
88
                command = fmt.Sprintf("code %q", file)
89
89
        case 1:
90
 
                command = fmt.Sprintf("code %q %s", file, format(arg[0]))
 
90
                command = fmt.Sprintf("code %q %s", file, stringFor(arg[0]))
91
91
                text = oneLine(file, text, arg[0])
92
92
        case 2:
93
 
                command = fmt.Sprintf("code %q %s %s", file, format(arg[0]), format(arg[1]))
 
93
                command = fmt.Sprintf("code %q %s %s", file, stringFor(arg[0]), stringFor(arg[1]))
94
94
                text = multipleLines(file, text, arg[0], arg[1])
95
95
        default:
96
96
                return "", fmt.Errorf("incorrect code invocation: code %q %q", file, arg)