diff --git a/py/stencila/schema/interpreter.py b/py/stencila/schema/interpreter.py index 136382f3..fa04205a 100644 --- a/py/stencila/schema/interpreter.py +++ b/py/stencila/schema/interpreter.py @@ -628,7 +628,7 @@ def handle_item(self, item: typing.Any, compilation_result: DocumentCompilationR self.traverse_list(item, compilation_result) elif isinstance(item, Entity): if isinstance(item, (CodeChunk, CodeExpression)): - if item.language == self.TARGET_LANGUAGE: # Only add Python code + if item.programmingLanguage == self.TARGET_LANGUAGE: # Only add Python code self.handle_code(item, compilation_result) elif isinstance(item, Parameter) and self.function_depth == 0: diff --git a/py/stencila/schema/types.py b/py/stencila/schema/types.py index 2f2cef1b..833f9126 100644 --- a/py/stencila/schema/types.py +++ b/py/stencila/schema/types.py @@ -9,9 +9,9 @@ EItemListOrder = Enum("ItemListOrder", ["ascending", "descending", "unordered"]) -ETableCellKind = Enum("TableCellKind", ["data", "header"]) +ECellType = Enum("CellType", ["data", "header"]) -ETableRowKind = Enum("TableRowKind", ["header", "footer"]) +ERowType = Enum("RowType", ["header", "footer"]) class Entity: @@ -89,6 +89,7 @@ class Cite(Entity): target: str citationMode: Optional["ECitationMode"] = None + content: Optional[Array["InlineContent"]] = None pageEnd: Optional[Union[str, int]] = None pageStart: Optional[Union[str, int]] = None pagination: Optional[str] = None @@ -99,6 +100,7 @@ def __init__( self, target: str, citationMode: Optional["ECitationMode"] = None, + content: Optional[Array["InlineContent"]] = None, id: Optional[str] = None, meta: Optional[Dict[str, Any]] = None, pageEnd: Optional[Union[str, int]] = None, @@ -115,6 +117,8 @@ def __init__( self.target = target if citationMode is not None: self.citationMode = citationMode + if content is not None: + self.content = content if pageEnd is not None: self.pageEnd = pageEnd if pageStart is not None: @@ -150,14 +154,14 @@ class Code(Entity): """Inline code.""" text: str - language: Optional[str] = None + programmingLanguage: Optional[str] = None def __init__( self, text: str, id: Optional[str] = None, - language: Optional[str] = None, - meta: Optional[Dict[str, Any]] = None + meta: Optional[Dict[str, Any]] = None, + programmingLanguage: Optional[str] = None ) -> None: super().__init__( id=id, @@ -165,8 +169,8 @@ def __init__( ) if text is not None: self.text = text - if language is not None: - self.language = language + if programmingLanguage is not None: + self.programmingLanguage = programmingLanguage class CodeBlock(Code): @@ -176,14 +180,14 @@ def __init__( self, text: str, id: Optional[str] = None, - language: Optional[str] = None, - meta: Optional[Dict[str, Any]] = None + meta: Optional[Dict[str, Any]] = None, + programmingLanguage: Optional[str] = None ) -> None: super().__init__( text=text, id=id, - language=language, - meta=meta + meta=meta, + programmingLanguage=programmingLanguage ) @@ -211,17 +215,17 @@ def __init__( errors: Optional[Array["CodeError"]] = None, id: Optional[str] = None, imports: Optional[Array[Union[str, "SoftwareSourceCode", "SoftwareApplication"]]] = None, - language: Optional[str] = None, meta: Optional[Dict[str, Any]] = None, outputs: Optional[Array["Node"]] = None, + programmingLanguage: Optional[str] = None, reads: Optional[Array[str]] = None, uses: Optional[Array[Union[str, "Variable"]]] = None ) -> None: super().__init__( text=text, id=id, - language=language, - meta=meta + meta=meta, + programmingLanguage=programmingLanguage ) if alters is not None: self.alters = alters @@ -250,14 +254,14 @@ def __init__( self, text: str, id: Optional[str] = None, - language: Optional[str] = None, - meta: Optional[Dict[str, Any]] = None + meta: Optional[Dict[str, Any]] = None, + programmingLanguage: Optional[str] = None ) -> None: super().__init__( text=text, id=id, - language=language, - meta=meta + meta=meta, + programmingLanguage=programmingLanguage ) @@ -273,15 +277,15 @@ def __init__( text: str, errors: Optional[Array["CodeError"]] = None, id: Optional[str] = None, - language: Optional[str] = None, meta: Optional[Dict[str, Any]] = None, - output: Optional["Node"] = None + output: Optional["Node"] = None, + programmingLanguage: Optional[str] = None ) -> None: super().__init__( text=text, id=id, - language=language, - meta=meta + meta=meta, + programmingLanguage=programmingLanguage ) if errors is not None: self.errors = errors @@ -335,6 +339,25 @@ def __init__( self.value = value +class Date(Entity): + """A date encoded as a ISO 8601 string.""" + + value: str + + def __init__( + self, + value: str, + id: Optional[str] = None, + meta: Optional[Dict[str, Any]] = None + ) -> None: + super().__init__( + id=id, + meta=meta + ) + if value is not None: + self.value = value + + class Mark(Entity): """ A base class for nodes that mark some other inline content in some way @@ -460,11 +483,11 @@ def __init__( class ContactPoint(Thing): - """A contact point—for example, a R&D department.""" + """A contact point, for example, a R&D department.""" availableLanguages: Optional[Array[str]] = None emails: Optional[Array[str]] = None - telephone: Optional[str] = None + telephoneNumbers: Optional[Array[str]] = None def __init__( self, @@ -475,7 +498,7 @@ def __init__( id: Optional[str] = None, meta: Optional[Dict[str, Any]] = None, name: Optional[str] = None, - telephone: Optional[str] = None, + telephoneNumbers: Optional[Array[str]] = None, url: Optional[str] = None ) -> None: super().__init__( @@ -490,8 +513,8 @@ def __init__( self.availableLanguages = availableLanguages if emails is not None: self.emails = emails - if telephone is not None: - self.telephone = telephone + if telephoneNumbers is not None: + self.telephoneNumbers = telephoneNumbers class CreativeWork(Thing): @@ -502,12 +525,13 @@ class CreativeWork(Thing): authors: Optional[Array[Union["Person", "Organization"]]] = None content: Optional[Array["Node"]] = None - dateCreated: Optional[str] = None - dateModified: Optional[str] = None - datePublished: Optional[str] = None + dateCreated: Optional[Union["Date", str]] = None + dateModified: Optional[Union["Date", str]] = None + datePublished: Optional[Union["Date", str]] = None editors: Optional[Array["Person"]] = None funders: Optional[Array[Union["Person", "Organization"]]] = None isPartOf: Optional["CreativeWorkTypes"] = None + keywords: Optional[Array[str]] = None licenses: Optional[Array[Union[str, "CreativeWorkTypes"]]] = None parts: Optional[Array["CreativeWorkTypes"]] = None publisher: Optional[Union["Person", "Organization"]] = None @@ -521,14 +545,15 @@ def __init__( alternateNames: Optional[Array[str]] = None, authors: Optional[Array[Union["Person", "Organization"]]] = None, content: Optional[Array["Node"]] = None, - dateCreated: Optional[str] = None, - dateModified: Optional[str] = None, - datePublished: Optional[str] = None, + dateCreated: Optional[Union["Date", str]] = None, + dateModified: Optional[Union["Date", str]] = None, + datePublished: Optional[Union["Date", str]] = None, description: Optional[str] = None, editors: Optional[Array["Person"]] = None, funders: Optional[Array[Union["Person", "Organization"]]] = None, id: Optional[str] = None, isPartOf: Optional["CreativeWorkTypes"] = None, + keywords: Optional[Array[str]] = None, licenses: Optional[Array[Union[str, "CreativeWorkTypes"]]] = None, meta: Optional[Dict[str, Any]] = None, name: Optional[str] = None, @@ -564,6 +589,8 @@ def __init__( self.funders = funders if isPartOf is not None: self.isPartOf = isPartOf + if keywords is not None: + self.keywords = keywords if licenses is not None: self.licenses = licenses if parts is not None: @@ -593,15 +620,16 @@ def __init__( title: str, alternateNames: Optional[Array[str]] = None, content: Optional[Array["Node"]] = None, - dateCreated: Optional[str] = None, - dateModified: Optional[str] = None, - datePublished: Optional[str] = None, + dateCreated: Optional[Union["Date", str]] = None, + dateModified: Optional[Union["Date", str]] = None, + datePublished: Optional[Union["Date", str]] = None, description: Optional[str] = None, editors: Optional[Array["Person"]] = None, environment: Optional["Environment"] = None, funders: Optional[Array[Union["Person", "Organization"]]] = None, id: Optional[str] = None, isPartOf: Optional["CreativeWorkTypes"] = None, + keywords: Optional[Array[str]] = None, licenses: Optional[Array[Union[str, "CreativeWorkTypes"]]] = None, meta: Optional[Dict[str, Any]] = None, name: Optional[str] = None, @@ -625,6 +653,7 @@ def __init__( funders=funders, id=id, isPartOf=isPartOf, + keywords=keywords, licenses=licenses, meta=meta, name=name, @@ -654,14 +683,15 @@ def __init__( alternateNames: Optional[Array[str]] = None, authors: Optional[Array[Union["Person", "Organization"]]] = None, content: Optional[Array["Node"]] = None, - dateCreated: Optional[str] = None, - dateModified: Optional[str] = None, - datePublished: Optional[str] = None, + dateCreated: Optional[Union["Date", str]] = None, + dateModified: Optional[Union["Date", str]] = None, + datePublished: Optional[Union["Date", str]] = None, description: Optional[str] = None, editors: Optional[Array["Person"]] = None, funders: Optional[Array[Union["Person", "Organization"]]] = None, id: Optional[str] = None, isPartOf: Optional["CreativeWorkTypes"] = None, + keywords: Optional[Array[str]] = None, licenses: Optional[Array[Union[str, "CreativeWorkTypes"]]] = None, meta: Optional[Dict[str, Any]] = None, name: Optional[str] = None, @@ -685,6 +715,7 @@ def __init__( funders=funders, id=id, isPartOf=isPartOf, + keywords=keywords, licenses=licenses, meta=meta, name=name, @@ -710,14 +741,15 @@ def __init__( alternateNames: Optional[Array[str]] = None, authors: Optional[Array[Union["Person", "Organization"]]] = None, content: Optional[Array["Node"]] = None, - dateCreated: Optional[str] = None, - dateModified: Optional[str] = None, - datePublished: Optional[str] = None, + dateCreated: Optional[Union["Date", str]] = None, + dateModified: Optional[Union["Date", str]] = None, + datePublished: Optional[Union["Date", str]] = None, description: Optional[str] = None, editors: Optional[Array["Person"]] = None, funders: Optional[Array[Union["Person", "Organization"]]] = None, id: Optional[str] = None, isPartOf: Optional["CreativeWorkTypes"] = None, + keywords: Optional[Array[str]] = None, licenses: Optional[Array[Union[str, "CreativeWorkTypes"]]] = None, meta: Optional[Dict[str, Any]] = None, name: Optional[str] = None, @@ -741,6 +773,7 @@ def __init__( funders=funders, id=id, isPartOf=isPartOf, + keywords=keywords, licenses=licenses, meta=meta, name=name, @@ -776,9 +809,9 @@ def __init__( bitrate: Optional[float] = None, content: Optional[Array["Node"]] = None, contentSize: Optional[float] = None, - dateCreated: Optional[str] = None, - dateModified: Optional[str] = None, - datePublished: Optional[str] = None, + dateCreated: Optional[Union["Date", str]] = None, + dateModified: Optional[Union["Date", str]] = None, + datePublished: Optional[Union["Date", str]] = None, description: Optional[str] = None, editors: Optional[Array["Person"]] = None, embedUrl: Optional[str] = None, @@ -786,6 +819,7 @@ def __init__( funders: Optional[Array[Union["Person", "Organization"]]] = None, id: Optional[str] = None, isPartOf: Optional["CreativeWorkTypes"] = None, + keywords: Optional[Array[str]] = None, licenses: Optional[Array[Union[str, "CreativeWorkTypes"]]] = None, meta: Optional[Dict[str, Any]] = None, name: Optional[str] = None, @@ -809,6 +843,7 @@ def __init__( funders=funders, id=id, isPartOf=isPartOf, + keywords=keywords, licenses=licenses, meta=meta, name=name, @@ -847,9 +882,9 @@ def __init__( caption: Optional[str] = None, content: Optional[Array["Node"]] = None, contentSize: Optional[float] = None, - dateCreated: Optional[str] = None, - dateModified: Optional[str] = None, - datePublished: Optional[str] = None, + dateCreated: Optional[Union["Date", str]] = None, + dateModified: Optional[Union["Date", str]] = None, + datePublished: Optional[Union["Date", str]] = None, description: Optional[str] = None, editors: Optional[Array["Person"]] = None, embedUrl: Optional[str] = None, @@ -857,6 +892,7 @@ def __init__( funders: Optional[Array[Union["Person", "Organization"]]] = None, id: Optional[str] = None, isPartOf: Optional["CreativeWorkTypes"] = None, + keywords: Optional[Array[str]] = None, licenses: Optional[Array[Union[str, "CreativeWorkTypes"]]] = None, meta: Optional[Dict[str, Any]] = None, name: Optional[str] = None, @@ -886,6 +922,7 @@ def __init__( funders=funders, id=id, isPartOf=isPartOf, + keywords=keywords, licenses=licenses, meta=meta, name=name, @@ -963,7 +1000,6 @@ class Environment(Thing): adds: Optional[Array["SoftwareSourceCode"]] = None extends: Optional[Array["Environment"]] = None removes: Optional[Array["SoftwareSourceCode"]] = None - source: Optional[str] = None def __init__( self, @@ -975,7 +1011,6 @@ def __init__( id: Optional[str] = None, meta: Optional[Dict[str, Any]] = None, removes: Optional[Array["SoftwareSourceCode"]] = None, - source: Optional[str] = None, url: Optional[str] = None ) -> None: super().__init__( @@ -994,8 +1029,6 @@ def __init__( self.extends = extends if removes is not None: self.removes = removes - if source is not None: - self.source = source class Figure(CreativeWork): @@ -1013,14 +1046,15 @@ def __init__( authors: Optional[Array[Union["Person", "Organization"]]] = None, caption: Optional[Array["Node"]] = None, content: Optional[Array["Node"]] = None, - dateCreated: Optional[str] = None, - dateModified: Optional[str] = None, - datePublished: Optional[str] = None, + dateCreated: Optional[Union["Date", str]] = None, + dateModified: Optional[Union["Date", str]] = None, + datePublished: Optional[Union["Date", str]] = None, description: Optional[str] = None, editors: Optional[Array["Person"]] = None, funders: Optional[Array[Union["Person", "Organization"]]] = None, id: Optional[str] = None, isPartOf: Optional["CreativeWorkTypes"] = None, + keywords: Optional[Array[str]] = None, label: Optional[str] = None, licenses: Optional[Array[Union[str, "CreativeWorkTypes"]]] = None, meta: Optional[Dict[str, Any]] = None, @@ -1045,6 +1079,7 @@ def __init__( funders=funders, id=id, isPartOf=isPartOf, + keywords=keywords, licenses=licenses, meta=meta, name=name, @@ -1130,9 +1165,9 @@ def __init__( caption: Optional[str] = None, content: Optional[Array["Node"]] = None, contentSize: Optional[float] = None, - dateCreated: Optional[str] = None, - dateModified: Optional[str] = None, - datePublished: Optional[str] = None, + dateCreated: Optional[Union["Date", str]] = None, + dateModified: Optional[Union["Date", str]] = None, + datePublished: Optional[Union["Date", str]] = None, description: Optional[str] = None, editors: Optional[Array["Person"]] = None, embedUrl: Optional[str] = None, @@ -1140,6 +1175,7 @@ def __init__( funders: Optional[Array[Union["Person", "Organization"]]] = None, id: Optional[str] = None, isPartOf: Optional["CreativeWorkTypes"] = None, + keywords: Optional[Array[str]] = None, licenses: Optional[Array[Union[str, "CreativeWorkTypes"]]] = None, meta: Optional[Dict[str, Any]] = None, name: Optional[str] = None, @@ -1169,6 +1205,7 @@ def __init__( funders=funders, id=id, isPartOf=isPartOf, + keywords=keywords, licenses=licenses, meta=meta, name=name, @@ -1538,8 +1575,8 @@ def __init__( class Periodical(CreativeWork): """A periodical publication.""" - dateEnd: Optional[str] = None - dateStart: Optional[str] = None + dateEnd: Optional[Union["Date", str]] = None + dateStart: Optional[Union["Date", str]] = None issn: Optional[Array[str]] = None def __init__( @@ -1547,17 +1584,18 @@ def __init__( alternateNames: Optional[Array[str]] = None, authors: Optional[Array[Union["Person", "Organization"]]] = None, content: Optional[Array["Node"]] = None, - dateCreated: Optional[str] = None, - dateEnd: Optional[str] = None, - dateModified: Optional[str] = None, - datePublished: Optional[str] = None, - dateStart: Optional[str] = None, + dateCreated: Optional[Union["Date", str]] = None, + dateEnd: Optional[Union["Date", str]] = None, + dateModified: Optional[Union["Date", str]] = None, + datePublished: Optional[Union["Date", str]] = None, + dateStart: Optional[Union["Date", str]] = None, description: Optional[str] = None, editors: Optional[Array["Person"]] = None, funders: Optional[Array[Union["Person", "Organization"]]] = None, id: Optional[str] = None, isPartOf: Optional["CreativeWorkTypes"] = None, issn: Optional[Array[str]] = None, + keywords: Optional[Array[str]] = None, licenses: Optional[Array[Union[str, "CreativeWorkTypes"]]] = None, meta: Optional[Dict[str, Any]] = None, name: Optional[str] = None, @@ -1581,6 +1619,7 @@ def __init__( funders=funders, id=id, isPartOf=isPartOf, + keywords=keywords, licenses=licenses, meta=meta, name=name, @@ -1673,14 +1712,14 @@ class Product(Thing): an episode of a TV show streamed online. """ - brand: Optional["Brand"] = None + brands: Optional[Array["Brand"]] = None logo: Optional[Union[str, "ImageObject"]] = None productID: Optional[str] = None def __init__( self, alternateNames: Optional[Array[str]] = None, - brand: Optional["Brand"] = None, + brands: Optional[Array["Brand"]] = None, description: Optional[str] = None, id: Optional[str] = None, logo: Optional[Union[str, "ImageObject"]] = None, @@ -1697,8 +1736,8 @@ def __init__( name=name, url=url ) - if brand is not None: - self.brand = brand + if brands is not None: + self.brands = brands if logo is not None: self.logo = logo if productID is not None: @@ -1708,7 +1747,7 @@ def __init__( class PublicationIssue(CreativeWork): """ A part of a successively published publication such as a periodical or - publication volume, often numbered. + publication volume, often numbered. """ issueNumber: Optional[Union[str, int]] = None @@ -1721,15 +1760,16 @@ def __init__( alternateNames: Optional[Array[str]] = None, authors: Optional[Array[Union["Person", "Organization"]]] = None, content: Optional[Array["Node"]] = None, - dateCreated: Optional[str] = None, - dateModified: Optional[str] = None, - datePublished: Optional[str] = None, + dateCreated: Optional[Union["Date", str]] = None, + dateModified: Optional[Union["Date", str]] = None, + datePublished: Optional[Union["Date", str]] = None, description: Optional[str] = None, editors: Optional[Array["Person"]] = None, funders: Optional[Array[Union["Person", "Organization"]]] = None, id: Optional[str] = None, isPartOf: Optional["CreativeWorkTypes"] = None, issueNumber: Optional[Union[str, int]] = None, + keywords: Optional[Array[str]] = None, licenses: Optional[Array[Union[str, "CreativeWorkTypes"]]] = None, meta: Optional[Dict[str, Any]] = None, name: Optional[str] = None, @@ -1756,6 +1796,7 @@ def __init__( funders=funders, id=id, isPartOf=isPartOf, + keywords=keywords, licenses=licenses, meta=meta, name=name, @@ -1793,14 +1834,15 @@ def __init__( alternateNames: Optional[Array[str]] = None, authors: Optional[Array[Union["Person", "Organization"]]] = None, content: Optional[Array["Node"]] = None, - dateCreated: Optional[str] = None, - dateModified: Optional[str] = None, - datePublished: Optional[str] = None, + dateCreated: Optional[Union["Date", str]] = None, + dateModified: Optional[Union["Date", str]] = None, + datePublished: Optional[Union["Date", str]] = None, description: Optional[str] = None, editors: Optional[Array["Person"]] = None, funders: Optional[Array[Union["Person", "Organization"]]] = None, id: Optional[str] = None, isPartOf: Optional["CreativeWorkTypes"] = None, + keywords: Optional[Array[str]] = None, licenses: Optional[Array[Union[str, "CreativeWorkTypes"]]] = None, meta: Optional[Dict[str, Any]] = None, name: Optional[str] = None, @@ -1828,6 +1870,7 @@ def __init__( funders=funders, id=id, isPartOf=isPartOf, + keywords=keywords, licenses=licenses, meta=meta, name=name, @@ -1852,12 +1895,12 @@ def __init__( class Quote(Mark): """Inline, quoted content.""" - citation: Optional[str] = None + cite: Optional[Union["Cite", str]] = None def __init__( self, content: Array["InlineContent"], - citation: Optional[str] = None, + cite: Optional[Union["Cite", str]] = None, id: Optional[str] = None, meta: Optional[Dict[str, Any]] = None ) -> None: @@ -1866,20 +1909,20 @@ def __init__( id=id, meta=meta ) - if citation is not None: - self.citation = citation + if cite is not None: + self.cite = cite class QuoteBlock(Entity): """A section quoted from somewhere else.""" content: Array["BlockContent"] - citation: Optional[str] = None + cite: Optional[Union["Cite", str]] = None def __init__( self, content: Array["BlockContent"], - citation: Optional[str] = None, + cite: Optional[Union["Cite", str]] = None, id: Optional[str] = None, meta: Optional[Dict[str, Any]] = None ) -> None: @@ -1889,8 +1932,8 @@ def __init__( ) if content is not None: self.content = content - if citation is not None: - self.citation = citation + if cite is not None: + self.cite = cite class ResourceParameters(Thing): @@ -1938,14 +1981,15 @@ def __init__( alternateNames: Optional[Array[str]] = None, authors: Optional[Array[Union["Person", "Organization"]]] = None, content: Optional[Array["Node"]] = None, - dateCreated: Optional[str] = None, - dateModified: Optional[str] = None, - datePublished: Optional[str] = None, + dateCreated: Optional[Union["Date", str]] = None, + dateModified: Optional[Union["Date", str]] = None, + datePublished: Optional[Union["Date", str]] = None, description: Optional[str] = None, editors: Optional[Array["Person"]] = None, funders: Optional[Array[Union["Person", "Organization"]]] = None, id: Optional[str] = None, isPartOf: Optional["CreativeWorkTypes"] = None, + keywords: Optional[Array[str]] = None, licenses: Optional[Array[Union[str, "CreativeWorkTypes"]]] = None, meta: Optional[Dict[str, Any]] = None, name: Optional[str] = None, @@ -1971,6 +2015,7 @@ def __init__( funders=funders, id=id, isPartOf=isPartOf, + keywords=keywords, licenses=licenses, meta=meta, name=name, @@ -2051,14 +2096,15 @@ def __init__( codeRepository: Optional[str] = None, codeSampleType: Optional[str] = None, content: Optional[Array["Node"]] = None, - dateCreated: Optional[str] = None, - dateModified: Optional[str] = None, - datePublished: Optional[str] = None, + dateCreated: Optional[Union["Date", str]] = None, + dateModified: Optional[Union["Date", str]] = None, + datePublished: Optional[Union["Date", str]] = None, description: Optional[str] = None, editors: Optional[Array["Person"]] = None, funders: Optional[Array[Union["Person", "Organization"]]] = None, id: Optional[str] = None, isPartOf: Optional["CreativeWorkTypes"] = None, + keywords: Optional[Array[str]] = None, licenses: Optional[Array[Union[str, "CreativeWorkTypes"]]] = None, maintainers: Optional[Array[Union["Organization", "Person"]]] = None, meta: Optional[Dict[str, Any]] = None, @@ -2087,6 +2133,7 @@ def __init__( funders=funders, id=id, isPartOf=isPartOf, + keywords=keywords, licenses=licenses, meta=meta, name=name, @@ -2203,14 +2250,15 @@ def __init__( alternateNames: Optional[Array[str]] = None, authors: Optional[Array[Union["Person", "Organization"]]] = None, content: Optional[Array["Node"]] = None, - dateCreated: Optional[str] = None, - dateModified: Optional[str] = None, - datePublished: Optional[str] = None, + dateCreated: Optional[Union["Date", str]] = None, + dateModified: Optional[Union["Date", str]] = None, + datePublished: Optional[Union["Date", str]] = None, description: Optional[str] = None, editors: Optional[Array["Person"]] = None, funders: Optional[Array[Union["Person", "Organization"]]] = None, id: Optional[str] = None, isPartOf: Optional["CreativeWorkTypes"] = None, + keywords: Optional[Array[str]] = None, licenses: Optional[Array[Union[str, "CreativeWorkTypes"]]] = None, meta: Optional[Dict[str, Any]] = None, name: Optional[str] = None, @@ -2234,6 +2282,7 @@ def __init__( funders=funders, id=id, isPartOf=isPartOf, + keywords=keywords, licenses=licenses, meta=meta, name=name, @@ -2253,17 +2302,17 @@ class TableCell(Entity): """A cell within a `Table`.""" content: Array["InlineContent"] + cellType: Optional["ECellType"] = None colspan: Optional[int] = None - kind: Optional["ETableCellKind"] = None name: Optional[str] = None rowspan: Optional[int] = None def __init__( self, content: Array["InlineContent"], + cellType: Optional["ECellType"] = None, colspan: Optional[int] = None, id: Optional[str] = None, - kind: Optional["ETableCellKind"] = None, meta: Optional[Dict[str, Any]] = None, name: Optional[str] = None, rowspan: Optional[int] = None @@ -2274,10 +2323,10 @@ def __init__( ) if content is not None: self.content = content + if cellType is not None: + self.cellType = cellType if colspan is not None: self.colspan = colspan - if kind is not None: - self.kind = kind if name is not None: self.name = name if rowspan is not None: @@ -2288,14 +2337,14 @@ class TableRow(Entity): """A row within a Table.""" cells: Array["TableCell"] - kind: Optional["ETableRowKind"] = None + rowType: Optional["ERowType"] = None def __init__( self, cells: Array["TableCell"], id: Optional[str] = None, - kind: Optional["ETableRowKind"] = None, - meta: Optional[Dict[str, Any]] = None + meta: Optional[Dict[str, Any]] = None, + rowType: Optional["ERowType"] = None ) -> None: super().__init__( id=id, @@ -2303,8 +2352,8 @@ def __init__( ) if cells is not None: self.cells = cells - if kind is not None: - self.kind = kind + if rowType is not None: + self.rowType = rowType class ThematicBreak(Entity): @@ -2360,9 +2409,9 @@ def __init__( caption: Optional[str] = None, content: Optional[Array["Node"]] = None, contentSize: Optional[float] = None, - dateCreated: Optional[str] = None, - dateModified: Optional[str] = None, - datePublished: Optional[str] = None, + dateCreated: Optional[Union["Date", str]] = None, + dateModified: Optional[Union["Date", str]] = None, + datePublished: Optional[Union["Date", str]] = None, description: Optional[str] = None, editors: Optional[Array["Person"]] = None, embedUrl: Optional[str] = None, @@ -2370,6 +2419,7 @@ def __init__( funders: Optional[Array[Union["Person", "Organization"]]] = None, id: Optional[str] = None, isPartOf: Optional["CreativeWorkTypes"] = None, + keywords: Optional[Array[str]] = None, licenses: Optional[Array[Union[str, "CreativeWorkTypes"]]] = None, meta: Optional[Dict[str, Any]] = None, name: Optional[str] = None, @@ -2400,6 +2450,7 @@ def __init__( funders=funders, id=id, isPartOf=isPartOf, + keywords=keywords, licenses=licenses, meta=meta, name=name, diff --git a/py/tests/test_document_compiler.py b/py/tests/test_document_compiler.py index d2455071..9fd0831f 100644 --- a/py/tests/test_document_compiler.py +++ b/py/tests/test_document_compiler.py @@ -35,22 +35,22 @@ def test_compile_article(): { 'type': 'CodeChunk', 'text': 'let a = \'I am JavaScript!\'', - 'language': 'notpython' + 'programmingLanguage': 'notpython' }, { 'type': 'CodeChunk', 'text': chunk_1_text, - 'language': 'python' + 'programmingLanguage': 'python' }, { 'type': 'CodeChunk', 'text': chunk_2_text, - 'language': 'python' + 'programmingLanguage': 'python' }, { 'type': 'CodeChunk', 'text': chunk_3_text, - 'language': 'python', + 'programmingLanguage': 'python', 'declares': [ { 'type': 'Function', @@ -68,17 +68,17 @@ def test_compile_article(): { 'type': 'CodeExpression', 'text': 'invalid code', - 'language': 'notpython' + 'programmingLanguage': 'notpython' }, { 'type': 'CodeExpression', 'text': expr_1_text, - 'language': 'python' + 'programmingLanguage': 'python' }, { 'type': 'CodeExpression', 'text': expr_2_text, - 'language': 'python' + 'programmingLanguage': 'python' } ] }) @@ -96,7 +96,7 @@ def test_compile_article(): for c in dcr.code: if isinstance(c, CodeChunkExecution): c = c[0] - assert c.language == 'python' + assert c.programmingLanguage == 'python' code_chunks = list(map(lambda c: c[0], filter(lambda ce: isinstance(ce, CodeChunkExecution), dcr.code))) code_exprs = list(filter(lambda ce: isinstance(ce, CodeExpression), dcr.code)) @@ -111,7 +111,7 @@ def test_compile_article(): def test_import_appending(): """Found imports in a piece of code should be added to the list of imports the code chunk already specifies.""" - c = CodeChunk('import moda\nimport modb\nimport modc', imports=['modc', 'modd'], language='python') + c = CodeChunk('import moda\nimport modb\nimport modc', imports=['modc', 'modd'], programmingLanguage='python') dc = DocumentCompiler() dc.compile(c) @@ -125,7 +125,7 @@ def test_import_appending(): def test_import_with_semaphore(): """If a `CodeChunk`'s imports has an empty string element then no imports should be added to its list.""" - c = CodeChunk('import moda\nimport modb', imports=['modc', 'modd', '']) + c = CodeChunk('import moda\nimport modb', imports=['modc', 'modd', ''], programmingLanguage='python') dc = DocumentCompiler() dc.compile(c) diff --git a/r/R/types.R b/r/R/types.R index a5bd5a1f..a18f4092 100644 --- a/r/R/types.R +++ b/r/R/types.R @@ -87,6 +87,7 @@ BooleanSchema <- function( #' @name Cite #' @param target The target of the citation (URL or reference ID). \bold{Required}. #' @param citationMode How the cite is rendered in the surrounding text. +#' @param content Optional structured content/text of this citation. #' @param id The identifier for this item. #' @param meta Metadata associated with this item. #' @param pageEnd The page on which the work ends; for example "138" or "xvi". @@ -99,6 +100,7 @@ BooleanSchema <- function( Cite <- function( target, citationMode, + content, id, meta, pageEnd, @@ -114,6 +116,7 @@ Cite <- function( self$type <- as_scalar("Cite") self[["target"]] <- check_property("Cite", "target", TRUE, missing(target), "character", target) self[["citationMode"]] <- check_property("Cite", "citationMode", FALSE, missing(citationMode), Enum("normal", "suppressAuthor"), citationMode) + self[["content"]] <- check_property("Cite", "content", FALSE, missing(content), Array("InlineContent"), content) self[["pageEnd"]] <- check_property("Cite", "pageEnd", FALSE, missing(pageEnd), Union("character", "numeric"), pageEnd) self[["pageStart"]] <- check_property("Cite", "pageStart", FALSE, missing(pageStart), Union("character", "numeric"), pageStart) self[["pagination"]] <- check_property("Cite", "pagination", FALSE, missing(pagination), "character", pagination) @@ -153,15 +156,15 @@ CiteGroup <- function( #' @name Code #' @param text The text of the code. \bold{Required}. #' @param id The identifier for this item. -#' @param language The programming language of the code. #' @param meta Metadata associated with this item. +#' @param programmingLanguage The programming language of the code. #' @seealso \code{\link{Entity}} #' @export Code <- function( text, id, - language, - meta + meta, + programmingLanguage ){ self <- Entity( id = id, @@ -169,7 +172,7 @@ Code <- function( ) self$type <- as_scalar("Code") self[["text"]] <- check_property("Code", "text", TRUE, missing(text), "character", text) - self[["language"]] <- check_property("Code", "language", FALSE, missing(language), "character", language) + self[["programmingLanguage"]] <- check_property("Code", "programmingLanguage", FALSE, missing(programmingLanguage), "character", programmingLanguage) class(self) <- c("list", "Entity") self } @@ -180,21 +183,21 @@ Code <- function( #' @name CodeBlock #' @param text The text of the code. \bold{Required}. #' @param id The identifier for this item. -#' @param language The programming language of the code. #' @param meta Metadata associated with this item. +#' @param programmingLanguage The programming language of the code. #' @seealso \code{\link{Code}} #' @export CodeBlock <- function( text, id, - language, - meta + meta, + programmingLanguage ){ self <- Code( text = text, id = id, - language = language, - meta = meta + meta = meta, + programmingLanguage = programmingLanguage ) self$type <- as_scalar("CodeBlock") @@ -214,9 +217,9 @@ CodeBlock <- function( #' @param errors Errors when compiling or executing the chunk. #' @param id The identifier for this item. #' @param imports Software packages that the code chunk imports -#' @param language The programming language of the code. #' @param meta Metadata associated with this item. #' @param outputs Outputs from executing the chunk. +#' @param programmingLanguage The programming language of the code. #' @param reads Filesystem paths that this code chunk reads from. #' @param uses Names of variables that the code chunk uses (but does not alter). #' @seealso \code{\link{CodeBlock}} @@ -230,17 +233,17 @@ CodeChunk <- function( errors, id, imports, - language, meta, outputs, + programmingLanguage, reads, uses ){ self <- CodeBlock( text = text, id = id, - language = language, - meta = meta + meta = meta, + programmingLanguage = programmingLanguage ) self$type <- as_scalar("CodeChunk") self[["alters"]] <- check_property("CodeChunk", "alters", FALSE, missing(alters), Array("character"), alters) @@ -262,21 +265,21 @@ CodeChunk <- function( #' @name CodeFragment #' @param text The text of the code. \bold{Required}. #' @param id The identifier for this item. -#' @param language The programming language of the code. #' @param meta Metadata associated with this item. +#' @param programmingLanguage The programming language of the code. #' @seealso \code{\link{Code}} #' @export CodeFragment <- function( text, id, - language, - meta + meta, + programmingLanguage ){ self <- Code( text = text, id = id, - language = language, - meta = meta + meta = meta, + programmingLanguage = programmingLanguage ) self$type <- as_scalar("CodeFragment") @@ -291,24 +294,24 @@ CodeFragment <- function( #' @param text The text of the code. \bold{Required}. #' @param errors Errors when compiling or executing the chunk. #' @param id The identifier for this item. -#' @param language The programming language of the code. #' @param meta Metadata associated with this item. #' @param output The value of the expression when it was last evaluated. +#' @param programmingLanguage The programming language of the code. #' @seealso \code{\link{CodeFragment}} #' @export CodeExpression <- function( text, errors, id, - language, meta, - output + output, + programmingLanguage ){ self <- CodeFragment( text = text, id = id, - language = language, - meta = meta + meta = meta, + programmingLanguage = programmingLanguage ) self$type <- as_scalar("CodeExpression") self[["errors"]] <- check_property("CodeExpression", "errors", FALSE, missing(errors), Array("CodeError"), errors) @@ -372,6 +375,30 @@ ConstantSchema <- function( } +#' A date encoded as a ISO 8601 string. +#' +#' @name Date +#' @param value The date as an ISO 8601 string. \bold{Required}. +#' @param id The identifier for this item. +#' @param meta Metadata associated with this item. +#' @seealso \code{\link{Entity}} +#' @export +Date <- function( + value, + id, + meta +){ + self <- Entity( + id = id, + meta = meta + ) + self$type <- as_scalar("Date") + self[["value"]] <- check_property("Date", "value", TRUE, missing(value), "character", value) + class(self) <- c("list", "Entity") + self +} + + #' A base class for nodes that mark some other inline content in some way (e.g. as being emphasised, or quoted). #' #' @name Mark @@ -519,7 +546,7 @@ Brand <- function( } -#' A contact point—for example, a R&D department. +#' A contact point, for example, a R&D department. #' #' @name ContactPoint #' @param alternateNames Alternate names (aliases) for the item. @@ -529,7 +556,7 @@ Brand <- function( #' @param id The identifier for this item. #' @param meta Metadata associated with this item. #' @param name The name of the item. -#' @param telephone The telephone number of the contact point. Accepted formats: +44 123455, (02)12345, 006645667. +#' @param telephoneNumbers Telephone numbers for the contact point. #' @param url The URL of the item. #' @seealso \code{\link{Thing}} #' @export @@ -541,7 +568,7 @@ ContactPoint <- function( id, meta, name, - telephone, + telephoneNumbers, url ){ self <- Thing( @@ -555,7 +582,7 @@ ContactPoint <- function( self$type <- as_scalar("ContactPoint") self[["availableLanguages"]] <- check_property("ContactPoint", "availableLanguages", FALSE, missing(availableLanguages), Array("character"), availableLanguages) self[["emails"]] <- check_property("ContactPoint", "emails", FALSE, missing(emails), Array("character"), emails) - self[["telephone"]] <- check_property("ContactPoint", "telephone", FALSE, missing(telephone), "character", telephone) + self[["telephoneNumbers"]] <- check_property("ContactPoint", "telephoneNumbers", FALSE, missing(telephoneNumbers), Array("character"), telephoneNumbers) class(self) <- c("list", "Entity") self } @@ -575,6 +602,7 @@ ContactPoint <- function( #' @param funders Person or organisation that funded the CreativeWork. #' @param id The identifier for this item. #' @param isPartOf An item or other CreativeWork that this CreativeWork is a part of. +#' @param keywords Keywords or tags used to describe this content. Multiple entries in a keywords list are typically delimited by commas. #' @param licenses License documents that applies to this content, typically indicated by URL. #' @param meta Metadata associated with this item. #' @param name The name of the item. @@ -599,6 +627,7 @@ CreativeWork <- function( funders, id, isPartOf, + keywords, licenses, meta, name, @@ -621,12 +650,13 @@ CreativeWork <- function( self$type <- as_scalar("CreativeWork") self[["authors"]] <- check_property("CreativeWork", "authors", FALSE, missing(authors), Array(Union("Person", "Organization")), authors) self[["content"]] <- check_property("CreativeWork", "content", FALSE, missing(content), Array("Node"), content) - self[["dateCreated"]] <- check_property("CreativeWork", "dateCreated", FALSE, missing(dateCreated), "character", dateCreated) - self[["dateModified"]] <- check_property("CreativeWork", "dateModified", FALSE, missing(dateModified), "character", dateModified) - self[["datePublished"]] <- check_property("CreativeWork", "datePublished", FALSE, missing(datePublished), "character", datePublished) + self[["dateCreated"]] <- check_property("CreativeWork", "dateCreated", FALSE, missing(dateCreated), Union("Date", "character"), dateCreated) + self[["dateModified"]] <- check_property("CreativeWork", "dateModified", FALSE, missing(dateModified), Union("Date", "character"), dateModified) + self[["datePublished"]] <- check_property("CreativeWork", "datePublished", FALSE, missing(datePublished), Union("Date", "character"), datePublished) self[["editors"]] <- check_property("CreativeWork", "editors", FALSE, missing(editors), Array("Person"), editors) self[["funders"]] <- check_property("CreativeWork", "funders", FALSE, missing(funders), Array(Union("Person", "Organization")), funders) self[["isPartOf"]] <- check_property("CreativeWork", "isPartOf", FALSE, missing(isPartOf), "CreativeWorkTypes", isPartOf) + self[["keywords"]] <- check_property("CreativeWork", "keywords", FALSE, missing(keywords), Array("character"), keywords) self[["licenses"]] <- check_property("CreativeWork", "licenses", FALSE, missing(licenses), Array(Union("character", "CreativeWorkTypes")), licenses) self[["parts"]] <- check_property("CreativeWork", "parts", FALSE, missing(parts), Array("CreativeWorkTypes"), parts) self[["publisher"]] <- check_property("CreativeWork", "publisher", FALSE, missing(publisher), Union("Person", "Organization"), publisher) @@ -655,6 +685,7 @@ CreativeWork <- function( #' @param funders Person or organisation that funded the CreativeWork. #' @param id The identifier for this item. #' @param isPartOf An item or other CreativeWork that this CreativeWork is a part of. +#' @param keywords Keywords or tags used to describe this content. Multiple entries in a keywords list are typically delimited by commas. #' @param licenses License documents that applies to this content, typically indicated by URL. #' @param meta Metadata associated with this item. #' @param name The name of the item. @@ -680,6 +711,7 @@ Article <- function( funders, id, isPartOf, + keywords, licenses, meta, name, @@ -703,6 +735,7 @@ Article <- function( funders = funders, id = id, isPartOf = isPartOf, + keywords = keywords, licenses = licenses, meta = meta, name = name, @@ -737,6 +770,7 @@ Article <- function( #' @param funders Person or organisation that funded the CreativeWork. #' @param id The identifier for this item. #' @param isPartOf An item or other CreativeWork that this CreativeWork is a part of. +#' @param keywords Keywords or tags used to describe this content. Multiple entries in a keywords list are typically delimited by commas. #' @param licenses License documents that applies to this content, typically indicated by URL. #' @param meta Metadata associated with this item. #' @param name The name of the item. @@ -761,6 +795,7 @@ Collection <- function( funders, id, isPartOf, + keywords, licenses, meta, name, @@ -784,6 +819,7 @@ Collection <- function( funders = funders, id = id, isPartOf = isPartOf, + keywords = keywords, licenses = licenses, meta = meta, name = name, @@ -816,6 +852,7 @@ Collection <- function( #' @param funders Person or organisation that funded the CreativeWork. #' @param id The identifier for this item. #' @param isPartOf An item or other CreativeWork that this CreativeWork is a part of. +#' @param keywords Keywords or tags used to describe this content. Multiple entries in a keywords list are typically delimited by commas. #' @param licenses License documents that applies to this content, typically indicated by URL. #' @param meta Metadata associated with this item. #' @param name The name of the item. @@ -841,6 +878,7 @@ Datatable <- function( funders, id, isPartOf, + keywords, licenses, meta, name, @@ -864,6 +902,7 @@ Datatable <- function( funders = funders, id = id, isPartOf = isPartOf, + keywords = keywords, licenses = licenses, meta = meta, name = name, @@ -901,6 +940,7 @@ Datatable <- function( #' @param funders Person or organisation that funded the CreativeWork. #' @param id The identifier for this item. #' @param isPartOf An item or other CreativeWork that this CreativeWork is a part of. +#' @param keywords Keywords or tags used to describe this content. Multiple entries in a keywords list are typically delimited by commas. #' @param licenses License documents that applies to this content, typically indicated by URL. #' @param meta Metadata associated with this item. #' @param name The name of the item. @@ -930,6 +970,7 @@ MediaObject <- function( funders, id, isPartOf, + keywords, licenses, meta, name, @@ -953,6 +994,7 @@ MediaObject <- function( funders = funders, id = id, isPartOf = isPartOf, + keywords = keywords, licenses = licenses, meta = meta, name = name, @@ -995,6 +1037,7 @@ MediaObject <- function( #' @param funders Person or organisation that funded the CreativeWork. #' @param id The identifier for this item. #' @param isPartOf An item or other CreativeWork that this CreativeWork is a part of. +#' @param keywords Keywords or tags used to describe this content. Multiple entries in a keywords list are typically delimited by commas. #' @param licenses License documents that applies to this content, typically indicated by URL. #' @param meta Metadata associated with this item. #' @param name The name of the item. @@ -1026,6 +1069,7 @@ AudioObject <- function( funders, id, isPartOf, + keywords, licenses, meta, name, @@ -1055,6 +1099,7 @@ AudioObject <- function( funders = funders, id = id, isPartOf = isPartOf, + keywords = keywords, licenses = licenses, meta = meta, name = name, @@ -1149,7 +1194,6 @@ EnumSchema <- function( #' @param id The identifier for this item. #' @param meta Metadata associated with this item. #' @param removes The packages that this environment removes from the base environments listed under `extends` (if any)., -#' @param source Source of environment definition. e.g. a URL to a Dockerfile, or a path to a filesystem folder. #' @param url The URL of the item. #' @seealso \code{\link{Thing}} #' @export @@ -1162,7 +1206,6 @@ Environment <- function( id, meta, removes, - source, url ){ self <- Thing( @@ -1178,7 +1221,6 @@ Environment <- function( self[["adds"]] <- check_property("Environment", "adds", FALSE, missing(adds), Array("SoftwareSourceCode"), adds) self[["extends"]] <- check_property("Environment", "extends", FALSE, missing(extends), Array("Environment"), extends) self[["removes"]] <- check_property("Environment", "removes", FALSE, missing(removes), Array("SoftwareSourceCode"), removes) - self[["source"]] <- check_property("Environment", "source", FALSE, missing(source), "character", source) class(self) <- c("list", "Entity") self } @@ -1199,6 +1241,7 @@ Environment <- function( #' @param funders Person or organisation that funded the CreativeWork. #' @param id The identifier for this item. #' @param isPartOf An item or other CreativeWork that this CreativeWork is a part of. +#' @param keywords Keywords or tags used to describe this content. Multiple entries in a keywords list are typically delimited by commas. #' @param label A short label for the figure. #' @param licenses License documents that applies to this content, typically indicated by URL. #' @param meta Metadata associated with this item. @@ -1225,6 +1268,7 @@ Figure <- function( funders, id, isPartOf, + keywords, label, licenses, meta, @@ -1249,6 +1293,7 @@ Figure <- function( funders = funders, id = id, isPartOf = isPartOf, + keywords = keywords, licenses = licenses, meta = meta, name = name, @@ -1345,6 +1390,7 @@ Heading <- function( #' @param funders Person or organisation that funded the CreativeWork. #' @param id The identifier for this item. #' @param isPartOf An item or other CreativeWork that this CreativeWork is a part of. +#' @param keywords Keywords or tags used to describe this content. Multiple entries in a keywords list are typically delimited by commas. #' @param licenses License documents that applies to this content, typically indicated by URL. #' @param meta Metadata associated with this item. #' @param name The name of the item. @@ -1376,6 +1422,7 @@ ImageObject <- function( funders, id, isPartOf, + keywords, licenses, meta, name, @@ -1405,6 +1452,7 @@ ImageObject <- function( funders = funders, id = id, isPartOf = isPartOf, + keywords = keywords, licenses = licenses, meta = meta, name = name, @@ -1829,6 +1877,7 @@ Parameter <- function( #' @param id The identifier for this item. #' @param isPartOf An item or other CreativeWork that this CreativeWork is a part of. #' @param issn The International Standard Serial Number (ISSN) that identifies this serial publication. +#' @param keywords Keywords or tags used to describe this content. Multiple entries in a keywords list are typically delimited by commas. #' @param licenses License documents that applies to this content, typically indicated by URL. #' @param meta Metadata associated with this item. #' @param name The name of the item. @@ -1856,6 +1905,7 @@ Periodical <- function( id, isPartOf, issn, + keywords, licenses, meta, name, @@ -1879,6 +1929,7 @@ Periodical <- function( funders = funders, id = id, isPartOf = isPartOf, + keywords = keywords, licenses = licenses, meta = meta, name = name, @@ -1891,8 +1942,8 @@ Periodical <- function( version = version ) self$type <- as_scalar("Periodical") - self[["dateEnd"]] <- check_property("Periodical", "dateEnd", FALSE, missing(dateEnd), "character", dateEnd) - self[["dateStart"]] <- check_property("Periodical", "dateStart", FALSE, missing(dateStart), "character", dateStart) + self[["dateEnd"]] <- check_property("Periodical", "dateEnd", FALSE, missing(dateEnd), Union("Date", "character"), dateEnd) + self[["dateStart"]] <- check_property("Periodical", "dateStart", FALSE, missing(dateStart), Union("Date", "character"), dateStart) self[["issn"]] <- check_property("Periodical", "issn", FALSE, missing(issn), Array("character"), issn) class(self) <- c("list", "Entity") self @@ -1969,7 +2020,7 @@ Person <- function( #' #' @name Product #' @param alternateNames Alternate names (aliases) for the item. -#' @param brand Brand that the product is labelled with. +#' @param brands Brands that the product is labelled with. #' @param description A description of the item. #' @param id The identifier for this item. #' @param logo The logo of the product. @@ -1981,7 +2032,7 @@ Person <- function( #' @export Product <- function( alternateNames, - brand, + brands, description, id, logo, @@ -1999,7 +2050,7 @@ Product <- function( url = url ) self$type <- as_scalar("Product") - self[["brand"]] <- check_property("Product", "brand", FALSE, missing(brand), "Brand", brand) + self[["brands"]] <- check_property("Product", "brands", FALSE, missing(brands), Array("Brand"), brands) self[["logo"]] <- check_property("Product", "logo", FALSE, missing(logo), Union("character", "ImageObject"), logo) self[["productID"]] <- check_property("Product", "productID", FALSE, missing(productID), "character", productID) class(self) <- c("list", "Entity") @@ -2007,7 +2058,7 @@ Product <- function( } -#' A part of a successively published publication such as a periodical or publication volume, often numbered. +#' A part of a successively published publication such as a periodical or publication volume, often numbered. #' #' @name PublicationIssue #' @param alternateNames Alternate names (aliases) for the item. @@ -2022,12 +2073,13 @@ Product <- function( #' @param id The identifier for this item. #' @param isPartOf An item or other CreativeWork that this CreativeWork is a part of. #' @param issueNumber Identifies the issue of publication; for example, "iii" or "2". +#' @param keywords Keywords or tags used to describe this content. Multiple entries in a keywords list are typically delimited by commas. #' @param licenses License documents that applies to this content, typically indicated by URL. #' @param meta Metadata associated with this item. #' @param name The name of the item. #' @param pageEnd The page on which the work ends; for example "138" or "xvi". #' @param pageStart The page on which the work starts; for example "135" or "xiii". -#' @param pagination Any description of pages that is not separated into pageStart and pageEnd; for example, "1-6, 9, 55". +#' @param pagination Any description of pages that is not separated into pageStart and pageEnd; for example, "1-6, 9, 55". #' @param parts Elements of the collection which can be a variety of different elements, such as Articles, Datatables, Tables and more. #' @param publisher A publisher of the CreativeWork. #' @param references References to other creative works, such as another publication, web page, scholarly article, etc. @@ -2050,6 +2102,7 @@ PublicationIssue <- function( id, isPartOf, issueNumber, + keywords, licenses, meta, name, @@ -2076,6 +2129,7 @@ PublicationIssue <- function( funders = funders, id = id, isPartOf = isPartOf, + keywords = keywords, licenses = licenses, meta = meta, name = name, @@ -2111,6 +2165,7 @@ PublicationIssue <- function( #' @param funders Person or organisation that funded the CreativeWork. #' @param id The identifier for this item. #' @param isPartOf An item or other CreativeWork that this CreativeWork is a part of. +#' @param keywords Keywords or tags used to describe this content. Multiple entries in a keywords list are typically delimited by commas. #' @param licenses License documents that applies to this content, typically indicated by URL. #' @param meta Metadata associated with this item. #' @param name The name of the item. @@ -2139,6 +2194,7 @@ PublicationVolume <- function( funders, id, isPartOf, + keywords, licenses, meta, name, @@ -2166,6 +2222,7 @@ PublicationVolume <- function( funders = funders, id = id, isPartOf = isPartOf, + keywords = keywords, licenses = licenses, meta = meta, name = name, @@ -2191,14 +2248,14 @@ PublicationVolume <- function( #' #' @name Quote #' @param content The content that is marked. \bold{Required}. -#' @param citation The source of the quote. +#' @param cite The source of the quote. #' @param id The identifier for this item. #' @param meta Metadata associated with this item. #' @seealso \code{\link{Mark}} #' @export Quote <- function( content, - citation, + cite, id, meta ){ @@ -2208,7 +2265,7 @@ Quote <- function( meta = meta ) self$type <- as_scalar("Quote") - self[["citation"]] <- check_property("Quote", "citation", FALSE, missing(citation), "character", citation) + self[["cite"]] <- check_property("Quote", "cite", FALSE, missing(cite), Union("Cite", "character"), cite) class(self) <- c("list", "Entity") self } @@ -2218,14 +2275,14 @@ Quote <- function( #' #' @name QuoteBlock #' @param content The content of the quote. \bold{Required}. -#' @param citation The source of the quote +#' @param cite The source of the quote. #' @param id The identifier for this item. #' @param meta Metadata associated with this item. #' @seealso \code{\link{Entity}} #' @export QuoteBlock <- function( content, - citation, + cite, id, meta ){ @@ -2235,7 +2292,7 @@ QuoteBlock <- function( ) self$type <- as_scalar("QuoteBlock") self[["content"]] <- check_property("QuoteBlock", "content", TRUE, missing(content), Array("BlockContent"), content) - self[["citation"]] <- check_property("QuoteBlock", "citation", FALSE, missing(citation), "character", citation) + self[["cite"]] <- check_property("QuoteBlock", "cite", FALSE, missing(cite), Union("Cite", "character"), cite) class(self) <- c("list", "Entity") self } @@ -2294,6 +2351,7 @@ ResourceParameters <- function( #' @param funders Person or organisation that funded the CreativeWork. #' @param id The identifier for this item. #' @param isPartOf An item or other CreativeWork that this CreativeWork is a part of. +#' @param keywords Keywords or tags used to describe this content. Multiple entries in a keywords list are typically delimited by commas. #' @param licenses License documents that applies to this content, typically indicated by URL. #' @param meta Metadata associated with this item. #' @param name The name of the item. @@ -2320,6 +2378,7 @@ SoftwareApplication <- function( funders, id, isPartOf, + keywords, licenses, meta, name, @@ -2345,6 +2404,7 @@ SoftwareApplication <- function( funders = funders, id = id, isPartOf = isPartOf, + keywords = keywords, licenses = licenses, meta = meta, name = name, @@ -2425,6 +2485,7 @@ SoftwareSession <- function( #' @param funders Person or organisation that funded the CreativeWork. #' @param id The identifier for this item. #' @param isPartOf An item or other CreativeWork that this CreativeWork is a part of. +#' @param keywords Keywords or tags used to describe this content. Multiple entries in a keywords list are typically delimited by commas. #' @param licenses License documents that applies to this content, typically indicated by URL. #' @param maintainers The people or organizations who maintain the software. #' @param meta Metadata associated with this item. @@ -2456,6 +2517,7 @@ SoftwareSourceCode <- function( funders, id, isPartOf, + keywords, licenses, maintainers, meta, @@ -2484,6 +2546,7 @@ SoftwareSourceCode <- function( funders = funders, id = id, isPartOf = isPartOf, + keywords = keywords, licenses = licenses, meta = meta, name = name, @@ -2628,6 +2691,7 @@ Superscript <- function( #' @param funders Person or organisation that funded the CreativeWork. #' @param id The identifier for this item. #' @param isPartOf An item or other CreativeWork that this CreativeWork is a part of. +#' @param keywords Keywords or tags used to describe this content. Multiple entries in a keywords list are typically delimited by commas. #' @param licenses License documents that applies to this content, typically indicated by URL. #' @param meta Metadata associated with this item. #' @param name The name of the item. @@ -2653,6 +2717,7 @@ Table <- function( funders, id, isPartOf, + keywords, licenses, meta, name, @@ -2676,6 +2741,7 @@ Table <- function( funders = funders, id = id, isPartOf = isPartOf, + keywords = keywords, licenses = licenses, meta = meta, name = name, @@ -2698,9 +2764,9 @@ Table <- function( #' #' @name TableCell #' @param content Contents of the table cell. \bold{Required}. +#' @param cellType Indicates whether the cell is a header or data. #' @param colspan How many columns the cell extends. #' @param id The identifier for this item. -#' @param kind Indicates whether the cell is a header. #' @param meta Metadata associated with this item. #' @param name The name of the cell. #' @param rowspan How many columns the cell extends. @@ -2708,9 +2774,9 @@ Table <- function( #' @export TableCell <- function( content, + cellType, colspan, id, - kind, meta, name, rowspan @@ -2721,8 +2787,8 @@ TableCell <- function( ) self$type <- as_scalar("TableCell") self[["content"]] <- check_property("TableCell", "content", TRUE, missing(content), Array("InlineContent"), content) + self[["cellType"]] <- check_property("TableCell", "cellType", FALSE, missing(cellType), Enum("data", "header"), cellType) self[["colspan"]] <- check_property("TableCell", "colspan", FALSE, missing(colspan), "numeric", colspan) - self[["kind"]] <- check_property("TableCell", "kind", FALSE, missing(kind), Enum("data", "header"), kind) self[["name"]] <- check_property("TableCell", "name", FALSE, missing(name), "character", name) self[["rowspan"]] <- check_property("TableCell", "rowspan", FALSE, missing(rowspan), "numeric", rowspan) class(self) <- c("list", "Entity") @@ -2735,15 +2801,15 @@ TableCell <- function( #' @name TableRow #' @param cells An array of cells in the row. \bold{Required}. #' @param id The identifier for this item. -#' @param kind If present, indicates that all cells in this row should be treated as header cells. #' @param meta Metadata associated with this item. +#' @param rowType If present, indicates that all cells in this row should be treated as header cells. #' @seealso \code{\link{Entity}} #' @export TableRow <- function( cells, id, - kind, - meta + meta, + rowType ){ self <- Entity( id = id, @@ -2751,7 +2817,7 @@ TableRow <- function( ) self$type <- as_scalar("TableRow") self[["cells"]] <- check_property("TableRow", "cells", TRUE, missing(cells), Array("TableCell"), cells) - self[["kind"]] <- check_property("TableRow", "kind", FALSE, missing(kind), Enum("header", "footer"), kind) + self[["rowType"]] <- check_property("TableRow", "rowType", FALSE, missing(rowType), Enum("header", "footer"), rowType) class(self) <- c("list", "Entity") self } @@ -2823,6 +2889,7 @@ TupleSchema <- function( #' @param funders Person or organisation that funded the CreativeWork. #' @param id The identifier for this item. #' @param isPartOf An item or other CreativeWork that this CreativeWork is a part of. +#' @param keywords Keywords or tags used to describe this content. Multiple entries in a keywords list are typically delimited by commas. #' @param licenses License documents that applies to this content, typically indicated by URL. #' @param meta Metadata associated with this item. #' @param name The name of the item. @@ -2855,6 +2922,7 @@ VideoObject <- function( funders, id, isPartOf, + keywords, licenses, meta, name, @@ -2885,6 +2953,7 @@ VideoObject <- function( funders = funders, id = id, isPartOf = isPartOf, + keywords = keywords, licenses = licenses, meta = meta, name = name, diff --git a/schema/ArraySchema.schema.yaml b/schema/ArraySchema.schema.yaml index 21056fbf..7b8bb74a 100644 --- a/schema/ArraySchema.schema.yaml +++ b/schema/ArraySchema.schema.yaml @@ -7,7 +7,7 @@ category: data description: A schema specifying constraints on an array node. properties: items: - '@id': stencila:items + '@id': schema:itemListElement description: Another data schema node specifying the constraints on all items in the array. allOf: - $ref: SchemaTypes diff --git a/schema/NumberSchema.schema.yaml b/schema/NumberSchema.schema.yaml index 35b37492..5adbde47 100644 --- a/schema/NumberSchema.schema.yaml +++ b/schema/NumberSchema.schema.yaml @@ -27,7 +27,7 @@ properties: A number is valid against the schema only if it has a value greater than (not equal to) `exclusiveMinimum`. maximum: - '@id': stencila:exclusiveMaximum + '@id': stencila:maximum type: number description: The inclusive upper limit for a numeric node. $comment: | diff --git a/schema/TupleSchema.schema.yaml b/schema/TupleSchema.schema.yaml index d19f462f..0ef8457e 100644 --- a/schema/TupleSchema.schema.yaml +++ b/schema/TupleSchema.schema.yaml @@ -7,7 +7,7 @@ category: data description: A schema specifying constraints on an array of heterogeneous items. properties: items: - '@id': stencila:items + '@id': schema:itemListElement description: An array of schemas specifying the constraints on each successive item in the array. type: array items: diff --git a/ts/interpreter.ts b/ts/interpreter.ts index 2850f098..5e210cee 100644 --- a/ts/interpreter.ts +++ b/ts/interpreter.ts @@ -162,7 +162,7 @@ export function parseItem( parameters.push(item) } else if ( (isA('CodeChunk', item) || isA('CodeExpression', item)) && - item.language === 'javascript' + item.programmingLanguage === 'javascript' ) { if (isA('CodeChunk', item)) { const parseResult = parseCodeChunk(item) diff --git a/ts/parsing.test.ts b/ts/parsing.test.ts index 9e042a67..02b66475 100644 --- a/ts/parsing.test.ts +++ b/ts/parsing.test.ts @@ -265,22 +265,22 @@ describe('Parsing information from an Article', () => { { type: 'CodeChunk', text: "def a():\n return 'I am python!'", - language: 'notjavascript' + programmingLanguage: 'notjavascript' }, { type: 'CodeChunk', text: chunk1Text, - language: 'javascript' + programmingLanguage: 'javascript' }, { type: 'CodeChunk', text: chunk2Text, - language: 'javascript' + programmingLanguage: 'javascript' }, { type: 'CodeChunk', text: chunk3Text, - language: 'javascript', + programmingLanguage: 'javascript', declares: [ { type: 'Function', @@ -298,17 +298,17 @@ describe('Parsing information from an Article', () => { { type: 'CodeExpression', text: 'invalid code', - language: 'notjavascript' + programmingLanguage: 'notjavascript' }, { type: 'CodeExpression', text: expr1Text, - language: 'javascript' + programmingLanguage: 'javascript' }, { type: 'CodeExpression', text: expr2Text, - language: 'javascript' + programmingLanguage: 'javascript' } ] } @@ -327,18 +327,22 @@ describe('Parsing information from an Article', () => { expect((code[3] as CodeExpression).text).toEqual(expr1Text) expect((code[4] as CodeExpression).text).toEqual(expr2Text) - expect((code[0] as CodeChunkExecution).codeChunk.language).toEqual( + expect( + (code[0] as CodeChunkExecution).codeChunk.programmingLanguage + ).toEqual('javascript') + expect( + (code[1] as CodeChunkExecution).codeChunk.programmingLanguage + ).toEqual('javascript') + expect( + (code[2] as CodeChunkExecution).codeChunk.programmingLanguage + ).toEqual('javascript') + + expect((code[3] as CodeExpression).programmingLanguage).toEqual( 'javascript' ) - expect((code[1] as CodeChunkExecution).codeChunk.language).toEqual( + expect((code[4] as CodeExpression).programmingLanguage).toEqual( 'javascript' ) - expect((code[2] as CodeChunkExecution).codeChunk.language).toEqual( - 'javascript' - ) - - expect((code[3] as CodeExpression).language).toEqual('javascript') - expect((code[4] as CodeExpression).language).toEqual('javascript') }) test('it only parses Parameters that are not inside a Function', () => { @@ -353,7 +357,7 @@ describe('Parsing information from an Article', () => { const c = codeChunk( "import { export1 } from 'module-name3'\nimport { export2 } from 'module-name4'", { - language: 'javascript', + programmingLanguage: 'javascript', imports: ['module-name1', 'module-name2', 'module-name3'] } ) @@ -369,7 +373,10 @@ describe('Parsing information from an Article', () => { test("it doesn't add imports it finds to existing CodeChunk imports if the empty string semaphore is present", () => { const c = codeChunk( "import { export1 } from 'module-name3'\nimport { export2 } from 'module-name4'", - { language: 'javascript', imports: ['module-name1', 'module-name2', ''] } + { + programmingLanguage: 'javascript', + imports: ['module-name1', 'module-name2', ''] + } ) parseItem(c, [], [])