]> Cypherpunks repositories - gostls13.git/commitdiff
go/doc: document the conditions where examples are "playable"
authorAndrew Gerrand <adg@golang.org>
Tue, 18 Feb 2014 04:53:22 +0000 (15:53 +1100)
committerAndrew Gerrand <adg@golang.org>
Tue, 18 Feb 2014 04:53:22 +0000 (15:53 +1100)
LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/64910043

src/pkg/go/doc/example.go

index 2358ed38902f36f9f4758f27b788a6bc08e6eeda..f4ce9f654154247ed6e16eb3ace05593fe953880 100644 (file)
@@ -32,6 +32,17 @@ type Example struct {
 
 // Examples returns the examples found in the files, sorted by Name field.
 // The Order fields record the order in which the examples were encountered.
+//
+// Playable Examples must be in a package whose name ends in "_test".
+// An Example is "playable" (the Play field is non-nil) in either of these
+// circumstances:
+//   - The example function is self-contained: the function references only
+//     identifiers from other packages (or predeclared identifiers, such as
+//     "int") and the test file does not include a dot import.
+//   - The entire test file is the example: the file contains exactly one
+//     example function, zero test or benchmark functions, and at least one
+//     top-level function, type, variable, or constant declaration other
+//     than the example function.
 func Examples(files ...*ast.File) []*Example {
        var list []*Example
        for _, file := range files {