8000 Add documentation for classes and change docstring. Update name of th… · phenoflow/python-cwlgen@c59c081 · GitHub
[go: up one dir, main page]

Skip to content

Commit c59c081

Browse files
committed
Add documentation for classes and change docstring. Update name of the library for import in Python
1 parent eafe4e7 commit c59c081

File tree

5 files changed

+211
-65
lines changed

5 files changed

+211
-65
lines changed

cwlgen/__init__.py

Lines changed: 109 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,34 @@
3434

3535
class CommandLineTool(object):
3636
'''
37-
Contain all informations to describe a CWL command line tool
37+
Contain all informations to describe a CWL command line tool.
3838
'''
3939

4040
def __init__(self, tool_id=None, base_command=None, label=None, doc=None,\
4141
cwl_version=DEF_CWL_VERSION, stdin=None, stderr=None, stdout=None):
4242
'''
43-
tool_id: unique identifier for this tool [STRING]
44-
10000 base_command: command line for the tool [STRING]
45-
label: label of this tool [STRING]
46-
doc: documentation for the tool [STRING]
47-
cwl_version: [STRING]
48-
stdin: path to a file whose contents must be piped into stdin [STRING]
49-
stderr: capture stderr into the file [STRING]
50-
stdout: capture stdout into the file [STRING]
43+
:param tool_id: unique identifier for this tool.
44+
:type tool_id: STRING
45+
:param base_command: command line for the tool.
46+
:type base_command: STRING
47+
:param label: label of this tool.
48+
:type label: STRING
49+
:param doc: documentation for the tool, usually longer than the label.
50+
:type doc: STRING
51+
:param cwl_version: version of the CWL tool.
52+
:type cwl_version: STRING
53+
:param stdin: path to a file whose contents must be piped into stdin.
54+
:type stdin: STRING
55+
:param stderr: capture stderr into the given file.
56+
:type stderr: STRING
57+
:param stdout: capture stdout into the given file.
58+
:type stdout: STRING
59+
60+
Inputs (:class:`cwlgen.CommandInputParameter` objects),
61+
outputs (:class:`cwlgen.CommandOutputParameter` objects),
62+
arguments (:class:`cwlgen.CommandLineBinding` objects)
63+
and requirements (:class:`cwlgen.Requirement` objects)
64+
are stored in lists which are initialized empty.
5165
'''
5266
self.tool_id = tool_id
5367
self.base_command = base_command
@@ -68,7 +82,7 @@ def __init__(self, tool_id=None, base_command=None, label=None, doc=None,\
6882

6983
def export(self, outfile=None):
7084
'''
71-
Export the tool in CWL
85+
Export the tool in CWL either on STDOUT or in outfile
7286
'''
7387
cwl_tool = {}
7488
cwl_tool['cwlVersion'] = self.cwl_version
@@ -153,23 +167,32 @@ def get_dict(self):
153167

154168
class CommandInputParameter(Parameter):
155169
'''
156-
An input parameter for a CommandLineTool
170+
An input parameter for a :class:`cwlgen.CommandLineTool`.
157171
'''
158172

159173
def __init__(self, param_id, label=None, secondary_files=None, param_format=None,\
160174
streamable=False, doc=None, input_binding=None, default=None, param_type=None):
161175
'''
162-
param_id: unique identifier for this parameter [STRING]
163-
label: short, human-readable label [STRING]
164-
secondary_files: If type is a file, describes files that must be included alongside
165-
the primary file(s) [STRING]
166-
param_format: If type is a file, uri to ontology of the format or exact format [STRING]
167-
streamable: If type is a file, true indicates that the file is read or written
168-
sequentially without seeking [BOOLEAN]
169-
doc: documentation [STRING]
170-
input_binding: describes how to handle the input [CommandLineBinding]
171-
default: default value [STRING]
172-
param_type: type of data assigned to the parameter [STRING] corresponding to CWLType
176+
:param param_id: unique identifier for this parameter.
177+
:type param_id: STRING
178+
:param label: short, human-readable label.
179+
:type label: STRING
180+
:param secondary_files: If type is a file, describes files that must be
181+
included alongside the primary file(s).
182+
:type secondary_files: STRING
183+
:param param_format: If type is a file, uri to ontology of the format or exact format.
184+
:type param_format: STRING
185+
:param streamable: If type is a file, true indicates that the file is read or written
186+
sequentially without seeking.
187+
:type streamable: BOOLEAN
188+
:param doc: documentation.
189+
:type doc: STRING
190+
:param input_binding: describes how to handle the input.
191+
:type input_binding: :class:`cwlgen.CommandLineBinding` object
192+
:param default: default value.
193+
:type default: STRING
194+
:param param_type: type of data assigned to the parameter corresponding to CWLType.
195+
:type param_type: STRING
173196
'''
174197
Parameter.__init__(self, param_id=param_id, label=label, \
175198
secondary_files=secondary_files, param_format=param_format,\
@@ -179,7 +202,7 @@ def __init__(self, param_id, label=None, secondary_files=None, param_format=None
179202

180203
def get_dict(self):
181204
'''
182-
Transform the object to a [DICT] to write CWL
205+
Transform the object to a [DICT] to write CWL.
183206
'''
184207
dict_in = Parameter.get_dict(self)
185208
if self.default:
@@ -191,30 +214,38 @@ def get_dict(self):
191214

192215
class CommandOutputParameter(Parameter):
193216
'''
194-
An output parameter for a CommandLineTool
217+
An output parameter for a :class:`cwlgen.CommandLineTool`.
195218
'''
196219

197220
def __init__(self, param_id, label=None, secondary_files=None, param_format=None,\
198221
streamable=False, doc=None, output_binding=None, param_type=None):
199222
'''
200-
param_id: unique identifier for this parameter [STRING]
201-
label: short, human-readable label [STRING]
202-
secondary_files: If type is a file, describes files that must be included alongside
203-
the primary file(s) [STRING]
204-
param_format: If type is a file, uri to ontology of the format or exact format [STRING]
205-
streamable: If type is a file, true indicates that the file is read or written
206-
sequentially without seeking [BOOLEAN]
207-
doc: documentation [STRING]
208-
output_binding: describes how to handle the input [CommandOutputBinding]
209-
param_type: type of data assigned to the parameter [STRING] corresponding to CWLType
223+
:param param_id: unique identifier for this parameter.
224+
:type param_id: STRING
225+
:param label: short, human-readable label.
226+
:type label: STRING
227+
:param secondary_files: If type is a file, describes files that must be
228+
included alongside the primary file(s).
229+
:type secondary_files: STRING
230+
:param param_format: If type is a file, uri to ontology of the format or exact format.
231+
:type param_format: STRING
232+
:param streamable: If type is a file, true indicates that the file is read or written
233+
sequentially without seeking.
234+
:type streamable: BOOLEAN
235+
:param doc: documentation.
236+
:type doc: STRING
237+
:param output_binding: describes how to handle the output.
238+
:type output_binding: :class:`cwlgen.CommandOutputBinding` object
239+
:param param_type: type of data assigned to the parameter corresponding to CWLType.
240+
:type param_type: STRING
210241
'''
211242
Parameter.__init__(self, param_id, label, secondary_files, param_format, streamable,\
212243
doc, param_type)
213244
self.output_binding = output_binding
214245

215246
def get_dict(self):
216247
'''
217-
Transform the object to a [DICT] to write CWL
248+
Transform the object to a [DICT] to write CWL.
218249
'''
219250
dict_out = Parameter.get_dict(self)
220251
if self.output_binding:
@@ -224,19 +255,26 @@ def get_dict(self):
224255

225256
class CommandLineBinding(object):
226257
'''
227-
Describes how the handle input or argument
258+
Describes how the handle an input or an argument.
228259
'''
229260

230261
def __init__(self, load_contents=False, position=None, prefix=None, separate=False,\
231262
item_separator=None, value_from=None, shell_quote=False):
232263
'''
233-
load_contents: [BOOLEAN]
234-
position: [INT]
235-
prefix: [STRING]
236-
separate: [BOOLEAN]
237-
item_separator: [STRING]
238-
value_from: [STRING]
239-
shell_quote: [BOOLEAN]
264+
:param load_contents:
265+
:type load_contents: BOOLEAN
266+
:param position:
267+
:type positio: INT
268+
:param prefix:
269+
:type prefix: STRING
270+
:param separate:
271+
:type separate: BOOLEAN
272+
:param item_separator:
273+
:type item_separator: STRING
274+
:param value_from:
275+
:type value_from: STRING
276+
:param shell_quote:
277+
:type shell_quote: BOOLEAN
240278
'''
241279
self.load_contents = load_contents
242280
self.position = position
@@ -248,7 +286,7 @@ def __init__(self, load_contents=False, position=None, prefix=None, separate=Fal
248286

249287
def get_dict(self):
250288
'''
251-
Transform the object to a [DICT] to write CWL
289+
Transform the object to a [DICT] to write CWL.
252290
'''
253291
dict_binding = {}
254292
if self.load_contents:
@@ -271,23 +309,26 @@ def get_dict(self):
271309

272310
class CommandOutputBinding(object):
273311
'''
274-
Describes how to generate an output parameter based on the files produced
312+
Describes how to generate an output parameter based on the files produced.
275313
'''
276314

277315
def __init__(self, glob=False, load_contents=False, output_eval=None):
278316
'''
279-
glob: Find corresponding file(s) [STRING]
280-
load_contents: For each file matched, read up to the 1st 64 KiB of text and
281-
place it in the contents field [BOOLEAN]
282-
output_eval: Evaluate an expression to generate the output value [STRING]
317+
:param glob: Find corresponding file(s).
318+
:type glob: STRING
319+
:param load_contents: For each file matched, read up to the 1st 64 KiB of text and
320+
place it in the contents field.
321+
:type load_contents: BOOLEAN
322+
:param output_eval: Evaluate an expression to generate the output value.
323+
:type output_eval: STRING
283324
'''
284325
self.glob = glob
285326
self.load_contents = load_contents
286327
self.output_eval = output_eval
287328

288329
def get_dict(self):
289330
'''
290-
Transform the object to a [DICT] to write CWL
331+
Transform the object to a [DICT] to write CWL.
291332
'''
292333
dict_binding = {}
293334
if self.glob:
@@ -301,24 +342,26 @@ def get_dict(self):
301342

302343
class Requirement(object):
303344
'''
304-
Requirement that must be met in order to execute the process
345+
Requirement that must be met in order to execute the process.
305346
'''
306347

307348
def __init__(self, req_class):
308349
'''
309-
req_class: requirement class [STRING]
350+
:param req_class: requirement class.
351+
:type req_class: STRING
310352
'''
311353
self.req_class = req_class
312354

313355

314356
class InlineJavascriptReq(Requirement):
315357
'''
316-
Workflow platform must support inline Javascript expressions
358+
Workflow platform must support inline Javascript expressions.
317359
'''
318360

319361
def __init__(self, expression_lib=None):
320362
'''
321-
expression_lib: List of [STRING]
363+
:param expression_lib: List of Strings
364+
:type expression_lib: STRING
322365
'''
323366
Requirement.__init__(self, 'InlineJavascriptRequirement')
324367
self.expression_lib = expression_lib
@@ -333,12 +376,18 @@ class DockerRequirement(Requirement):
333376
def __init__(self, docker_pull=None, docker_load=None, docker_file=None,\
334377
docker_import=None, docker_image_id=None, docker_output_dir=None):
335378
'''
336-
docker_pull: image to retrive with docker pull [STRING]
337-
docker_load: HTTP URL from which to download Docker image [STRING]
338-
docker_file: supply the contents of a Dockerfile [STRING]
339-
docker_import: HTTP URL to download and gunzip a Docker images [STRING]
340-
docker_image_id: Image id for docker run [STRING]
341-
docker_output_dir: designated output dir inside the Docker container [STRING]
379+
:param docker_pull: image to retrive with docker pull.
380+
:type docker_pull: STRING
381+
:param docker_load: HTTP URL from which to download Docker image.
382+
:type docker_load: STRING
383+
:param docker_file: supply the contents of a Dockerfile.
384+
:type docker_file: STRING
385+
:param docker_import: HTTP URL to download and gunzip a Docker images.
386+
:type docker_import: STRING
387+
:param docker_image_id: Image id for docker run.
388+
:type docker_image_id: STRING
389+
:param docker_output_dir: designated output dir inside the Docker container.
390+
:type docker_output_dir: STRING
342391
'''
343392
Requirement.__init__(self, 'DockerRequirement')
344393
self.docker_pull = docker_pull

doc/source/classes.rst

Lines changed: 75 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,81 @@
66
API classes
77
***********
88

9+
.. _cwl_tool:
10+
11+
CWL tool
12+
========
13+
914
CommandLineTool
10-
===============
15+
"""""""""""""""
16+
17+
.. autoclass:: cwlgen.CommandLineTool
18+
:members:
19+
:private-members:
20+
:special-members:
21+
22+
.. _in_out:
23+
24+
Input and outputs
25+
=================
26+
27+
CommandInputParameter
28+
"""""""""""""""""""""
29+
30+
.. autoclass:: cwlgen.CommandInputParameter
31+
:members:
32+
:private-members:
33+
:special-members:
34+
35+
CommandOutputParameter
36+
""""""""""""""""""""""
37+
38+
.. autoclass:: cwlgen.CommandOutputParameter
39+
:members:
40< 10000 /td>+
:private-members:
41+
:special-members:
42+
43+
CommandLineBinding
44+
""""""""""""""""""
45+
46+
.. autoclass:: cwlgen.CommandLineBinding
47+
:members:
48+
:private-members:
49+
:special-members:
50+
51+
CommandOutputBinding
52+
""""""""""""""""""""
53+
54+
.. autoclass:: cwlgen.CommandOutputBinding
55+
:members:
56+
:private-members:
57+
:special-members:
58+
59+
.. _requirements:
60+
61+
Requirements
62+
============
63+
64+
Requirement
65+
"""""""""""
66+
67+
.. autoclass:: cwlgen.Requirement
68+
:members:
69+
:private-members:
70+
:special-members:
71+
72+
InLineJavascriptReq
73+
"""""""""""""""""""
74+
75+
.. autoclass:: cwlgen.InLineJavascriptReq
76+
:members:
77+
:private-members:
78+
:special-members:
79+
80+
DockerRequirement
81+
"""""""""""""""""
1182

12-
.. autoclass:: CommandLineTool
83+
.. autoclass:: cwlgen.DockerRequirement
1384
:members:
85+
:private-members:
86+
:special-members:

doc/source/conf.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# -*- coding: utf-8 -*-
22
#
3-
# IntegronFinder documentation build configuration file, created by
4-
# sphinx-quickstart on Mon Jul 27 15:07:43 2015.
3+
# Python-cwlgen documentation build configuration file
54
#
65
# This file is execfile()d with the current directory set to its
76
# containing dir.

0 commit comments

Comments
 (0)
0