forked from nf-core/tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake_lint_md.py
79 lines (65 loc) · 2.39 KB
/
make_lint_md.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/env python
from pathlib import Path
import nf_core.modules.lint
import nf_core.pipelines.lint
import nf_core.subworkflows.lint
def create_docs(docs_basedir, lint_tests, md_template):
docs_basedir.mkdir(parents=True, exist_ok=True)
existing_docs = list(docs_basedir.glob("*.md"))
existing_docs.remove(docs_basedir / "index.md")
for test_name in lint_tests:
fn = docs_basedir / f"{test_name}.md"
if fn.exists():
existing_docs.remove(fn)
else:
with open(fn, "w") as fh:
fh.write(md_template.format(test_name))
for fn in existing_docs:
fn.unlink()
def create_index_file(basedir, title):
index_file = basedir / "index.md"
with open(index_file, "w") as fh:
fh.write(f"# {title}\n\n")
for fn in sorted(basedir.glob("*.md")):
if fn.name != "index.md":
fh.write(f" - [{fn.stem}](./{fn.stem}/)\n")
# Create the pipeline docs
pipeline_lint_docs_basedir = Path(__file__).resolve().parent / "_src" / "pipeline_lint_tests"
create_docs(
pipeline_lint_docs_basedir,
nf_core.pipelines.lint.PipelineLint._get_all_lint_tests(True),
"""# {0}
```{{eval-rst}}
.. automethod:: nf_core.pipelines.lint.PipelineLint.{0}
```
""",
)
create_index_file(pipeline_lint_docs_basedir, "Pipeline Lint Tests")
# Create the modules docs
modules_lint_docs_basedir = Path(__file__).resolve().parent / "_src" / "module_lint_tests"
create_docs(
modules_lint_docs_basedir,
set(nf_core.modules.lint.ModuleLint.get_all_module_lint_tests(is_pipeline=True)).union(
nf_core.modules.lint.ModuleLint.get_all_module_lint_tests(is_pipeline=False)
),
"""# {0}
```{{eval-rst}}
.. automethod:: nf_core.modules.lint.ModuleLint.{0}
```
""",
)
create_index_file(modules_lint_docs_basedir, "Module Lint Tests")
# Create the subworkflow docs
subworkflow_lint_docs_basedir = Path(__file__).resolve().parent / "_src" / "subworkflow_lint_tests"
create_docs(
subworkflow_lint_docs_basedir,
set(nf_core.subworkflows.lint.SubworkflowLint.get_all_subworkflow_lint_tests(is_pipeline=True)).union(
nf_core.subworkflows.lint.SubworkflowLint.get_all_subworkflow_lint_tests(is_pipeline=False)
),
"""# {0}
```{{eval-rst}}
.. automethod:: nf_core.subworkflows.lint.SubworkflowLint.{0}
```
""",
)
create_index_file(subworkflow_lint_docs_basedir, "Subworkflow Lint Tests")