1
0
mirror of https://github.com/StackExchange/dnscontrol.git synced 2024-05-11 05:55:12 +00:00

DOCS: Documentation inline replacements (#2083)

Co-authored-by: Tom Limoncelli <tlimoncelli@stackoverflow.com>
This commit is contained in:
Jeffrey Cafferata
2023-02-19 06:07:30 +01:00
committed by GitHub
parent b635dc5f4a
commit 7b1b964b76
2 changed files with 38 additions and 4 deletions

View File

@@ -1,11 +1,12 @@
package main
import (
"sort"
"github.com/StackExchange/dnscontrol/v3/providers"
_ "github.com/StackExchange/dnscontrol/v3/providers/_all"
"github.com/fbiville/markdown-table-formatter/pkg/markdown"
"os"
"sort"
"strings"
)
func generateFeatureMatrix() error {
@@ -16,7 +17,12 @@ func generateFeatureMatrix() error {
return err
}
_ = markdownTable
replaceInlineContent(
"documentation/providers.md",
"<!-- provider-matrix-start -->",
"<!-- provider-matrix-end -->",
markdownTable,
)
return nil
}
@@ -277,3 +283,29 @@ type FeatureMatrix struct {
Features []string
Providers map[string]FeatureMap
}
func replaceInlineContent(
file string,
startMarker string,
endMarker string,
newContent string,
) {
contentBytes, err := os.ReadFile(file)
if err != nil {
panic(err)
}
content := string(contentBytes)
start := strings.Index(content, startMarker)
end := strings.Index(content, endMarker)
newContentString := startMarker + "\n" + newContent + endMarker
newContentBytes := []byte(newContentString)
contentBytes = []byte(content)
contentBytes = append(contentBytes[:start], append(newContentBytes, contentBytes[end+len(endMarker):]...)...)
err = os.WriteFile(file, contentBytes, 0644)
if err != nil {
panic(err)
}
}