Separate license and version from docs

This commit is contained in:
Hajime Hoshi 2014-12-29 23:16:02 +09:00
parent b77181e37a
commit 075c67a84c
6 changed files with 60 additions and 34 deletions

View File

@ -23,27 +23,37 @@ import (
"os" "os"
"path/filepath" "path/filepath"
"regexp" "regexp"
"strings"
) )
const ( const (
outputPath = "public/index.html" outputPath = "public/index.html"
templatePath = "index_tmpl.html" templatePath = "index.tmpl.html"
) )
// TODO: License should be on another file var license = ""
const license = `Copyright 2014 Hajime Hoshi
Licensed under the Apache License, Version 2.0 (the "License"); func init() {
you may not use this file except in compliance with the License. b, err := ioutil.ReadFile("../license.txt")
You may obtain a copy of the License at if err != nil {
panic(err)
}
license = string(b)
http://www.apache.org/licenses/LICENSE-2.0 // TODO: Year check
}
Unless required by applicable law or agreed to in writing, software var stableVersion = ""
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. var devVersion = ""
See the License for the specific language governing permissions and
limitations under the License.` func init() {
b, err := ioutil.ReadFile("../version.txt")
if err != nil {
panic(err)
}
devVersion = string(b)
}
func comment(text string) template.HTML { func comment(text string) template.HTML {
// TODO: text should be escaped // TODO: text should be escaped
@ -86,6 +96,17 @@ func (e *example) Source() string {
return str return str
} }
func versions() string {
vers := []string{}
if stableVersion != "" {
vers = append(vers, "Stable: "+stableVersion)
}
if devVersion != "" {
vers = append(vers, "Development: "+devVersion)
}
return strings.Join(vers, ", ")
}
func main() { func main() {
f, err := os.Create(outputPath) f, err := os.Create(outputPath)
if err != nil { if err != nil {
@ -102,6 +123,7 @@ func main() {
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
examples := []example{ examples := []example{
{Name: "blocks"}, {Name: "blocks"},
{Name: "hue"}, {Name: "hue"},
@ -111,6 +133,7 @@ func main() {
} }
data := map[string]interface{}{ data := map[string]interface{}{
"License": license, "License": license,
"Versions": versions(),
"Examples": examples, "Examples": examples,
} }
if err := t.Funcs(funcs).Execute(f, data); err != nil { if err := t.Funcs(funcs).Execute(f, data); err != nil {

View File

@ -19,9 +19,9 @@ table.examples td.code pre {
height: 240px; height: 240px;
overflow: auto; overflow: auto;
} }
</style> </style>
<h1>Ebiten (海老天) v1.0.0-alpha</h1> <h1>Ebiten (海老天)</h1>
<p>{{.Versions}}</p>
<ul> <ul>
<li>A simple SNES-like 2D game library in Go</li> <li>A simple SNES-like 2D game library in Go</li>
<li>Works on <li>Works on

View File

@ -11,7 +11,8 @@ Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License.--> limitations under the License.
-->
<link rel="shortcut icon" href="./favicon.png" type="image/png" > <link rel="shortcut icon" href="./favicon.png" type="image/png" >
<link rel="icon" href="./favicon.png" type="image/png" > <link rel="icon" href="./favicon.png" type="image/png" >
<title>Ebiten - A simple SNES-like 2D game library in Go</title> <title>Ebiten - A simple SNES-like 2D game library in Go</title>
@ -31,9 +32,10 @@ table.examples td.code pre {
height: 240px; height: 240px;
overflow: auto; overflow: auto;
} }
</style> </style>
<h1>Ebiten (海老天) v1.0.0-alpha</h1> <h1>Ebiten (海老天)</h1>
<p>Development: 1.0.0-alpha
</p>
<ul> <ul>
<li>A simple SNES-like 2D game library in Go</li> <li>A simple SNES-like 2D game library in Go</li>
<li>Works on <li>Works on
@ -299,4 +301,5 @@ Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an &#34;AS IS&#34; BASIS, distributed under the License is distributed on an &#34;AS IS&#34; BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License.</code></pre> limitations under the License.
</code></pre>

13
license.txt Normal file
View File

@ -0,0 +1,13 @@
Copyright 2014 Hajime Hoshi
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@ -1,4 +1,4 @@
# Ebiten (海老天) v1.0.0-alpha # Ebiten (海老天)
[![Build Status](https://travis-ci.org/hajimehoshi/ebiten.svg?branch=master)](https://travis-ci.org/hajimehoshi/ebiten) [![Build Status](https://travis-ci.org/hajimehoshi/ebiten.svg?branch=master)](https://travis-ci.org/hajimehoshi/ebiten)
@ -53,18 +53,4 @@
## License ## License
``` See license.txt.
Copyright 2014 Hajime Hoshi
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
```

1
version.txt Normal file
View File

@ -0,0 +1 @@
1.0.0-alpha