Skip to content

Commit 2b30255

Browse files
committed
docs: intersphinx links, other cleanups
1 parent 3e75295 commit 2b30255

File tree

6 files changed

+104
-71
lines changed

6 files changed

+104
-71
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ EXTRAS=
2828
# `[[` conditional expressions.
2929
PYSOURCES=$(filter-out $(MODULE)/parser/cwl_v%,$(shell find $(MODULE) -name "*.py")) \
3030
$(wildcard tests/*.py) create_cwl_from_objects.py load_cwl_by_path.py \
31-
setup.py ${MODULE}/parser/cwl_v1_?_utils.py
31+
setup.py ${MODULE}/parser/cwl_v1_?_utils.py docs/conf.py
3232
DEVPKGS=diff_cover black pylint pep257 pydocstyle flake8 tox tox-pyenv \
3333
isort wheel autoflake flake8-bugbear pyupgrade bandit \
3434
-rtest-requirements.txt -rmypy-requirements.txt

cwl_utils/cite_extract.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111

1212
def arg_parser() -> argparse.ArgumentParser:
13-
"""Argument parser."""
13+
"""Construct the argument parser."""
1414
parser = argparse.ArgumentParser(
1515
description="Print information about software used in a CWL document (Workflow or CommandLineTool). "
1616
"For CWL Workflows, all steps will also be searched (recursively)."

cwl_utils/parser/__init__.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,36 @@
1414
LoadingOptions = Union[
1515
cwl_v1_0.LoadingOptions, cwl_v1_1.LoadingOptions, cwl_v1_2.LoadingOptions
1616
]
17+
"""Type union for a CWL v1.x LoadingOptions object."""
1718
Saveable = Union[cwl_v1_0.Saveable, cwl_v1_1.Saveable, cwl_v1_2.Saveable]
19+
"""Type union for a CWL v1.x Savable object."""
1820
Workflow = Union[cwl_v1_0.Workflow, cwl_v1_1.Workflow, cwl_v1_2.Workflow]
21+
"""Type union for a CWL v1.x Workflow object."""
1922
WorkflowTypes = (cwl_v1_0.Workflow, cwl_v1_1.Workflow, cwl_v1_2.Workflow)
2023
WorkflowStep = Union[
2124
cwl_v1_0.WorkflowStep, cwl_v1_1.WorkflowStep, cwl_v1_2.WorkflowStep
2225
]
26+
"""Type union for a CWL v1.x WorkflowStep object."""
2327
CommandLineTool = Union[
2428
cwl_v1_0.CommandLineTool, cwl_v1_1.CommandLineTool, cwl_v1_2.CommandLineTool
2529
]
30+
"""Type union for a CWL v1.x CommandLineTool object."""
2631
ExpressionTool = Union[
2732
cwl_v1_0.ExpressionTool, cwl_v1_1.ExpressionTool, cwl_v1_2.ExpressionTool
2833
]
34+
"""Type union for a CWL v1.x ExpressionTool object."""
2935
DockerRequirement = Union[
3036
cwl_v1_0.DockerRequirement, cwl_v1_1.DockerRequirement, cwl_v1_2.DockerRequirement
3137
]
38+
"""Type union for a CWL v1.x DockerRequirement object."""
3239
DockerRequirementTypes = (
3340
cwl_v1_0.DockerRequirement,
3441
cwl_v1_1.DockerRequirement,
3542
cwl_v1_2.DockerRequirement,
3643
)
44+
Process = Union[Workflow, CommandLineTool, ExpressionTool, cwl_v1_2.Operation]
45+
"""Type Union for a CWL v1.x Process object."""
46+
3747
_Loader = Union[cwl_v1_0._Loader, cwl_v1_1._Loader, cwl_v1_2._Loader]
3848

3949

@@ -52,11 +62,9 @@ def _get_id_from_graph(yaml: MutableMapping[str, Any], id_: Optional[str]) -> An
5262
def cwl_version(yaml: Any) -> Optional[str]:
5363
"""Return the cwlVersion of a YAML object.
5464
55-
Args:
56-
yaml: A YAML object
65+
:param yaml: ruamel.yaml object for a CWL document
5766
58-
Raises:
59-
ValidationException: If `yaml` is not a MutableMapping.
67+
:raises ValidationException: If `yaml` is not a MutableMapping.
6068
"""
6169
if not isinstance(yaml, MutableMapping):
6270
raise ValidationException("MutableMapping is required")
@@ -162,7 +170,7 @@ def save(
162170
base_url: str = "",
163171
relative_uris: bool = True,
164172
) -> Any:
165-
"""Convert a given CWL object into a built-in typed object."""
173+
"""Convert a CWL Python object into a JSON/YAML serializable object."""
166174
if (
167175
isinstance(val, cwl_v1_0.Saveable)
168176
or isinstance(val, cwl_v1_1.Saveable)
@@ -194,6 +202,7 @@ def save(
194202

195203

196204
def is_process(v: Any) -> bool:
205+
"""Test to see if the object is a CWL v1.x Python Process object."""
197206
return (
198207
isinstance(v, cwl_v1_0.Process)
199208
or isinstance(v, cwl_v1_1.Process)
@@ -202,4 +211,5 @@ def is_process(v: Any) -> bool:
202211

203212

204213
def version_split(version: str) -> MutableSequence[int]:
214+
"""Split a cwlVersion value into its numerical components."""
205215
return [int(v) for v in version[1:].split(".")]

cwl_utils/parser/utils.py

Lines changed: 34 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -4,83 +4,76 @@
44

55
from schema_salad.exceptions import ValidationException
66

7-
import cwl_utils.parser
8-
import cwl_utils.parser.cwl_v1_0
9-
import cwl_utils.parser.cwl_v1_0_utils
10-
import cwl_utils.parser.cwl_v1_1
11-
import cwl_utils.parser.cwl_v1_1_utils
12-
import cwl_utils.parser.cwl_v1_2
13-
import cwl_utils.parser.cwl_v1_2_utils
7+
from . import (
8+
Process,
9+
Workflow,
10+
cwl_v1_0,
11+
cwl_v1_0_utils,
12+
cwl_v1_1,
13+
cwl_v1_1_utils,
14+
cwl_v1_2,
15+
cwl_v1_2_utils,
16+
)
1417

1518

16-
def convert_stdstreams_to_files(
17-
process: Union[
18-
cwl_utils.parser.Workflow,
19-
cwl_utils.parser.CommandLineTool,
20-
cwl_utils.parser.ExpressionTool,
21-
]
22-
) -> None:
19+
def convert_stdstreams_to_files(process: Process) -> None:
2320
"""Convert stdin, stdout and stderr type shortcuts to files."""
24-
if isinstance(process, cwl_utils.parser.cwl_v1_0.CommandLineTool):
25-
cwl_utils.parser.cwl_v1_0_utils.convert_stdstreams_to_files(process)
26-
elif isinstance(process, cwl_utils.parser.cwl_v1_1.CommandLineTool):
27-
cwl_utils.parser.cwl_v1_1_utils.convert_stdstreams_to_files(process)
28-
elif isinstance(process, cwl_utils.parser.cwl_v1_2.CommandLineTool):
29-
cwl_utils.parser.cwl_v1_2_utils.convert_stdstreams_to_files(process)
21+
if isinstance(process, cwl_v1_0.CommandLineTool):
22+
cwl_v1_0_utils.convert_stdstreams_to_files(process)
23+
elif isinstance(process, cwl_v1_1.CommandLineTool):
24+
cwl_v1_1_utils.convert_stdstreams_to_files(process)
25+
elif isinstance(process, cwl_v1_2.CommandLineTool):
26+
cwl_v1_2_utils.convert_stdstreams_to_files(process)
3027

3128

3229
def type_for_source(
33-
process: Union[
34-
cwl_utils.parser.CommandLineTool,
35-
cwl_utils.parser.Workflow,
36-
cwl_utils.parser.ExpressionTool,
37-
],
30+
process: Process,
3831
sourcenames: Union[str, List[str]],
39-
parent: Optional[cwl_utils.parser.Workflow] = None,
32+
parent: Optional[Workflow] = None,
4033
linkMerge: Optional[str] = None,
4134
pickValue: Optional[str] = None,
4235
) -> Any:
4336
"""Determine the type for the given sourcenames."""
4437
if process.cwlVersion == "v1.0":
45-
cwl_utils.parser.cwl_v1_0_utils.type_for_source(
38+
cwl_v1_0_utils.type_for_source(
4639
cast(
4740
Union[
48-
cwl_utils.parser.cwl_v1_0.CommandLineTool,
49-
cwl_utils.parser.cwl_v1_0.Workflow,
50-
cwl_utils.parser.cwl_v1_0.ExpressionTool,
41+
cwl_v1_0.CommandLineTool,
42+
cwl_v1_0.Workflow,
43+
cwl_v1_0.ExpressionTool,
5144
],
5245
process,
5346
),
5447
sourcenames,
55-
cast(cwl_utils.parser.cwl_v1_0.Workflow, parent),
48+
cast(Optional[cwl_v1_0.Workflow], parent),
5649
linkMerge,
5750
)
5851
elif process.cwlVersion == "v1.1":
59-
cwl_utils.parser.cwl_v1_1_utils.type_for_source(
52+
cwl_v1_1_utils.type_for_source(
6053
cast(
6154
Union[
62-
cwl_utils.parser.cwl_v1_1.CommandLineTool,
63-
cwl_utils.parser.cwl_v1_1.Workflow,
64-
cwl_utils.parser.cwl_v1_1.ExpressionTool,
55+
cwl_v1_1.CommandLineTool,
56+
cwl_v1_1.Workflow,
57+
cwl_v1_1.ExpressionTool,
6558
],
6659
process,
6760
),
6861
sourcenames,
69-
cast(cwl_utils.parser.cwl_v1_1.Workflow, parent),
62+
cast(Optional[cwl_v1_1.Workflow], parent),
7063
linkMerge,
7164
)
7265
elif process.cwlVersion == "v1.2":
73-
cwl_utils.parser.cwl_v1_2_utils.type_for_source(
66+
cwl_v1_2_utils.type_for_source(
7467
cast(
7568
Union[
76-
cwl_utils.parser.cwl_v1_2.CommandLineTool,
77-
cwl_utils.parser.cwl_v1_2.Workflow,
78-
cwl_utils.parser.cwl_v1_2.ExpressionTool,
69+
cwl_v1_2.CommandLineTool,
70+
cwl_v1_2.Workflow,
71+
cwl_v1_2.ExpressionTool,
7972
],
8073
process,
8174
),
8275
sourcenames,
83-
cast(cwl_utils.parser.cwl_v1_2.Workflow, parent),
76+
cast(Optional[cwl_v1_2.Workflow], parent),
8477
linkMerge,
8578
pickValue,
8679
)

docs/_static/favicon.ico

14.7 KB
Binary file not shown.

docs/conf.py

Lines changed: 53 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#
33
# This file only contains a selection of the most common options. For a full
44
# list see the documentation:
5-
# http://www.sphinx-doc.org/en/master/config
5+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
66

77
# -- Path setup --------------------------------------------------------------
88

@@ -12,14 +12,20 @@
1212
#
1313
import os
1414
import sys
15-
sys.path.insert(0, os.path.abspath('..'))
15+
import time
16+
from datetime import datetime
17+
18+
sys.path.insert(0, os.path.abspath(".."))
1619

1720

1821
# -- Project information -----------------------------------------------------
1922

20-
project = 'cwl-utils'
21-
copyright = '2019, CWL Community'
22-
author = 'CWL Community'
23+
build_date = datetime.utcfromtimestamp(
24+
int(os.environ.get("SOURCE_DATE_EPOCH", time.time()))
25+
)
26+
project = "cwl-utils: Python utilities Common Workflow Language documents"
27+
copyright = f"2019 — {build_date.year} CWL Community"
28+
author = "Common Workflow Language Project contributors"
2329

2430

2531
# -- General configuration ---------------------------------------------------
@@ -28,22 +34,31 @@
2834
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
2935
# ones.
3036
extensions = [
31-
"sphinx.ext.autodoc",
32-
"sphinx.ext.autosummary",
33-
"sphinx.ext.inheritance_diagram",
34-
"autoapi.extension",
35-
"sphinx_autodoc_typehints",
36-
"sphinx_rtd_theme",
37-
"sphinxcontrib.autoprogram"
37+
"sphinx.ext.autodoc",
38+
"sphinx.ext.autosummary",
39+
"sphinx.ext.intersphinx",
40+
"sphinx.ext.inheritance_diagram",
41+
"autoapi.extension",
42+
"sphinx_autodoc_typehints",
43+
"sphinx_rtd_theme",
44+
"sphinxcontrib.autoprogram",
3845
]
3946

47+
intersphinx_mapping = {
48+
"python": ("https://docs.python.org/3", None),
49+
"schema_salad": ("https://schema-salad.readthedocs.io/en/stable/", None),
50+
"rdflib": ("https://rdflib.readthedocs.io/en/6.2.0/", None),
51+
# "ruamel.yaml": ("https://yaml.readthedocs.io/en/stable/", None),
52+
}
53+
54+
4055
# Add any paths that contain templates here, relative to this directory.
41-
templates_path = ['_templates']
56+
templates_path = ["_templates"]
4257

4358
# List of patterns, relative to source directory, that match files and
4459
# directories to ignore when looking for source files.
4560
# This pattern also affects html_static_path and html_extra_path.
46-
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
61+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
4762

4863

4964
# -- Options for HTML output -------------------------------------------------
@@ -53,22 +68,37 @@
5368
#
5469
html_theme = "sphinx_rtd_theme"
5570

71+
# html_logo = "_static/logo.png"
72+
html_favicon = "_static/favicon.ico"
73+
74+
html_theme_options = {
75+
"collapse_navigation": False,
76+
}
77+
5678
# Add any paths that contain custom static files (such as style sheets) here,
5779
# relative to this directory. They are copied after the builtin static files,
5880
# so a file named "default.css" will overwrite the builtin "default.css".
59-
html_static_path = ['_static']
81+
html_static_path = ["_static"]
6082

6183
from pkg_resources import get_distribution
62-
release = get_distribution('cwl-utils').version
63-
version = '.'.join(release.split('.')[:2])
6484

65-
autoapi_dirs = ['../cwl_utils']
66-
autodoc_typehints = 'description'
85+
release = get_distribution("cwl-utils").version
86+
version = ".".join(release.split(".")[:2])
87+
88+
autoapi_dirs = ["../cwl_utils"]
89+
autodoc_typehints = "description"
6790
autoapi_keep_files = True
68-
autoapi_ignore = ['*migrations*', '*.pyi']
69-
autoapi_options = [ 'members', 'undoc-members', 'show-inheritance', 'show-inheritance-diagram', 'show-module-summary', 'imported-members', 'special-members' ]
70-
#sphinx-autodoc-typehints
91+
autoapi_ignore = ["*migrations*", "*.pyi"]
92+
autoapi_options = [
93+
"members",
94+
"undoc-members",
95+
"show-inheritance",
96+
"show-inheritance-diagram",
97+
"show-module-summary",
98+
"imported-members",
99+
"special-members",
100+
]
101+
# sphinx-autodoc-typehints
71102
always_document_param_types = True
72103
# If False, do not add type info for undocumented parameters.
73104
# If True, add stub documentation for undocumented parameters to be able to add type info.
74-

0 commit comments

Comments
 (0)