Commit 3f9dce7
committed
fix(documentation): Make API sidebar generation deterministic and order-safe
The API sidebar in .vitepress/config.ts is built by walking
fs.readdirSync("docs/api") and merging entries into a tree. Two issues
were causing failures and inconsistencies:
- readdirSync returns entries in filesystem order (insertion order on
Linux, alphabetical on macOS APFS). When a "module-..." leaf file
was processed before a sibling that needed to nest under the same
name (e.g. module-@ui5_logger.md before @ui5_logger_Logger.md), the
recursion crashed with "Cannot read properties of undefined (reading
'push')" because the leaf had no items array. This broke the
build:vitepress step on GitHub Actions.
- Even when it succeeded, sibling order in the generated sidebar
varied across platforms.
Fixes:
- Sort the readdir result so the input order — and therefore the
resulting tree — is identical across filesystems.
- Make appendToTree defensive: when a leaf and a branch share a name,
merge them by promoting the leaf to a branch and attaching the
module doc as a 'main' child, in either order. This keeps the build
working even if the sort is removed or the file set changes.1 parent 19e633f commit 3f9dce7
1 file changed
Lines changed: 29 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
293 | 293 | | |
294 | 294 | | |
295 | 295 | | |
296 | | - | |
| 296 | + | |
297 | 297 | | |
298 | 298 | | |
299 | 299 | | |
| |||
302 | 302 | | |
303 | 303 | | |
304 | 304 | | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
305 | 318 | | |
306 | | - | |
| 319 | + | |
307 | 320 | | |
308 | 321 | | |
309 | 322 | | |
| |||
314 | 327 | | |
315 | 328 | | |
316 | 329 | | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
317 | 344 | | |
318 | 345 | | |
319 | 346 | | |
| |||
0 commit comments