Skip to content

Commit 2cd03e7

Browse files
authored
Fix broken links and images (#331)
* scripts automation (check links + images) * last scripts check * update warning messge * fix broken links and adjust link script to skip example urls * updating image directory errors and script to check location (ignores images used in multiple mdx files) * check-links adjustment * fixing directory * validate script also runs when changes are committed to a PR (for Tori specifically)
1 parent fc47231 commit 2cd03e7

42 files changed

Lines changed: 591 additions & 42 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
name: Validate Documentation
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened] # Run on PR open AND every commit
6+
branches:
7+
- main
8+
paths:
9+
- '**.mdx'
10+
- '**.md'
11+
- 'images/**'
12+
- 'scripts/**'
13+
- '.github/workflows/validate-docs.yml'
14+
15+
jobs:
16+
validate:
17+
name: Check Links and Images
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
- name: Checkout code
22+
uses: actions/checkout@v4
23+
24+
- name: Setup Node.js
25+
uses: actions/setup-node@v4
26+
with:
27+
node-version: '18'
28+
29+
- name: Check for broken links
30+
id: check-links
31+
run: |
32+
echo "::group::Checking for broken links"
33+
node scripts/check-links.js > /tmp/check-links-output.txt 2>&1 || echo "issues_found=true" >> $GITHUB_OUTPUT
34+
cat /tmp/check-links-output.txt
35+
echo "::endgroup::"
36+
continue-on-error: true
37+
38+
- name: Check image locations
39+
id: check-images
40+
run: |
41+
echo "::group::Checking image locations"
42+
node scripts/check-image-locations.js > /tmp/check-images-output.txt 2>&1 || echo "issues_found=true" >> $GITHUB_OUTPUT
43+
cat /tmp/check-images-output.txt
44+
echo "::endgroup::"
45+
continue-on-error: true
46+
47+
- name: Post or update PR comment
48+
if: always() # Always run to update comment even if issues are fixed
49+
uses: actions/github-script@v7
50+
with:
51+
script: |
52+
const fs = require('fs');
53+
54+
// Build comment body
55+
let comment = '## 📋 Documentation Validation Report\n\n';
56+
57+
const hasIssues = '${{ steps.check-links.outputs.issues_found }}' === 'true' ||
58+
'${{ steps.check-images.outputs.issues_found }}' === 'true';
59+
60+
if (hasIssues) {
61+
comment += '⚠️ Some issues were found in this PR. These are **informational warnings** and will not block merging.\n\n';
62+
} else {
63+
comment += '✅ All validation checks passed!\n\n';
64+
}
65+
66+
if ('${{ steps.check-links.outputs.issues_found }}' === 'true') {
67+
const linksOutput = fs.readFileSync('/tmp/check-links-output.txt', 'utf8');
68+
const lines = linksOutput.split('\n');
69+
const brokenLinks = lines.filter(line => line.includes('Broken link:') || line.includes('📄')).slice(0, 10);
70+
71+
comment += '### 🔗 Links\n';
72+
if (brokenLinks.length > 0) {
73+
comment += '<details><summary>❌ Found broken links (click to expand)</summary>\n\n';
74+
comment += '```\n' + brokenLinks.join('\n') + '\n```\n';
75+
comment += '</details>\n\n';
76+
}
77+
} else {
78+
comment += '### 🔗 Links\n✅ All links valid\n\n';
79+
}
80+
81+
if ('${{ steps.check-images.outputs.issues_found }}' === 'true') {
82+
const imagesOutput = fs.readFileSync('/tmp/check-images-output.txt', 'utf8');
83+
const lines = imagesOutput.split('\n');
84+
const imageIssues = lines.filter(line => line.includes('📄') || line.includes('Expected in:')).slice(0, 10);
85+
86+
comment += '### 🖼️ Images\n';
87+
if (imageIssues.length > 0) {
88+
comment += '<details><summary>❌ Found image location issues (click to expand)</summary>\n\n';
89+
comment += '```\n' + imageIssues.join('\n') + '\n```\n';
90+
comment += '</details>\n\n';
91+
}
92+
} else {
93+
comment += '### 🖼️ Images\n✅ All images in correct locations\n\n';
94+
}
95+
96+
comment += '---\n';
97+
comment += '💡 **Quick Reference:**\n';
98+
comment += '- A page at `guides/dashboard.mdx` should use images from `images/guides/dashboard/`\n';
99+
comment += '- Shared images can be placed in parent directories\n';
100+
comment += '- All internal links must point to existing files\n\n';
101+
comment += '📖 Run `node scripts/check-links.js` and `node scripts/check-image-locations.js` locally for full details.\n';
102+
103+
// Find existing comment from this bot
104+
const { data: comments } = await github.rest.issues.listComments({
105+
issue_number: context.issue.number,
106+
owner: context.repo.owner,
107+
repo: context.repo.repo,
108+
});
109+
110+
const botComment = comments.find(c =>
111+
c.user.type === 'Bot' && c.body.includes('📋 Documentation Validation Report')
112+
);
113+
114+
// Update existing or create new
115+
if (botComment) {
116+
await github.rest.issues.updateComment({
117+
comment_id: botComment.id,
118+
owner: context.repo.owner,
119+
repo: context.repo.repo,
120+
body: comment
121+
});
122+
} else {
123+
await github.rest.issues.createComment({
124+
issue_number: context.issue.number,
125+
owner: context.repo.owner,
126+
repo: context.repo.repo,
127+
body: comment
128+
});
129+
}
130+
131+
- name: Report results
132+
if: always()
133+
run: |
134+
if [ "${{ steps.check-links.outputs.issues_found }}" == "true" ] || [ "${{ steps.check-images.outputs.issues_found }}" == "true" ]; then
135+
echo "## Documentation Validation Warnings ⚠️" >> $GITHUB_STEP_SUMMARY
136+
echo "" >> $GITHUB_STEP_SUMMARY
137+
echo "Issues found - see PR comment for details" >> $GITHUB_STEP_SUMMARY
138+
else
139+
echo "## Documentation Validation Passed ✅" >> $GITHUB_STEP_SUMMARY
140+
echo "" >> $GITHUB_STEP_SUMMARY
141+
echo "All links are valid and images are in the correct locations!" >> $GITHUB_STEP_SUMMARY
142+
fi

get-started/develop-in-lightdash/adding-tables-to-lightdash.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ Here's an example of our dbt project at Lightdash too see what that looks like i
159159
- We have one `.yml` file per model (these are the files where all of your Tables' configuration sits)
160160

161161
<Frame>
162-
<img src="/images/guides/dbt-repo-example.png" alt="" />
162+
<img src="/images/get-started/develop-in-lightdash/adding-tables-to-lightdash/dbt-repo-example.png" alt="" />
163163
</Frame>
164164

165165
**But, in my dbt project, I have a single schema.yml file. Not one for each model. Will that still work?**

get-started/exploring-data/using-explores.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ Saved Charts allow you to save a specific chart or table so you can share, add i
107107
When you open a saved chart, it will always update to display the latest data in your database since it will re-run the query each time you open it.
108108

109109
<Frame>
110-
![](/images/get-started/exploring-data/dashboards/save-your-chart.png)
110+
![](/images/get-started/exploring-data/using-explores/save-your-chart.png)
111111
</Frame>
112112

113113
To save a chart, click the `Save chart` button at the top of the page, then give your chart a useful name and description. You'll have the option to save the chart to a Dashboard or a Space.

guides/embedding/dashboards.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ Filter data based on the viewing user's properties. See the [user attributes ref
444444
Embed individual charts for focused displays
445445
</Card>
446446

447-
<Card title="User attributes & row-level security" icon="shield-check" href="/references/user-attributes">
447+
<Card title="User attributes & row-level security" icon="shield-check" href="/references/workspace/user-attributes">
448448
Show different data to different users
449449
</Card>
450450

guides/table-calculations.mdx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: "Table calculations"
33
description: "Table calculations make it easy to create metrics on the fly (for example, aggregating the data in your table over some window, or getting a running total of a column)."
44
---
55

6-
You add table calculations in the Explore view and they appear as green columns in your results table (remember, [dimensions](references/dimensions) are blue, and [metrics](references/metrics) are orange).
6+
You add table calculations in the Explore view and they appear as green columns in your results table (remember, [dimensions](/references/dimensions) are blue, and [metrics](/references/metrics) are orange).
77

88
<Frame>
99
<img src="/images/guides/table-calculations/table-calculations-add-a932fb32af1dc604d4ef709886f9a833.jpg"/>
@@ -24,7 +24,7 @@ Table calculations work as an additional computational layer that builds on top
2424
- Other table calculations (you can even stack them)
2525

2626
<Warning>
27-
Table calculations are useful for specialized, temporary needs, but if you find yourself repeatedly reusing a table calculation, it's a sign to add it to dbt so it's tracked in the semantic layer. This keeps your organization's metrics centralized and consistently defined. You can read more about [adding metrics to your dbt project here](references/metrics).
27+
Table calculations are useful for specialized, temporary needs, but if you find yourself repeatedly reusing a table calculation, it's a sign to add it to dbt so it's tracked in the semantic layer. This keeps your organization's metrics centralized and consistently defined. You can read more about [adding metrics to your dbt project here](/references/metrics).
2828
</Warning>
2929

3030
## Creating table calculations
@@ -38,7 +38,7 @@ Table calculations work with whatever data you've already pulled into your resul
3838
Quick calculations are shortcuts to the most common table calculations, these are only available to metrics in the contextual menu in the results table.
3939

4040
<Frame>
41-
![](/images/references/quick-table-calculation-b1e76d3e54d84ca3c5066ffdf989514b.png)
41+
![](/images/guides/table-calculations/quick-table-calculation-b1e76d3e54d84ca3c5066ffdf989514b.png)
4242
</Frame>
4343

4444
To learn more about what these calculations are doing, check out the docs [here](/guides/table-calculations/sql-templates). Once the table calculation is generated you can edit it to modify the SQL query or update the format.
@@ -48,7 +48,7 @@ To learn more about what these calculations are doing, check out the docs [here]
4848
Once you've got some data in your results table, you can create a table calculation by clicking on the `+ Table calculation` in the `Results` tab of the Explore view:
4949

5050
<Frame>
51-
![](/images/references/create-new-table-calc-772add6d063a5122c0a25accf798fbb3.jpg)
51+
![](/images/guides/table-calculations/create-new-table-calc-772add6d063a5122c0a25accf798fbb3.jpg)
5252
</Frame>
5353

5454
##### Write the SQL for your table calculation in the pop-up box
@@ -58,7 +58,7 @@ Your table calculation is defined using raw SQL that you write up in this pop up
5858
To reference the metrics and dimensions in your results table, you can either use the autocomplete, or you can manually write the full field name using the format `${table_name.field_name}`.
5959

6060
<Frame>
61-
![](/images/references/add-table-calc-sql-20de5398dc117ef3d4087cf3b6d9939b.jpg)
61+
![](/images/guides/table-calculations/add-table-calc-sql-20de5398dc117ef3d4087cf3b6d9939b.jpg)
6262
</Frame>
6363

6464

@@ -67,7 +67,7 @@ To reference the metrics and dimensions in your results table, you can either us
6767
If needed, you can update the format of your table calculation to things like percent formatting using the `format` tab.
6868

6969
<Frame>
70-
![](/images/references/format-table-calc-c0e3828b6681db084b4ddd6799ff2c96.jpg)
70+
![](/images/guides/table-calculations/format-table-calc-c0e3828b6681db084b4ddd6799ff2c96.jpg)
7171
</Frame>
7272

7373
| Format types | Description | Raw value | How it might look like in Lightdash |
@@ -82,7 +82,7 @@ If needed, you can update the format of your table calculation to things like pe
8282
If you need to edit or delete a table calculation, you can just click on the toggle beside the field and do what you need to do!
8383

8484
<Frame>
85-
![](/images/references/edit-delete-table-calc-520776c8631697527bf3760000dce88e.jpg)
85+
![](/images/guides/table-calculations/edit-delete-table-calc-520776c8631697527bf3760000dce88e.jpg)
8686
</Frame>
8787

8888

@@ -102,7 +102,7 @@ Since all calculations are performed before filtering, table calculation filters
102102
For example: You use table calculations to calculate the `percentage_of_shipping_method_amount`, then filter to hide rows below 30%. The filtered rows (shown in purple) will disappear but the `percentage_total` calculation still shows 100% even though the visible percentages in the `percentage_of_shipping_method_amount` column no longer add up to 100%.
103103

104104
<Frame>
105-
![](/images/references/table_calculation_filter_example.jpg)
105+
![](/images/guides/table-calculations/table_calculation_filter_example.jpg)
106106
</Frame>
107107

108108
## Table calculation SQL templates

images/guides/dbt-repo-example.png renamed to images/get-started/develop-in-lightdash/adding-tables-to-lightdash/dbt-repo-example.png

File renamed without changes.

images/get-started/exploring-data/dashboards/save-your-chart.png renamed to images/get-started/exploring-data/using-explores/save-your-chart.png

File renamed without changes.

images/references/add-table-calc-sql-20de5398dc117ef3d4087cf3b6d9939b.jpg renamed to images/guides/table-calculations/add-table-calc-sql-20de5398dc117ef3d4087cf3b6d9939b.jpg

File renamed without changes.

images/references/create-new-table-calc-772add6d063a5122c0a25accf798fbb3.jpg renamed to images/guides/table-calculations/create-new-table-calc-772add6d063a5122c0a25accf798fbb3.jpg

File renamed without changes.

images/references/edit-delete-table-calc-520776c8631697527bf3760000dce88e.jpg renamed to images/guides/table-calculations/edit-delete-table-calc-520776c8631697527bf3760000dce88e.jpg

File renamed without changes.

0 commit comments

Comments
 (0)