Skip to content

Commit ccb3b3a

Browse files
authored
Merge pull request #502 from bioimage-io/download_docs
download documentation for PR preview
2 parents 14e8319 + d173d1c commit ccb3b3a

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

.github/workflows/auto_update_main.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ jobs:
7272
mv tmp_download_counts.json dist/download_counts.json
7373
- name: update partner resources
7474
run: python scripts/update_partner_resources.py
75+
- name: add documentation files to preview
76+
if: github.event_name == 'pull_request'
77+
run: python scripts/download_documentation.py
7578
- name: Upload preview of updated partner resources
7679
if: github.event_name == 'pull_request'
7780
uses: actions/upload-artifact@v2

scripts/download_documentation.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import warnings
2+
from pathlib import Path
3+
4+
import typer
5+
6+
from bioimageio.spec.shared import resolve_source
7+
from utils import yaml
8+
9+
10+
def main(
11+
folder: Path = Path(__file__).parent / "../dist", # nested folders with rdf.yaml files
12+
):
13+
"""Download the documentation file for every rdf.yaml found in (subfolders of) folder"""
14+
if not folder.exists():
15+
warnings.warn(f"{folder} not found")
16+
return
17+
18+
for rdf_path in folder.glob("**/rdf.yaml"):
19+
rdf = yaml.load(rdf_path)
20+
if not isinstance(rdf, dict):
21+
warnings.warn(f"rdf not a dict: {rdf_path}")
22+
continue
23+
24+
doc_uri = rdf.get("documentation")
25+
if not isinstance(doc_uri, str):
26+
warnings.warn(f"rdf['documentation'] not a string: {rdf_path}")
27+
continue
28+
29+
if "." in str(doc_uri):
30+
type_ext = str(doc_uri).split(".")[-1]
31+
else:
32+
type_ext = "md"
33+
34+
resolve_source(doc_uri, output=rdf_path.with_name(f"documentation.{type_ext}"))
35+
36+
37+
if __name__ == "__main__":
38+
typer.run(main)

0 commit comments

Comments
 (0)