Marcel van Lohuizen | 42ebafe | 2019-04-27 01:24:54 +0200 | [diff] [blame] | 1 | // Copyright 2019 CUE Authors |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | // +build ignore |
| 16 | |
| 17 | package main |
| 18 | |
| 19 | // TODO: remove when we have a cuedoc server. Until then, |
| 20 | // piggyback on godoc.org. |
| 21 | |
| 22 | import ( |
| 23 | "bytes" |
| 24 | "fmt" |
| 25 | "io/ioutil" |
| 26 | "os" |
| 27 | ) |
| 28 | |
| 29 | const msg = `// Code generated by cue get go. DO NOT EDIT. |
| 30 | |
| 31 | // Package cli provides tasks dealing with a console. |
| 32 | // |
| 33 | // These are the supported tasks: |
| 34 | // %s |
| 35 | package cli |
| 36 | ` |
| 37 | |
| 38 | func main() { |
| 39 | f, _ := os.Create("doc.go") |
| 40 | defer f.Close() |
| 41 | b, _ := ioutil.ReadFile("cli.cue") |
| 42 | i := bytes.Index(b, []byte("package cli")) |
| 43 | b = b[i+len("package cli")+1:] |
| 44 | b = bytes.ReplaceAll(b, []byte("\n"), []byte("\n// ")) |
| 45 | fmt.Fprintf(f, msg, string(b)) |
| 46 | } |