Skip to content
This repository was archived by the owner on Jun 9, 2020. It is now read-only.

Commit 36cc0ff

Browse files
committed
Improve documentation for parse_cwl / parse_cwl_dict on docs
1 parent e955d49 commit 36cc0ff

File tree

2 files changed

+22
-57
lines changed

2 files changed

+22
-57
lines changed

cwlgen/__init__.py

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

1515
from .utils import literal, literal_presenter
1616

17-
from .import_cwl import parse_cwl
17+
from .import_cwl import parse_cwl, parse_cwl_dict
1818

1919
logging.basicConfig(level=logging.INFO)
2020
_LOGGER = logging.getLogger(__name__)

doc/source/classes.rst

Lines changed: 21 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -138,65 +138,30 @@ DockerRequirement
138138
Import CWL
139139
==========
140140

141-
CWLToolParser
142-
"""""""""""""
141+
As of release v0.3.0 the existing importing CWL has been replaced by an
142+
automated deserialization. Each function that inherits from the :class:`Serializable`
143+
class will have a ``parse_dict`` method.
143144

144-
.. autoclass:: cwlgen.import_cwl.CWLToolParser
145-
:members:
146-
:private-members:
147-
:special-members:
148-
:exclude-members: __weakref_
149-
150-
InputsParser
151-
""""""""""""
152-
153-
.. autoclass:: cwlgen.import_cwl.InputsParser
154-
:members:
155-
:private-members:
156-
:special-members:
157-
:exclude-members: __weakref__
158-
159-
InputBindingParser
160-
""""""""""""""""""
161-
162-
.. autoclass:: cwlgen.import_cwl.InputBindingParser
163-
:members:
164-
:private-members:
165-
:special-members:
166-
:exclude-members: __weakref__
167-
168-
OutputsParser
169-
"""""""""""""
170-
171-
.. autoclass:: cwlgen.import_cwl.OutputsParser
172-
:members:
173-
:private-members:
174-
:special-members:
175-
:exclude-members: __weakref__
145+
If you're adding a class and want to provide a hint on how to parse a particular
146+
field, you can add a static ``parse_types`` dictionary onto your class with the
147+
fieldname and a list of types that you want to try and parse as. If your input
148+
can be a list (eg: ``T[]``), or a dictionary with the identifier as the key
149+
(eg: ``{ $identifier: T }``, you can let your type be ``[T]`` in the ``parse_types``
150+
dict. It will automatically inject this identifier in the constructor.
151+
See the ``Serializable.parse_dict`` class for more information.
176152

177-
OutputBindingParser
178-
"""""""""""""""""""
153+
.. code-block:: python
179154
180-
.. autoclass:: cwlgen.import_cwl.OutputBindingParser
181-
:members:
182-
:private-members:
183-
:special-members:
184-
:exclude-members: __weakref__
155+
class Workflow:
156+
parse_types = {
157+
# Parse inputs as : [InputParameter] or { id: InputParameter }
158+
"inputs": [[InputParameter]],
185159
186-
CWLWorkflowParser
187-
"""""""""""""""""
160+
# will attempt to parse extraParam as a string, then SecondaryType,
161+
# then (TertiaryType[] || { $identifier: TertiaryType }
162+
"extraParam": [str, SecondaryType, [TertiaryType]]
163+
}
188164
189-
.. autoclass:: cwlgen.import_cwl.CWLWorkflowParser
190-
:members:
191-
:private-members:
192-
:special-members:
193-
:exclude-members: __weakref__
165+
.. autofunction:: cwlgen.parse_cwl
194166

195-
StepsParser
196-
"""""""""""
197-
198-
.. autoclass:: cwlgen.import_cwl.StepsParser
199-
:members:
200-
:private-members:
201-
:special-members:
202-
:exclude-members: __weakref__
167+
.. autofunction:: cwlgen.parse_cwl_dict

0 commit comments

Comments
 (0)