Skip to content
This repository was archived by the owner on Jul 29, 2021. It is now read-only.

Commit 7eb68b1

Browse files
committed
wip
1 parent c0252ac commit 7eb68b1

File tree

4 files changed

+41
-7
lines changed

4 files changed

+41
-7
lines changed

examples/build/README.md

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,16 @@ Here's an example directory layout:
5656
bar.a (installed package object)
5757

5858
### Build Constraints
59-
A build constraint is a line comment beginning with the directive +build
59+
A build constraint, also known as a build tag, is a line comment that begins
60+
61+
62+
// +build
63+
6064
that lists the conditions under which a file should be included in the package.
6165
Constraints may appear in any kind of source file (not just Go), but
6266
they must appear near the top of the file, preceded
63-
only by blank lines and other line comments.
67+
only by blank lines and other line comments. These rules mean that in Go
68+
files a build constraint must appear before the package clause.
6469

6570
To distinguish build constraints from package documentation, a series of
6671
build constraints must be followed by a blank line.
@@ -236,7 +241,10 @@ A Context specifies the supporting context for a build.
236241

237242

238243

239-
<pre>var Default Context = defaultContext()</pre>
244+
``` go
245+
var Default Context = defaultContext()
246+
```
247+
240248
Default is the default Context for builds.
241249
It uses the GOARCH, GOOS, GOROOT, and GOPATH environment variables
242250
if set, or else the compiled code's GOARCH, GOOS, and GOROOT.
@@ -309,7 +317,8 @@ An ImportMode controls the behavior of the Import method.
309317

310318

311319

312-
<pre>const (
320+
``` go
321+
const (
313322
// If FindOnly is set, Import stops after locating the directory
314323
// that should contain the sources for a package. It does not
315324
// read any files in the directory.
@@ -318,7 +327,9 @@ An ImportMode controls the behavior of the Import method.
318327
// If AllowBinary is set, Import can be satisfied by a compiled
319328
// package object without corresponding sources.
320329
AllowBinary
321-
)</pre>
330+
)
331+
```
332+
322333

323334

324335

examples/martini/README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,24 @@ NewResponseWriter creates a ResponseWriter that wraps an http.ResponseWriter
260260

261261

262262

263+
## type ReturnHandler
264+
<pre>type ReturnHandler func(http.ResponseWriter, []reflect.Value)</pre>
265+
ReturnHandler is a service that Martini provides that is called
266+
when a route handler returns something. The ReturnHandler is
267+
responsible for writing to the ResponseWriter based on the values
268+
that are passed into this function.
269+
270+
271+
272+
273+
274+
275+
276+
277+
278+
279+
280+
263281
## type Route
264282
<pre>type Route interface {
265283
// URLWith returns a rendering of the Route's url with the given string params.

main.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ var (
5858
"comment_md": comment_mdFunc,
5959
"base": path.Base,
6060
"md": mdFunc,
61+
"pre": preFunc,
6162
}
6263
)
6364

@@ -75,6 +76,10 @@ func mdFunc(text string) string {
7576
return text
7677
}
7778

79+
func preFunc(text string) string {
80+
return "``` go\n"+text+"\n```\n"
81+
}
82+
7883
func readTemplate(name, data string) *template.Template {
7984
// be explicit with errors (for app engine use)
8085
t, err := template.New(name).Funcs(pres.FuncMap()).Funcs(funcs).Parse(string(data))

template.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ var pkgTemplate = `{{with .PDoc}}{{if $.IsMain}}
3232
<pre>{{node $ .Decl}}</pre>
3333
{{comment_md .Doc}}
3434
35-
{{range .Consts}}<pre>{{node $ .Decl}}</pre>
35+
{{range .Consts}}{{node $ .Decl | pre }}
3636
{{comment_md .Doc}}{{end}}
3737
38-
{{range .Vars}}<pre>{{node $ .Decl}}</pre>
38+
{{range .Vars}}{{node $ .Decl | pre }}
3939
{{comment_md .Doc}}{{end}}
4040
4141
{{example_html $ $tname}}

0 commit comments

Comments
 (0)