Skip to content

Commit ea582f0

Browse files
authored
Merge pull request #234 from percona/pxc-4661
PXC-4661 [DOCS] - Add Index 8.4
2 parents 3c64278 + e8da746 commit ea582f0

File tree

3 files changed

+261
-0
lines changed

3 files changed

+261
-0
lines changed

docs/index-contents.md

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Index
2+
3+
- [About Percona XtraDB Cluster](intro.md)
4+
- [Add nodes to cluster](add-node.md)
5+
- [Bootstrap the first node](bootstrap.md)
6+
- [Certification in Percona XtraDB Cluster](certification.md)
7+
- [Cluster failover](failover.md)
8+
- [Compile and install from source code](compile.md)
9+
- [Configure a cluster on Debian or Ubuntu](configure-cluster-ubuntu.md)
10+
- [Configure a cluster on Red Hat-based distributions](configure-cluster-rhel.md)
11+
- [Configure nodes for write-set replication](configure-nodes.md)
12+
- [Copyright and licensing information](copyright-and-licensing-information.md)
13+
- [Crash recovery](crash-recovery.md)
14+
- [Data at Rest Encryption](data-at-rest-encryption.md)
15+
- [Enable AppArmor](apparmor.md)
16+
- [Enable SELinux](selinux.md)
17+
- [Encrypt PXC traffic](encrypt-traffic.md)
18+
- [Files in packages built for Percona XtraDB Cluster Pro](pro-files.md)
19+
- [FIPS compliance](fips.md)
20+
- [Frequently asked questions](faq.md)
21+
- [GCache encryption and Write-Set cache encryption](gcache-write-set-cache-encryption.md)
22+
- [Get help from Percona](get-help.md)
23+
- [Get started with Percona XtraDB Cluster](get-started-cluster.md)
24+
- [Glossary](glossary.md)
25+
- [High availability](high-availability.md)
26+
- [How to set up a three-node cluster in EC2 environment](set-up-3nodes-ec2.md)
27+
- [How to set up a three-node cluster on a single box](singlebox.md)
28+
- [Index of files created by PXC](wsrep-files-index.md)
29+
- [Index of wsrep status variables](wsrep-status-index.md)
30+
- [Index of wsrep system variables](wsrep-system-index.md)
31+
- [Index of wsrep_provider options](wsrep-provider-index.md)
32+
- [Install from Binary Tarball](tarball.md)
33+
- [Install on Debian or Ubuntu](apt.md)
34+
- [Install on Red Hat Enterprise Linux](yum.md)
35+
- [Install Percona XtraDB Cluster](install-index.md)
36+
- [Install Percona XtraDB Cluster Pro](install-pro.md)
37+
- [Load balance with ProxySQL](load-balance-proxysql.md)
38+
- [Load balancing with HAProxy](haproxy.md)
39+
- [Monitor the cluster](monitoring.md)
40+
- [Non-Blocking Operations (NBO) method for Online Scheme Upgrades (OSU)](nbo.md)
41+
- [Online schema upgrade](online-schema-upgrade.md)
42+
- [Percona Software Download Instructions](download-instructions.md)
43+
- [Percona XtraBackup SST configuration](xtrabackup-sst.md)
44+
- [Percona XtraDB Cluster limitations](limitation.md)
45+
- [Percona XtraDB Cluster Pro](pxc-pro.md)
46+
- [Percona XtraDB Cluster strict mode](strict-mode.md)
47+
- [Percona XtraDB Cluster threading model](threading-model.md)
48+
- [Percona XtraDB Cluster {{vers}} Documentation](index.md)
49+
- [Perfomance Schema instrumentation](performance-schema-instrumentation.md)
50+
- [ProxySQL admin utilities](proxysql-v2.md)
51+
- [Quickstart Guide for Percona XtraDB Cluster](quickstart-overview.md)
52+
- [Restart the cluster nodes](restarting-nodes.md)
53+
- [Restore 8.0 backup to 8.4 cluster](upgrade-backup.md)
54+
- [Running Percona XtraDB Cluster in a Docker Container](docker.md)
55+
- [Secure the network](secure-network.md)
56+
- [Security basics](security-index.md)
57+
- [Set up a testing environment with ProxySQL](virtual-sandbox.md)
58+
- [Set up Galera arbitrator](garbd-howto.md)
59+
- [State snapshot transfer](state-snapshot-transfer.md)
60+
- [State Snapshot Transfer (SST) Method using Clone plugin](clone-sst.md)
61+
- [Telemetry on Percona XtraDB Cluster](telemetry.md)
62+
- [Trademark policy](trademark-policy.md)
63+
- [Understand GCache and Record-Set cache](gcache-record-set-cache-difference.md)
64+
- [Understand version numbers](xtradb-cluster-version-numbers.md)
65+
- [Upgrade cluster from packages](upgrade-packages.md)
66+
- [Upgrade Percona XtraDB Cluster](upgrade-guide.md)
67+
- [Verify replication](verify-replication.md)

generate_index.go

+193
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
package main
2+
3+
import (
4+
"bufio"
5+
"fmt"
6+
"io/fs"
7+
"log"
8+
"os"
9+
"path/filepath"
10+
"sort"
11+
"strings"
12+
)
13+
14+
func main() {
15+
// --- Instructions on how to run this script ---
16+
// Save this code to a file named generate_index.go in the root directory
17+
// Ensure Go is installed on your system.
18+
// Open your terminal and navigate to the directory containing generate_index.go.
19+
// Either - Compile the code (optional): `go build generate_index.go`
20+
// and then run the code: `./generate_index`
21+
// Or `go run generate_index.go` to run the Go script without compile.
22+
// The script generates index-contents.md inside the "docs" directory.
23+
// --- End of Instructions ---
24+
docsDir := "docs"
25+
indexFileName := "index-contents.md"
26+
indexFilePath := filepath.Join(docsDir, indexFileName)
27+
maxDepth := 5
28+
excludeDirs := map[string]struct{}{
29+
"_static": {}, "assets": {}, "css": {}, "fonts": {}, "js": {},
30+
"release-notes": {}, filepath.Join("release-notes", "8.0"): {},
31+
}
32+
excludeFiles := map[string]struct{}{
33+
"404.md": {}, indexFileName: {},
34+
}
35+
prefixesToStrip := []string{"The ", "Work with "}
36+
37+
if err := os.Remove(indexFilePath); err == nil {
38+
fmt.Printf("Deleted existing index file: %s\n", indexFilePath)
39+
} else if !os.IsNotExist(err) {
40+
log.Fatalf("Failed to delete existing index file: %v", err)
41+
}
42+
43+
var fileEntries []struct {
44+
sortKey, displayName, relPath string
45+
indentLevel int
46+
}
47+
48+
err := filepath.Walk(docsDir, func(path string, info fs.FileInfo, err error) error {
49+
if err != nil {
50+
return err
51+
}
52+
53+
relPath, err := filepath.Rel(docsDir, path)
54+
if err != nil {
55+
return err
56+
}
57+
relPath = filepath.ToSlash(relPath)
58+
59+
depth := strings.Count(relPath, "/")
60+
if depth > maxDepth {
61+
if info.IsDir() {
62+
return filepath.SkipDir
63+
}
64+
return nil
65+
}
66+
67+
if info.IsDir() {
68+
if _, ok := excludeDirs[info.Name()]; ok {
69+
return nil
70+
}
71+
if _, ok := excludeDirs[relPath]; ok {
72+
return nil
73+
}
74+
return nil
75+
}
76+
77+
if !strings.HasSuffix(info.Name(), ".md") {
78+
return nil
79+
}
80+
81+
if _, ok := excludeFiles[info.Name()]; ok {
82+
return nil
83+
}
84+
85+
dirsInPath := strings.Split(filepath.Dir(relPath), "/")
86+
for i := range dirsInPath {
87+
if _, ok := excludeDirs[strings.Join(dirsInPath[:i+1], "/")]; ok {
88+
return nil
89+
}
90+
}
91+
92+
if contains(dirsInPath, "release-notes") && info.Name() != "release-notes.md" {
93+
return nil
94+
}
95+
96+
displayName := extractDisplayName(path)
97+
if displayName == "" {
98+
displayName = strings.TrimSuffix(info.Name(), ".md")
99+
}
100+
101+
sortKey := stripPrefixes(displayName, prefixesToStrip)
102+
sortKey = strings.ToLower(sortKey)
103+
104+
indentLevel := strings.Count(relPath, "/") - 1
105+
if indentLevel < 0 {
106+
indentLevel = 0
107+
}
108+
109+
fileEntries = append(fileEntries, struct {
110+
sortKey, displayName, relPath string
111+
indentLevel int
112+
}{sortKey, displayName, relPath, indentLevel})
113+
114+
return nil
115+
})
116+
117+
if err != nil {
118+
log.Fatalf("Error walking the docs directory: %v", err)
119+
}
120+
121+
sort.Slice(fileEntries, func(i, j int) bool {
122+
return fileEntries[i].sortKey < fileEntries[j].sortKey
123+
})
124+
125+
var content strings.Builder
126+
content.WriteString("# Index\n\n")
127+
128+
prevDir := ""
129+
for _, entry := range fileEntries {
130+
dir := filepath.Dir(entry.relPath)
131+
dir = strings.ReplaceAll(dir, "\\", "/")
132+
if dir == "." {
133+
dir = ""
134+
}
135+
136+
if dir != prevDir && dir != "" {
137+
dirDisplayName := strings.Replace(dir, "release-notes", "Release notes", -1)
138+
indentLevel := strings.Count(dirDisplayName, "/")
139+
indent := strings.Repeat(" ", indentLevel)
140+
content.WriteString(fmt.Sprintf("%s- %s/\n", indent, dirDisplayName))
141+
}
142+
prevDir = dir
143+
144+
indent := strings.Repeat(" ", entry.indentLevel)
145+
content.WriteString(fmt.Sprintf("%s - [%s](%s)\n", indent, entry.displayName, entry.relPath))
146+
}
147+
148+
if err := os.WriteFile(indexFilePath, []byte(content.String()), 0644); err != nil {
149+
log.Fatalf("Failed to write index file: %v", err)
150+
}
151+
152+
fmt.Printf("Index generated at %s\n", indexFilePath)
153+
}
154+
155+
func stripPrefixes(s string, prefixes []string) string {
156+
sLower := strings.ToLower(s)
157+
for _, prefix := range prefixes {
158+
if strings.HasPrefix(sLower, strings.ToLower(prefix)) {
159+
return s[len(prefix):]
160+
}
161+
}
162+
return s
163+
}
164+
165+
func contains(slice []string, item string) bool {
166+
for _, s := range slice {
167+
if strings.EqualFold(s, item) {
168+
return true
169+
}
170+
}
171+
return false
172+
}
173+
174+
func extractDisplayName(filePath string) string {
175+
file, err := os.Open(filePath)
176+
if err != nil {
177+
fmt.Printf("Error opening file %s: %v\n", filePath, err)
178+
return ""
179+
}
180+
defer file.Close()
181+
182+
scanner := bufio.NewScanner(file)
183+
for scanner.Scan() {
184+
line := strings.TrimSpace(scanner.Text())
185+
if strings.HasPrefix(line, "# ") {
186+
return strings.TrimSpace(line[2:])
187+
}
188+
}
189+
if err := scanner.Err(); err != nil {
190+
fmt.Printf("Error reading file %s: %v\n", filePath, err)
191+
}
192+
return ""
193+
}

mkdocs-base.yml

+1
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ nav:
244244
- glossary.md
245245
- copyright-and-licensing-information.md
246246
- trademark-policy.md
247+
- Topic Index: index-contents.md
247248

248249
# - Version Selector: "../"
249250

0 commit comments

Comments
 (0)