Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: added website to repo #597

Merged
merged 4 commits into from
Dec 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 18 additions & 7 deletions ci/main.go
Expand Up @@ -95,11 +95,11 @@ func main() {
os.WriteFile("./docs/docs/putils.md", []byte(putilsReadme), 0600)
})

var allPrinters []string
do("Geneating printers Table", currentLevel, func(currentLevel int) {
// get features located in "_examples/*"
files, _ := os.ReadDir("./_examples/")

var allPrinters []string
for _, file := range files {
if file.Name() == "README.md" {
continue
Expand Down Expand Up @@ -142,6 +142,23 @@ func main() {
os.WriteFile("./README.md", []byte(readmeString), 0600)
})

do("Write printers to website", currentLevel, func(currentLevel int) {
pterm.Info.Println("Writing printers to website")
websiteIndex, _ := os.ReadFile("./docs/index.html")
websiteIndexString := string(websiteIndex)

// Write as li elements, which contain a link to the example. (https://github.com/pterm/pterm/tree/master/_examples/{name})
var links []string
for _, printer := range allPrinters {
links = append(links, fmt.Sprintf(`<li><a href="https://github.com/pterm/pterm/tree/master/_examples/%s">%s</a></li>`, printer, printer))
}

// Replace placeholder with li elements.
websiteIndexString = writeBetween("printers", websiteIndexString, "\n"+strings.Join(links, "\n")+"\n")

os.WriteFile("./docs/index.html", []byte(websiteIndexString), 0600)
})

var readmeExamples string
do("Generating Examples", currentLevel, func(currentLevel int) {
files, _ := os.ReadDir("./_examples/")
Expand Down Expand Up @@ -226,12 +243,6 @@ func main() {
if err != nil {
log.Panic(err)
}

pterm.Info.Println("Writing README for https://pterm.sh")
err = os.WriteFile("./docs/README.md", []byte(newReadmeContent), 0600)
if err != nil {
log.Panic(err)
}
})
})
}
Expand Down