Skip to content

Commit b88caa3

Browse files
Add test to validate markdown files referenced in mkdocs.yml (#1730)
* add the test case for checking the test links * add the test case for checking the test links and update mkdocs
1 parent 064f6d2 commit b88caa3

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

docs/mkdocs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ nav:
3232
- ReAct: deep-dive/modules/react.md
3333
- MultiChainComparison: deep-dive/modules/multi-chain-comparison.md
3434
- ProgramOfThought: deep-dive/modules/program-of-thought.md
35-
- Assertions: deep-dive/modules/assertions.md
35+
- Assertions: deep-dive/assertions.md
3636
- Retreive: deep-dive/modules/retrieve.md
3737
- Modules Guide: deep-dive/modules/guide.md
3838
- Metrics and Assertions:

tests/docs/test_mkdocs_links.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
2+
3+
import pytest
4+
import os
5+
6+
def test_nav_files_exist():
7+
# Read mkdocs.yml
8+
docs_dir = os.path.join(os.path.dirname(__file__), '..', '..', 'docs', 'docs')
9+
yaml_path = os.path.join(os.path.dirname(__file__), '..', '..', 'docs', 'mkdocs.yml')
10+
11+
# Read file and extract nav section
12+
with open(yaml_path) as f:
13+
content = f.read()
14+
15+
# Find nav section
16+
nav_start = content.find('nav:')
17+
lines = content[nav_start:].split('\n')
18+
19+
# Get markdown files
20+
md_files = []
21+
for line in lines:
22+
if '.md' in line:
23+
# Extract the markdown filename and clean it up
24+
md_file = line.strip().split(':')[-1].strip()
25+
# Remove list markers and quotes
26+
md_file = md_file.lstrip('- ').strip("'").strip('"')
27+
if md_file.endswith('.md'):
28+
md_files.append(md_file)
29+
30+
# Check if files exist
31+
missing = []
32+
for file in md_files:
33+
if not os.path.exists(os.path.join(docs_dir, file)):
34+
missing.append(file)
35+
36+
print("\nChecking files in:", docs_dir)
37+
print("Found MD files:", md_files)
38+
print("Missing files:", missing)
39+
40+
assert not missing, f"Missing files: {missing}"

0 commit comments

Comments
 (0)