Rename package, prepare for repo move

This commit is contained in:
Mm2PL 2022-04-23 15:01:17 +02:00
parent c92a7a369d
commit d51ac2960a
Signed by: Mm2PL
GPG Key ID: 94AC9B80EFA15ED9
5 changed files with 14 additions and 14 deletions

View File

@ -7,7 +7,7 @@ import (
"os"
"strings"
docs_examples "git.kotmisia.pl/Mm2PL/docs-examples"
"git.kotmisia.pl/Mm2PL/examples"
)
func main() {
@ -17,7 +17,7 @@ func main() {
fmt.Fprintf(os.Stderr, "The -files flag is required.")
return
}
var allExamples []docs_examples.Example
var allExamples []examples.Example
for _, file := range strings.Split(*files, ",") {
file = strings.Trim(file, " ")
f, err := os.Open(file)
@ -25,12 +25,12 @@ func main() {
fmt.Fprintf(os.Stderr, "Failed to open %s for reading: %s\n", file, err)
continue
}
examples, err := docs_examples.ReadFile(f)
exs, err := examples.ReadFile(f)
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to parse %s: %s\n", file, err)
continue
}
allExamples = append(allExamples, examples...)
allExamples = append(allExamples, exs...)
}
err := json.NewEncoder(os.Stdout).Encode(&allExamples)
if err != nil {

View File

@ -5,7 +5,7 @@ import (
"os"
"strings"
docs_examples "git.kotmisia.pl/Mm2PL/docs-examples"
"git.kotmisia.pl/Mm2PL/examples"
)
var currentFile *os.File
@ -22,7 +22,7 @@ func main() {
return
}
currentFile.WriteString(
`package docs_examples
`package examples
// WARNING: this file was auto generated with cmd/gen_examples
import (
"math/rand"
@ -40,15 +40,15 @@ func dummy() int {
fmt.Fprintf(os.Stderr, "Failed to open %s for reading: %s\n", file, err)
continue
}
examples, err := docs_examples.ReadFile(f)
exs, err := examples.ReadFile(f)
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to parse %s: %s\n", file, err)
continue
}
var fnames []string
for i, example := range examples {
for i, example := range exs {
if i >= 1 {
lastEx := examples[i-1]
lastEx := exs[i-1]
if lastEx.Path[len(lastEx.Path)-1] != example.Path[len(example.Path)-1] {
// changed header
currentFile.WriteString(genRandomFunction(fnames, lastEx.Path))
@ -64,7 +64,7 @@ func dummy() int {
}
fnames = append(fnames, fname)
}
currentFile.WriteString(genRandomFunction(fnames, examples[len(examples)-1].Path))
currentFile.WriteString(genRandomFunction(fnames, exs[len(exs)-1].Path))
}
}
func genPathName(input []string) string {
@ -78,7 +78,7 @@ func genPathName(input []string) string {
}
return path
}
func generateFunction(example docs_examples.Example) (code string, fname string) {
func generateFunction(example examples.Example) (code string, fname string) {
fname = genPathName(example.Path) + example.Name
return fmt.Sprintf(
`

View File

@ -1,4 +1,4 @@
package docs_examples
package examples
// WARNING: this file was auto generated with cmd/gen_examples
import (
"math/rand"

View File

@ -1,4 +1,4 @@
package docs_examples
package examples
import (
"bufio"

2
go.mod
View File

@ -1,3 +1,3 @@
module git.kotmisia.pl/Mm2PL/docs-examples
module git.kotmisia.pl/Mm2PL/examples
go 1.18