Skip to content

Commit 45004cf

Browse files
ivanzatiCopilot
andauthored
Check documentation MDX syntax (open-edge-platform#803)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 8287044 commit 45004cf

4 files changed

Lines changed: 92 additions & 3 deletions

File tree

.github/components-path-filters.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,8 @@ markdown:
2626
- '!SECURITY.md'
2727
- '!.github/copilot-instructions.md'
2828
- .github/workflows/**
29+
30+
documentation:
31+
- application/docs/**/*.md
32+
- library/docs/**/*.md
33+
- .github/workflows/**
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: documentation
2+
on:
3+
workflow_call:
4+
workflow_dispatch:
5+
6+
jobs:
7+
documentation:
8+
name: Documentation / MDX checks
9+
permissions:
10+
contents: read
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
15+
with:
16+
persist-credentials: false
17+
18+
- name: Setup Node.js
19+
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
20+
with:
21+
node-version-file: application/ui/.nvmrc
22+
package-manager-cache: false
23+
24+
- name: Validate MDX syntax in Documentation
25+
shell: bash
26+
run: |
27+
echo "Validating MDX/JSX syntax in Documentation files..."
28+
WORKDIR=$(mktemp -d)
29+
cd "$WORKDIR"
30+
npm init -y >/dev/null 2>&1
31+
npm install --no-save @mdx-js/mdx@3 remark-comment@1.0.0 fast-glob@3.3.2 >/dev/null 2>&1
32+
cat > "$WORKDIR/validate-mdx.mjs" << 'SCRIPT'
33+
import { readFile } from "node:fs/promises";
34+
import fg from "fast-glob";
35+
import { compile } from "@mdx-js/mdx";
36+
import remarkComment from 'remark-comment';
37+
const workspace = process.env.WORKSPACE;
38+
process.chdir(workspace);
39+
const files = await fg(["application/docs/**/*.md", "library/docs/**/*.md"], {
40+
ignore: [
41+
"**/node_modules/**",
42+
"**/.git/**",
43+
"**/.venv/**",
44+
"**/dist/**",
45+
"**/build/**",
46+
"**/.next/**"
47+
]
48+
});
49+
console.log(`Found ${files.length} documentation file(s) to validate\n`);
50+
let hasErrors = false;
51+
let errorCount = 0;
52+
for (const file of files) {
53+
try {
54+
const source = await readFile(file, "utf8");
55+
await compile(source, { filepath: file, remarkPlugins: [remarkComment] });
56+
process.stdout.write(".");
57+
} catch (error) {
58+
hasErrors = true;
59+
errorCount++;
60+
process.stdout.write("\n");
61+
console.error(`\n❌ MDX parse error in ${file}:`);
62+
console.error(error.message ?? error);
63+
if (error.position) {
64+
console.error(` Line ${error.position.start.line}, Column ${error.position.start.column}`);
65+
}
66+
}
67+
}
68+
console.log("\n");
69+
if (hasErrors) {
70+
console.error(`❌ Found ${errorCount} file(s) with MDX/JSX syntax errors`);
71+
process.exit(1);
72+
} else {
73+
console.log(`✅ All ${files.length} file(s) passed MDX validation`);
74+
}
75+
SCRIPT
76+
WORKSPACE="$GITHUB_WORKSPACE" NODE_PATH="$WORKDIR/node_modules" node "$WORKDIR/validate-mdx.mjs"

.github/workflows/main.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,19 @@ jobs:
9494

9595
- uses: DavidAnson/markdownlint-cli2-action@07035fd053f7be764496c0f8d8f9f41f98305101 #v22.0.0
9696
with:
97-
config: ".github/.markdownlint-cli2.jsonc"
97+
config: '.github/.markdownlint-cli2.jsonc'
98+
99+
documentation:
100+
name: Documentation markdown checks
101+
needs: build-parameters
102+
permissions:
103+
contents: read
104+
if: needs.build-parameters.outputs.components-list && contains(fromJson(needs.build-parameters.outputs.components-list), 'documentation')
105+
uses: ./.github/workflows/documentation.yml
98106

99107
success:
100108
name: Status checks
101-
needs: [build-parameters, library, backend, ui, distrib, markdown]
109+
needs: [ build-parameters, library, backend, ui, distrib, markdown, documentation ]
102110
runs-on: ubuntu-latest
103111
if: ${{ always() && !cancelled() }}
104112
env:

application/docs/04-concepts/01-architecture.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ The application is structured as a layered edge server. Each layer has a clear r
5656

5757
<div align="center">
5858

59-
<img src="media/system-architecture.svg" width="1200px" alt="Diagram showing the application system architecture">
59+
<img src="media/system-architecture.svg" width="1200px" alt="Diagram showing the application system architecture"/>
6060
</div>
6161

6262
### API Layer

0 commit comments

Comments
 (0)