This commit is contained in:
Mark McGranaghan 2012-10-10 06:54:46 -07:00
parent 996fa26561
commit 0c1a7354e5
13 changed files with 38 additions and 46 deletions

View File

@ -1,35 +1,27 @@
## Go by Example
Content and toolchain source for the
[Go by Example](https://gobyexample.com) site.
Content and toolchain for [Go by Example](https://gobyexample.com).
### Overview
This repo contains:
The Go by Example site is built by extracting code &
comments from source files in `examples` and rendering
that data via the site `templates`. The programs
implementing this build process are in `tools`.
* `src`: Go and Bash source code for the site
* `meta`: metadata used to generate the site
* `tool`: toolchain used to generate the site
* `template`: HTML templates and CSS for the site
The site is built by extracting the code & comments from
the `.go` and `.sh` source files in `src` and rendering
that data according to `meta` and `templates` via programs
in `tool`.
The generated contented is served by the a
[lightweight server](https://github.com/mmcgrana/gobyexample-server).
The build process produces a directory of static files
suitable for serving by any modern HTTP server. The
Go by Example site is served by a
[lightweight Go server](https://github.com/mmcgrana/gobyexample-server).
### Usage
### Building
To validate the source, generate the site, and open the
home page in your browser:
To build the site to ./site:
```console
$ tool/build
$ open site/index.html
```
To build continuously in a loop:
@ -38,7 +30,7 @@ To build continuously in a loop:
$ tool/build-loop
```
Generation requires the [`pygmentize`](http://pygments.org/)
Builds require the [`pygmentize`](http://pygments.org/)
binary for syntax highlighting.
@ -54,7 +46,8 @@ $ SITEDIR = ../gobyexample-server/public tool/build
### License
This work is licensed under a [Creative Commons Attribution 3.0 Unported License](http://creativecommons.org/licenses/by/3.0/).
This work is licensed under a
[Creative Commons Attribution 3.0 Unported License](http://creativecommons.org/licenses/by/3.0/).
### Thanks

View File

@ -25,11 +25,10 @@
</p>
<p>
This is a hands-on introduction to Go. <em>Go by
Example</em> teaches Go with example programs,
since programmers learn to program by reading and
writing programs. Each example gives you a new
tool for writing your own Go code:
<em>Go by Example</em> is a hands-on introduction
to Go using annotated example programs. Check out
the <a href="/hello-world">first example</a> or
see the full list below.
</p>
<ul>

View File

@ -1,7 +0,0 @@
#!/bin/bash
set -e
tool/gofmt
tool/measure
tool/generate

View File

@ -1,3 +0,0 @@
#!/bin/bash
exec go run tool/generate.go

View File

@ -1,6 +0,0 @@
#!/bin/bash
set -e
set -o pipefail
ls tool/*.go examples/*/*.go | xargs gofmt -tabs=false -tabwidth=4 -w=true

View File

@ -1,3 +0,0 @@
#!/bin/bash
exec go run tool/measure.go

7
tools/build Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash
set -e
tools/gofmt
tools/measure
tools/generate

View File

@ -2,7 +2,7 @@
while :
do
tool/build
tools/build
if [ "$?" == "0" ]; then
echo "success"
else

3
tools/generate Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
exec go run tools/generate.go

6
tools/gofmt Executable file
View File

@ -0,0 +1,6 @@
#!/bin/bash
set -e
set -o pipefail
ls tools/*.go examples/*/*.go | xargs gofmt -tabs=false -tabwidth=4 -w=true

3
tools/measure Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
exec go run tools/measure.go