Skip to content

Commit a34a36e

Browse files
authored
Merge pull request #252 from common-workflow-language/description2doc
Description2doc
2 parents 0c3e2c5 + dd59179 commit a34a36e

33 files changed

+225
-83
lines changed

draft-3/Workflow.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,8 +378,8 @@ $graph:
378378
extends: "#Process"
379379
documentRoot: true
380380
specialize:
381-
specializeFrom: "#OutputParameter"
382-
specializeTo: "#WorkflowOutputParameter"
381+
- specializeFrom: "#OutputParameter"
382+
specializeTo: "#WorkflowOutputParameter"
383383
doc: |
384384
A workflow describes a set of **steps** and the **dependencies** between
385385
those processes. When a process produces output that will be consumed by a

draft-3/salad/schema_salad/metaschema/metaschema.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,8 +302,8 @@ $graph:
302302
extends: ["#NamedType", "#RecordSchema", "#SchemaDefinedType"]
303303
documentRoot: true
304304
specialize:
305-
specializeFrom: "#RecordField"
306-
specializeTo: "#SaladRecordField"
305+
- specializeFrom: "#RecordField"
306+
specializeTo: "#SaladRecordField"
307307
fields:
308308
- name: abstract
309309
type: ["null", boolean]

v1.0/Process.yml

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ $graph:
9999
As a special case, if the `path` field is provided but the `location`
100100
field is not, an implementation may assign the value of the `path`
101101
field to `location`, and remove the `path` field.
102-
102+
103103
If the `path` contains [POSIX shell metacharacters](http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_02)
104104
(`|`,`&`, `;`, `<`, `>`, `(`,`)`, `$`,`` ` ``, `\`, `"`, `'`,
105105
`<space>`, `<tab>`, and `<newline>`) or characters
@@ -260,7 +260,7 @@ $graph:
260260
must not be used in any other context. The command line tool being
261261
executed must be able to to access the directory at `path` using the POSIX
262262
`opendir(2)` syscall.
263-
263+
264264
If the `path` contains [POSIX shell metacharacters](http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_02)
265265
(`|`,`&`, `;`, `<`, `>`, `(`,`)`, `$`,`` ` ``, `\`, `"`, `'`,
266266
`<space>`, `<tab>`, and `<newline>`) or characters
@@ -305,6 +305,13 @@ $graph:
305305
- name: SchemaBase
306306
type: record
307307
abstract: true
308+
fields:
309+
- name: label
310+
type:
311+
- "null"
312+
- string
313+
jsonldPredicate: "rdfs:label"
314+
doc: "A short, human-readable label of this object."
308315

309316

310317
- name: Parameter
@@ -315,19 +322,6 @@ $graph:
315322
Define an input or output parameter to a process.
316323
317324
fields:
318-
- name: label
319-
type:
320-
- "null"
321-
- string
322-
jsonldPredicate: "rdfs:label"
323-
doc: "A short, human-readable label of this parameter object."
324-
325-
- name: description
326-
type:
327-
- "null"
328-
- string
329-
jsonldPredicate: "rdfs:comment"
330-
doc: "A long, human-readable description of this parameter object."
331325
- name: secondaryFiles
332326
type:
333327
- "null"
@@ -385,6 +379,13 @@ $graph:
385379
indicate whether it is valid to stream file contents using a named
386380
pipe. Default: `false`.
387381
382+
- name: doc
383+
type:
384+
- string?
385+
- string[]?
386+
doc: "A documentation string for this type, or an array of strings which should be concatenated."
387+
jsonldPredicate: "rdfs:comment"
388+
388389

389390
- type: enum
390391
name: Expression
@@ -446,6 +447,10 @@ $graph:
446447
- name: inputBinding
447448
type: [ "null", "#InputBinding" ]
448449
jsonldPredicate: "cwl:inputBinding"
450+
- name: label
451+
type: string?
452+
jsonldPredicate: "rdfs:label"
453+
doc: "A short, human-readable label of this process object."
449454

450455

451456
- name: InputRecordSchema
@@ -685,7 +690,7 @@ $graph:
685690
- string
686691
jsonldPredicate: "rdfs:label"
687692
doc: "A short, human-readable label of this process object."
688-
- name: description
693+
- name: doc
689694
type:
690695
- "null"
691696
- string

v1.0/Workflow.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ $graph:
399399
type: string?
400400
jsonldPredicate: "rdfs:label"
401401
doc: "A short, human-readable label of this process object."
402-
- name: description
402+
- name: doc
403403
type: string?
404404
jsonldPredicate: "rdfs:comment"
405405
doc: "A long, human-readable description of this process object."
@@ -433,8 +433,8 @@ $graph:
433433
extends: "#Process"
434434
documentRoot: true
435435
specialize:
436-
specializeFrom: "#OutputParameter"
437-
specializeTo: "#WorkflowOutputParameter"
436+
- specializeFrom: "#OutputParameter"
437+
specializeTo: "#WorkflowOutputParameter"
438438
doc: |
439439
A workflow describes a set of **steps** and the **dependencies** between
440440
those steps. When a step produces output that will be consumed by a

v1.0/salad/schema_salad/makedoc.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -213,17 +213,27 @@ def __init__(self, toc, j, renderlist, redirects):
213213
("docAfter" not in f))):
214214
self.render_type(f, 1)
215215

216-
def typefmt(self, tp, redirects, nbsp=False):
217-
# type: (Any, Dict[str, str], bool) -> Union[str, unicode]
216+
def typefmt(self, tp, redirects, nbsp=False, jsonldPredicate=None):
217+
# type: (Any, Dict[str, str], bool, Dict[str, str]) -> Union[str, unicode]
218218
global primitiveType
219219
if isinstance(tp, list):
220220
if nbsp and len(tp) <= 3:
221-
return "&nbsp;|&nbsp;".join([self.typefmt(n, redirects) for n in tp])
221+
return "&nbsp;|&nbsp;".join([self.typefmt(n, redirects, jsonldPredicate=jsonldPredicate) for n in tp])
222222
else:
223223
return " | ".join([self.typefmt(n, redirects) for n in tp])
224224
if isinstance(tp, dict):
225225
if tp["type"] == "https://w3id.org/cwl/salad#array":
226-
return "array&lt;%s&gt;" % (self.typefmt(tp["items"], redirects, nbsp=True))
226+
ar = "array&lt;%s&gt;" % (self.typefmt(tp["items"], redirects, nbsp=True))
227+
if jsonldPredicate and "mapSubject" in jsonldPredicate:
228+
if "mapPredicate" in jsonldPredicate:
229+
ar += " | map&lt;%s.%s,&nbsp;%s.%s&gt" % (self.typefmt(tp["items"], redirects),
230+
jsonldPredicate["mapSubject"],
231+
self.typefmt(tp["items"], redirects),
232+
jsonldPredicate["mapPredicate"])
233+
ar += " | map&lt;%s.%s,&nbsp;%s&gt" % (self.typefmt(tp["items"], redirects),
234+
jsonldPredicate["mapSubject"],
235+
self.typefmt(tp["items"], redirects))
236+
return ar
227237
if tp["type"] in ("https://w3id.org/cwl/salad#record", "https://w3id.org/cwl/salad#enum"):
228238
frg = schema.avro_name(tp["name"])
229239
if tp["name"] in redirects:
@@ -345,7 +355,9 @@ def extendsfrom(item, ex):
345355
rfrg = schema.avro_name(i["name"])
346356
tr = "<td><code>%s</code></td><td>%s</td><td>%s</td>"\
347357
"<td>%s</td>" % (
348-
rfrg, self.typefmt(tp, self.redirects), opt,
358+
rfrg, self.typefmt(tp, self.redirects,
359+
jsonldPredicate=i.get("jsonldPredicate")),
360+
"Optional" if opt else "Required",
349361
mistune.markdown(desc))
350362
if opt:
351363
required.append(tr)

v1.0/salad/schema_salad/metaschema/import_include.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,67 @@ This becomes:
110110
}
111111
}
112112
```
113+
114+
115+
## Mixin
116+
117+
During preprocessing traversal, an implementation must resolve `$mixin`
118+
directives. An `$mixin` directive is an object consisting of the field
119+
`$mixin` specifying resource by URI string. If there are additional fields in
120+
the `$mixin` object, these fields override fields in the object which is loaded
121+
from the `$mixin` URI.
122+
123+
The URI string must be resolved to an absolute URI using the link resolution
124+
rules described previously. Implementations must support loading from `file`,
125+
`http` and `https` resources. The URI referenced by `$mixin` must be loaded
126+
and recursively preprocessed as a Salad document. The external imported
127+
document must inherit the context of the importing document, however the file
128+
URI for processing the imported document must be the URI used to retrieve the
129+
imported document. The `$mixin` URI must not include a document fragment.
130+
131+
Once loaded and processed, the `$mixin` node is replaced in the document
132+
structure by the object or array yielded from the import operation.
133+
134+
URIs may reference document fragments which refer to specific an object in
135+
the target document. This indicates that the `$mixin` node must be
136+
replaced by only the object with the appropriate fragment identifier.
137+
138+
It is a fatal error if an import directive refers to an external resource
139+
or resource fragment which does not exist or is not accessible.
140+
141+
### Mixin example
142+
143+
mixin.yml:
144+
```
145+
{
146+
"hello": "world",
147+
"carrot": "orange"
148+
}
149+
150+
```
151+
152+
parent.yml:
153+
```
154+
{
155+
"form": {
156+
"bar": {
157+
"$mixin": "mixin.yml"
158+
"carrot": "cake"
159+
}
160+
}
161+
}
162+
163+
```
164+
165+
This becomes:
166+
167+
```
168+
{
169+
"form": {
170+
"bar": {
171+
"hello": "world",
172+
"carrot": "cake"
173+
}
174+
}
175+
}
176+
```

v1.0/salad/schema_salad/metaschema/metaschema.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,13 +140,15 @@ $graph:
140140
jsonldPredicate:
141141
_id: "sld:specializeFrom"
142142
_type: "@id"
143+
refScope: 1
143144

144145
- name: specializeTo
145146
type: string
146147
doc: "The new data type to replace with"
147148
jsonldPredicate:
148149
_id: "sld:specializeTo"
149150
_type: "@id"
151+
refScope: 1
150152

151153

152154
- name: NamedType
@@ -168,7 +170,7 @@ $graph:
168170
- string?
169171
- string[]?
170172
doc: "A documentation string for this type, or an array of strings which should be concatenated."
171-
jsonldPredicate: "sld:doc"
173+
jsonldPredicate: "rdfs:comment"
172174

173175
- name: docParent
174176
type: string?
@@ -242,8 +244,7 @@ $graph:
242244
extends: [NamedType, RecordSchema, SchemaDefinedType]
243245
documentRoot: true
244246
specialize:
245-
specializeFrom: "#RecordField"
246-
specializeTo: "#SaladRecordField"
247+
RecordField: SaladRecordField
247248
fields:
248249
- name: abstract
249250
type: boolean?
@@ -271,7 +272,10 @@ $graph:
271272
base record as a template. For each field inherited from the base
272273
record, replace any instance of the type `specializeFrom` with
273274
`specializeTo`.
274-
275+
jsonldPredicate:
276+
_id: "sld:specialize"
277+
mapSubject: specializeFrom
278+
mapPredicate: specializeTo
275279

276280
- name: SaladEnumSchema
277281
type: record

v1.0/salad/schema_salad/metaschema/metaschema_base.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ $graph:
5353
type: string?
5454
doc: |
5555
A documentation string for this field
56-
jsonldPredicate: "sld:doc"
56+
jsonldPredicate: "rdfs:comment"
5757

5858
type:
5959
type:

0 commit comments

Comments
 (0)