From 6f5d106b379f4c518b5e8e81b1ac138e8bc4bee8 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sun, 28 Dec 2014 00:26:33 +0900 Subject: [PATCH] Add _docs --- _docs/gen.go | 102 ++++++++++++++++++++++++++++++++++++++++ _docs/generate.go | 17 +++++++ _docs/index_tmpl.html | 3 ++ _docs/public/index.html | 99 +++++++++++++++++++++++++++++++++++++- 4 files changed, 220 insertions(+), 1 deletion(-) create mode 100644 _docs/gen.go create mode 100644 _docs/generate.go create mode 100644 _docs/index_tmpl.html diff --git a/_docs/gen.go b/_docs/gen.go new file mode 100644 index 000000000..b454d5a25 --- /dev/null +++ b/_docs/gen.go @@ -0,0 +1,102 @@ +// 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. + +// +build ignore + +package main + +import ( + "github.com/google/go-github/github" + "html/template" + "io/ioutil" + "log" + "os" + "path/filepath" +) + +const ( + outputPath = "public/index.html" + readMePath = "../readme.md" + templatePath = "index_tmpl.html" +) + +// TODO: License should be on another file +const license = `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.` + +func parseMarkdown(path string) (string, error) { + md, err := ioutil.ReadFile(path) + if err != nil { + return "", err + } + + client := github.NewClient(nil) + html, _, err := client.Markdown(string(md), nil) + if err != nil { + return "", err + } + + return html, nil +} + +func comment(text string) template.HTML { + // TODO: text should be escaped + return template.HTML("") +} + +func safeHTML(text string) template.HTML { + return template.HTML(text) +} + +func main() { + f, err := os.Create(outputPath) + if err != nil { + log.Fatal(err) + } + defer f.Close() + + // Parse readme.md + readme, err := parseMarkdown(readMePath) + if err != nil { + log.Fatal(err) + } + + funcs := template.FuncMap{ + "comment": comment, + "safeHTML": safeHTML, + } + name := filepath.Base(templatePath) + t, err := template.New(name).Funcs(funcs).ParseFiles(templatePath) + if err != nil { + panic(err) + } + data := map[string]string{ + "License": license, + "ReadMe": readme, + } + if err := t.Funcs(funcs).Execute(f, data); err != nil { + log.Fatal(err) + } +} diff --git a/_docs/generate.go b/_docs/generate.go new file mode 100644 index 000000000..a1fc50754 --- /dev/null +++ b/_docs/generate.go @@ -0,0 +1,17 @@ +// 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. + +package docs + +//go:generate go run gen.go diff --git a/_docs/index_tmpl.html b/_docs/index_tmpl.html new file mode 100644 index 000000000..f6bad5415 --- /dev/null +++ b/_docs/index_tmpl.html @@ -0,0 +1,3 @@ + +{{ comment .License }} +{{ safeHTML .ReadMe }} diff --git a/_docs/public/index.html b/_docs/public/index.html index e9bc11025..fc38584fd 100644 --- a/_docs/public/index.html +++ b/_docs/public/index.html @@ -1 +1,98 @@ -hogehoge + + +

+Ebiten (海老天) v1.0.0-alpha

+ + + +

+Features

+ + + +

+Example

+ + + +

+Install on Mac OS X

+ +
:; brew install glew
+:; brew install glfw3 # or homebrew/versions/glfw3
+:; go get -u github.com/hajimehoshi/ebiten
+
+ +

+Execute the example

+ +
:; cd $GOHOME/src/github.com/hajimehoshi/ebiten/example
+:; go run blocks/main.go
+
+ +

+Benchmark the example

+ +
:; cd $GOHOME/src/github.com/hajimehoshi/ebiten/example
+:; go build -o=example blocks/main.go
+:; ./example -cpuprofile=cpu.out
+:; go tool pprof ./example cpu.out
+
+ +

+Versioning

+ + + +

+License

+ +
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.
+
+