Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛📝 Fixes and tests links on the doc #188

Merged
merged 4 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions clients/python/test/tests_docs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import pytest
import sys
import re
from pathlib import Path

_CURRENT_DIR = (
Path(sys.argv[0] if __name__ == "__main__" else __file__).resolve().parent
)
_REPO_DIR = _CURRENT_DIR.parent.parent.parent
_DOCS_DIR = _REPO_DIR / "docs"

assert _DOCS_DIR.exists

_MD_LINK_PATTERN = re.compile(r"\[(.*?)\]\((.*?)\)")


def _collect_links():
def _extract_file_links(markdown_file: Path) -> tuple[Path, str, str]:
content = markdown_file.read_text()
# Find all markdown links (e.g., [text](path/to/file))
links = _MD_LINK_PATTERN.findall(content)
return [(markdown_file, text, file_link) for text, file_link in links]

links = []
for md_file in _DOCS_DIR.rglob("*.md"):
links.extend(_extract_file_links(md_file))
return links


@pytest.mark.parametrize("md_file, link_text, file_link", _collect_links())
def test_markdown_links(md_file: Path, link_text: str, file_link: str):
if file_link.startswith("http"):
pytest.skip(f"External link skipped: {file_link}")

# NOTE: that current doc only support relative to repo!
relative_to_repo = (_REPO_DIR / file_link).resolve()

assert (
relative_to_repo.exists()
), f"Broken link found: [{link_text}]({file_link}) in {md_file}"
9 changes: 2 additions & 7 deletions docs/doc_entrypoint.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@ pip install osparc

## Getting Started with `osparc`

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).

### API Key/Secret Setup

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.
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.

Once generated, you can configure them by either:

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


## Contributing

We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details on how to get involved.

## License

This project is licensed under the MIT License. See the [LICENSE](../LICENSE) file for details.
This project is licensed under the MIT License. See the [LICENSE](./LICENSE) file for details.

---

Expand Down
Loading