Skip to content

Commit 7d3fc22

Browse files
committed
chore(docs): fix Actions workflow to correctly build reference docs
Before generating the site, also gracefully handle the missing "references" sidebar config. Remove the, now generated, _reference.js sidebar config file
1 parent 6692142 commit 7d3fc22

5 files changed

Lines changed: 20 additions & 15 deletions

File tree

.github/workflows/deploy-docusaurus.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,14 @@ jobs:
4949
cache-dependency-path: 'package-lock.json' # root level, since we're using npm workspaces
5050

5151
- name: Install dependencies
52-
working-directory: ./packages/docs
5352
run: npm ci
5453

54+
- name: Build Blockly and generate reference docs
55+
working-directory: ./packages/blockly
56+
run: |
57+
npm run package
58+
npm run docs
59+
5560
- name: Build the Docusaurus site
5661
working-directory: ./packages/docs
5762
run: npm run build

packages/blockly/scripts/gulpfiles/docs_tasks.mjs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ const prependFrontmatter = function(done) {
209209
const description = extractDescription(content, file);
210210

211211
let frontmatter = '---\n';
212-
frontmatter += 'sidebar: referenceSidebar\n';
212+
frontmatter += 'displayed_sidebar: referenceSidebar\n';
213213
frontmatter += 'hide_title: true\n';
214214
frontmatter += `title: "${title}"\n`;
215215
frontmatter += `description: ${JSON.stringify(description)}\n`;
@@ -292,6 +292,8 @@ const convertToMdx = function() {
292292
}))
293293
// Remove %5C (URL-encoded backslash) and literal backslash before anchor tags
294294
.pipe(replace(/(%5C|\\)(#[^)\s"']*)/g, '$2'))
295+
// Fix breadcrumb "Home" link to point to the overview page
296+
.pipe(replace(/\[Home\]\(\/reference\/index\)/g, '[Home](/reference/blockly)'))
295297
// Convert <code>text</code> to markdown backtick code
296298
.pipe(replace(/<code>([^<]*)<\/code>/g, '`$1`'))
297299
// Convert paragraph breaks to spaces (for table cells) and remove remaining p tags
@@ -382,8 +384,8 @@ const parseHtmlTables = function(fileContent) {
382384

383385
if (!sectionName || sectionName === 'blockly package') continue;
384386

385-
// Find table rows in HTML - match links with or without ./ prefix
386-
const tableRowRegex = /<tr><td>\s*\[([^\]]+)\]\((?:\/reference\/)?([^\)]+)\)/g;
387+
// Match links in markdown pipe tables: | [Name](/reference/path) | ...
388+
const tableRowRegex = /\|\s*\[([^\]]+)\]\(\/reference\/([^\)]+)\)/g;
387389
const items = [];
388390

389391
let match;

packages/docs/.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# Autogenerated reference docs, do not check in
2-
docs/reference/*
3-
!docs/reference/_reference.js
2+
docs/reference/
43
.docusaurus
54
build/

packages/docs/docs/reference/_reference.js

Lines changed: 0 additions & 7 deletions
This file was deleted.

packages/docs/sidebars.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
1-
import { referenceSidebar } from './docs/reference/_reference';
2-
31
// @ts-nocheck
42

3+
let referenceSidebar = [];
4+
try {
5+
({ referenceSidebar } = await import('./docs/reference/_reference.js'));
6+
} catch {
7+
console.warn('Reference sidebar not found — run "npm run docs" in packages/blockly to generate it.');
8+
}
9+
10+
511
// This runs in Node.js - Don't use client-side code here (browser APIs, JSX...)
612

713
/**

0 commit comments

Comments
 (0)