Skip to content

Commit f3c6ee2

Browse files
authored
Pointing to a directory (#736)
* Pointing to a directory * And now two pages pointing to the same markdown file * Added better Gitbook validation and now ran through CI
1 parent ffe8df2 commit f3c6ee2

File tree

4 files changed

+68
-10
lines changed

4 files changed

+68
-10
lines changed

.github/workflows/main.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ jobs:
1414
test:
1515
name: Test
1616
runs-on: ${{ matrix.os }}
17-
if: "${{ !startsWith(github.event.head_commit.message, 'GitBook: [#') }}"
17+
if: "!startsWith(github.event.head_commit.message, 'GitBook: [#')"
1818
strategy:
1919
matrix:
20-
go-version: [ 1.24.x ]
20+
go-version: [1.24.x]
2121
os: [ubuntu-latest, macos-latest]
2222
steps:
2323
- name: Set up Go
@@ -43,6 +43,9 @@ jobs:
4343
restore-keys: |
4444
${{ runner.os }}-go-
4545
46+
- name: Validate GitBook
47+
run: go run ./docs/.gitbook/validate.go
48+
4649
- name: Run Tests
4750
run: ./bin/test.sh
4851

docs/.gitbook/validate.go

Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,11 @@ func main() {
4040
validSummary := validateAllFilesAreInSummary(docsRoot)
4141

4242
fmt.Println("")
43-
if validReferences && validSummary {
43+
fmt.Println("Checking for duplicate file references in SUMMARY.md...")
44+
validUniqueSummary := validateSummaryNoDuplicates(docsRoot)
45+
46+
fmt.Println("")
47+
if validReferences && validSummary && validUniqueSummary {
4448
fmt.Println("🎉 All documentation checks passed!")
4549
os.Exit(0)
4650
} else {
@@ -96,6 +100,57 @@ func validateLocalReferences(docsRoot string) bool {
96100
return true
97101
}
98102

103+
func validateSummaryNoDuplicates(docsRoot string) bool {
104+
cwd, err := os.Getwd()
105+
cli.NoError(err, "Unable to get current working directory")
106+
107+
summaryPath := filepath.Join(docsRoot, "SUMMARY.md")
108+
summaryContent, err := os.ReadFile(summaryPath)
109+
cli.NoError(err, "Unable to read SUMMARY.md", zap.String("path", summaryPath))
110+
111+
summaryLinks := extractMarkdownLinks(summaryPath, string(summaryContent))
112+
113+
// Track which files appear and where
114+
fileOccurrences := make(map[string][]MarkdownLink)
115+
for _, link := range summaryLinks {
116+
if link.TargetFilePath != nil {
117+
fileOccurrences[*link.TargetFilePath] = append(fileOccurrences[*link.TargetFilePath], link)
118+
}
119+
}
120+
121+
// Find duplicates
122+
duplicates := []string{}
123+
for filePath, occurrences := range fileOccurrences {
124+
if len(occurrences) > 1 {
125+
duplicates = append(duplicates, filePath)
126+
}
127+
}
128+
129+
if len(duplicates) == 0 {
130+
fmt.Println("✓ No duplicate file references in SUMMARY.md!")
131+
return true
132+
}
133+
134+
fmt.Printf("\n❌ Found %d files referenced multiple times in SUMMARY.md:\n\n", len(duplicates))
135+
for _, filePath := range duplicates {
136+
relPath, err := filepath.Rel(cwd, filePath)
137+
if err != nil {
138+
relPath = filePath
139+
}
140+
fmt.Printf(" • %s (referenced %d times):\n", relPath, len(fileOccurrences[filePath]))
141+
for _, link := range fileOccurrences[filePath] {
142+
relSummaryPath, err := filepath.Rel(cwd, summaryPath)
143+
if err != nil {
144+
relSummaryPath = summaryPath
145+
}
146+
fmt.Printf(" - %s:%d - [%s](%s)\n", relSummaryPath, link.LineNumber, link.LinkText, link.LinkPath)
147+
}
148+
fmt.Println()
149+
}
150+
151+
return false
152+
}
153+
99154
func validateAllFilesAreInSummary(docsRoot string) bool {
100155
sourceFiles, err := extractAllSourceFiles(docsRoot)
101156
cli.NoError(err, "Unable to extract all source files")

docs/SUMMARY.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
* [Install Substreams CLI](how-to-guides/cli/installing-the-cli.md)
2626
* [Substreams CLI Authentication](how-to-guides/cli/authentication.md)
2727
* [Developing Substreams](how-to-guides/develop-your-own-substreams/develop-your-own-substreams.md)
28-
* [on EVM](how-to-guides/develop-your-own-substreams/on-evm/README.md)
28+
* [on EVM](how-to-guides/develop-your-own-substreams/evm)
2929
* [Exploring Ethereum](how-to-guides/develop-your-own-substreams/evm/exploring-ethereum/exploring-ethereum.md)
3030
* [Filter Transactions](how-to-guides/develop-your-own-substreams/evm/exploring-ethereum/map_filter_transactions_module.md)
3131
* [Retrieve Events of a Smart Contract](how-to-guides/develop-your-own-substreams/evm/exploring-ethereum/map_contract_events_module.md)
@@ -71,13 +71,13 @@
7171
## Reference Material
7272

7373
* [CLI Reference](references/cli/command-line-interface.md)
74-
* [Core Concepts](references/architecture.md)
74+
* Core Concepts
7575
* [Architecture & Parallel Execution](references/architecture.md)
7676
* [Foundational Stores](references/foundational-store-reference.md)
7777
* [Module Concepts](references/substreams-components/modules/modules.md)
7878
* [Reliability Guarantees](references/reliability-guarantees.md)
7979
* [FAQ](references/faq.md)
80-
* [Manifest & Components](references/substreams-components/manifests.md)
80+
* Manifest & Components
8181
* [Manifests](references/substreams-components/manifests.md)
8282
* [Packages](references/substreams-components/packages.md)
8383
* [Module Types](references/substreams-components/modules/types.md)
@@ -89,7 +89,7 @@
8989
* [Parameterized Modules](references/substreams-components/modules/parameterized-modules.md)
9090
* [Dynamic Data Sources](references/substreams-components/modules/dynamic-data-sources.md)
9191
* [Aggregation Windows](references/substreams-components/modules/aggregation-windows.md)
92-
* [Chain Support](references/chains-and-endpoints.md)
92+
* Chain Support
9393
* [Chains & Endpoints](references/chains-and-endpoints.md)
9494
* [Ethereum Data Model](references/ethereum-data-model.md)
9595
* [Flashblocks support](references/flashblocks.md)
@@ -100,7 +100,7 @@
100100
* [Reorg Handling](references/sql/reorg-handling.md)
101101
* Operators
102102
* [Hosting Foundational Stores](./references/foundational-stores/hosting-foundational-stores.md)
103-
* [Development Tools](references/log-and-debug.md)
103+
* Development Tools
104104
* [Logging & Debugging](references/log-and-debug.md)
105105
* [Dev Container Reference](references/devcontainer-ref.md)
106106
* [Change log](release-notes/change-log.md)

docs/release-notes/change-log.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
2525
* commands `run` and `sink webhook` now support these flags:
2626
- `--include-partial-blocks`: sends every block as partial(s) but also as real block
2727
- `--partial-blocks-only`: only sends partials (for every block, every bit of data should be there)
28-
28+
2929
### Sink library
3030

3131
* To use the new partial blocks in a sink that uses github.com/streamingfast/substreams/sink, simply:
@@ -269,7 +269,7 @@ People using their own authentication layer will need to consider these changes
269269

270270
* **Improved** Improved `substreams build`, `substreams protogen` and `substreams pack` command outputs to be streamlined and condensed.
271271
* **Added** support for reading manifest from stdin across all manifest-accepting commands using `"-"` as the manifest path. Affected commands: `build`, `run`, `gui`, `info`, `graph`, `pack`, `protogen`. This enables dynamic manifest generation and preprocessing workflows, including integration with tools like `envsubst` for environment variable substitution and CI/CD pipeline automation.
272-
* **Added** `substreams sink webhook` command to send Substreams output to a webhook endpoint. See [the documentation](./sink/webhook/README.md) for more information.
272+
* **Added** `substreams sink webhook` command to send Substreams output to a webhook endpoint. See [the documentation](../how-to-guides/sinks/) for more information.
273273
* Changed `substreams-api-token-envvar` flag to `api-token-envvar`
274274
* Changed `substreams-api-key-envvar` flag to `api-key-envvar`
275275

0 commit comments

Comments
 (0)