Skip to content

Commit 7cbf7a1

Browse files
authored
πŸ›πŸ“ Fixes and tests links on the doc (#188)
1 parent bd2aa4f commit 7cbf7a1

File tree

2 files changed

+42
-7
lines changed

2 files changed

+42
-7
lines changed

β€Žclients/python/test/tests_docs.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import pytest
2+
import sys
3+
import re
4+
from pathlib import Path
5+
6+
_CURRENT_DIR = (
7+
Path(sys.argv[0] if __name__ == "__main__" else __file__).resolve().parent
8+
)
9+
_REPO_DIR = _CURRENT_DIR.parent.parent.parent
10+
_DOCS_DIR = _REPO_DIR / "docs"
11+
12+
assert _DOCS_DIR.exists
13+
14+
_MD_LINK_PATTERN = re.compile(r"\[(.*?)\]\((.*?)\)")
15+
16+
17+
def _collect_links():
18+
def _extract_file_links(markdown_file: Path) -> tuple[Path, str, str]:
19+
content = markdown_file.read_text()
20+
# Find all markdown links (e.g., [text](path/to/file))
21+
links = _MD_LINK_PATTERN.findall(content)
22+
return [(markdown_file, text, file_link) for text, file_link in links]
23+
24+
links = []
25+
for md_file in _DOCS_DIR.rglob("*.md"):
26+
links.extend(_extract_file_links(md_file))
27+
return links
28+
29+
30+
@pytest.mark.parametrize("md_file, link_text, file_link", _collect_links())
31+
def test_markdown_links(md_file: Path, link_text: str, file_link: str):
32+
if file_link.startswith("http"):
33+
pytest.skip(f"External link skipped: {file_link}")
34+
35+
# NOTE: that current doc only support relative to repo!
36+
relative_to_repo = (_REPO_DIR / file_link).resolve()
37+
38+
assert (
39+
relative_to_repo.exists()
40+
), f"Broken link found: [{link_text}]({file_link}) in {md_file}"

β€Ždocs/doc_entrypoint.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,10 @@ pip install osparc
2424

2525
## Getting Started with `osparc`
2626

27-
To begin using `osparc`, simply import the package and refer to the detailed examples provided in the [official documentation](https://github.com/your-username/osparc/wiki).
2827

2928
### API Key/Secret Setup
3029

31-
Before interacting with the osparc API, you need to generate an API key-secret pair from your osparc account. Follow the [instructions here](https://docs.osparc.io/#/docs/platform_introduction/profile?id=preferences) to create the key and secret.
30+
Before interacting with the osparc API, you need to generate an API key-secret pair from your osparc account. Follow the [instructions here](https://docs.osparc.io/#/docs/platform_introduction/user_setup/security_details?id=generating-o%c2%b2s%c2%b2parc-tokens) to create the key and secret.
3231

3332
Once generated, you can configure them by either:
3433

@@ -79,13 +78,9 @@ For more in-depth usage, refer to the following tutorial guides:
7978
- [Version 0.6 Documentation](clients/python/docs/v0.6.0/README.md)
8079

8180

82-
## Contributing
83-
84-
We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details on how to get involved.
85-
8681
## License
8782

88-
This project is licensed under the MIT License. See the [LICENSE](../LICENSE) file for details.
83+
This project is licensed under the MIT License. See the [LICENSE](./LICENSE) file for details.
8984

9085
---
9186

0 commit comments

Comments
Β (0)