Skip to content

Commit

Permalink
fix(Language bindings): Handle enumeration types
Browse files Browse the repository at this point in the history
  • Loading branch information
nokome committed Apr 14, 2021
1 parent de06cb9 commit a524c92
Show file tree
Hide file tree
Showing 8 changed files with 611 additions and 236 deletions.
349 changes: 347 additions & 2 deletions py/stencila/schema/types.py

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions r/NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ export(AudioObject)
export(BlockContent)
export(BooleanValidator)
export(Brand)
export(CitationTypeEnumeration)
export(Cite)
export(CiteGroup)
export(Claim)
export(Code)
export(CodeBlock)
export(CodeBlockTypes)
Expand All @@ -36,6 +38,8 @@ export(Entity)
export(EntityTypes)
export(Enum)
export(EnumValidator)
export(Enumeration)
export(EnumerationTypes)
export(Figure)
export(Function)
export(Grant)
Expand Down
62 changes: 60 additions & 2 deletions r/R/types.R
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ BooleanValidator <- function(
#' @param citationMode Determines how the citation is shown within the surrounding text.
#' @param citationPrefix Text to show before the citation.
#' @param citationSuffix Text to show after the citation.
#' @param citationType The type/s of the citation, both factually and rhetorically.
#' @param content Optional structured content/text of this citation.
#' @param id The identifier for this item.
#' @param meta Metadata associated with this item.
Expand All @@ -106,6 +107,7 @@ Cite <- function(
citationMode,
citationPrefix,
citationSuffix,
citationType,
content,
id,
meta,
Expand All @@ -122,6 +124,7 @@ Cite <- function(
self[["citationMode"]] <- check_property("Cite", "citationMode", FALSE, missing(citationMode), Enum("Parenthetical", "Narrative", "NarrativeAuthor", "NarrativeYear", "normal", "suppressAuthor"), citationMode)
self[["citationPrefix"]] <- check_property("Cite", "citationPrefix", FALSE, missing(citationPrefix), "character", citationPrefix)
self[["citationSuffix"]] <- check_property("Cite", "citationSuffix", FALSE, missing(citationSuffix), "character", citationSuffix)
self[["citationType"]] <- check_property("Cite", "citationType", FALSE, missing(citationType), Array(CitationTypeEnumeration), citationType)
self[["content"]] <- check_property("Cite", "content", FALSE, missing(content), Array(InlineContent), content)
self[["pageEnd"]] <- check_property("Cite", "pageEnd", FALSE, missing(pageEnd), Union("numeric", "character"), pageEnd)
self[["pageStart"]] <- check_property("Cite", "pageStart", FALSE, missing(pageStart), Union("numeric", "character"), pageStart)
Expand Down Expand Up @@ -1726,6 +1729,47 @@ EnumValidator <- function(
}


#' Lists or enumerations, for example, a list of cuisines or music genres, etc.
#'
#' @name Enumeration
#' @param alternateNames Alternate names (aliases) for the item.
#' @param description A description of the item.
#' @param id The identifier for this item.
#' @param identifiers Any kind of identifier for any kind of Thing.
#' @param images Images of the item.
#' @param meta Metadata associated with this item.
#' @param name The name of the item.
#' @param url The URL of the item.
#' @return A `list` of class `Enumeration`
#' @seealso \code{\link{Thing}}
#' @export
Enumeration <- function(
alternateNames,
description,
id,
identifiers,
images,
meta,
name,
url
){
self <- Thing(
alternateNames = alternateNames,
description = description,
id = id,
identifiers = identifiers,
images = images,
meta = meta,
name = name,
url = url
)
self$type <- as_scalar("Enumeration")

class(self) <- c(class(self), "Enumeration")
self
}


#' Encapsulates one or more images, videos, tables, etc, and provides captions and labels for them.
#'
#' @name Figure
Expand Down Expand Up @@ -4358,6 +4402,13 @@ VolumeMount <- function(



#' The type or nature of a citation, both factually and rhetorically.
#'
#' @return A `list` of class `Enum` describing valid members of this enumeration
#' @export
CitationTypeEnumeration <- Enum("AffilationSelfCitation", "AgreesWith", "AuthorNetworkSelfCitation", "AuthorSelfCitation", "CitesAsAuthority", "CitesAsDataSource", "CitesAsEvidence", "CitesAsMetadataDocument", "CitesAsPotentialSolution", "CitesAsRecommendedReading", "CitesAsRelated", "CitesAsSourceDocument", "CitesForInformation", "Compiles", "Confirms", "ContainsAssertionFrom", "Corrects", "Credits", "Critiques", "Derides", "Describes", "DisagreesWith", "Discusses", "Disputes", "DistantCitation", "Documents", "Extends", "FunderSelfCitation", "GivesBackgroundTo", "GivesSupportTo", "HasReplyFrom", "IncludesExcerptFrom", "IncludesQuotationFrom", "IsAgreedWithBy", "IsCitedAsAuthorityBy", "IsCitedAsDataSourceBy", "IsCitedAsEvidenceBy", "IsCitedAsMetadataDocumentBy", "IsCitedAsPontentialSolutionBy", "IsCitedAsRecommendedReadingBy", "IsCitedAsRelatedBy", "IsCitedAsSourceDocumentBy", "IsCitedBy", "IsCitedForInformationBy", "IsCompiledBy", "IsConfirmedBy", "IsCorrectedBy", "IsCreditedBy", "IsCritiquedBy", "IsDeridedBy", "IsDescribedBy", "IsDisagreedWithBy", "IsDiscussedBy", "IsDisputedBy", "IsDocumentedBy", "IsExtendedBy", "IsLinkedToBy", "IsParodiedBy", "IsPlagiarizedBy", "IsQualifiedBy", "IsRefutedBy", "IsRetractedBy", "IsReviewedBy", "IsRidiculedBy", "IsSpeculatedOnBy", "IsSupportedBy", "IsUpdatedBy", "JournalCartelCitation", "JournalSelfCitation", "Likes", "LinksTo", "ObtainsBackgroundFrom", "ObtainsSupportFrom", "Parodies", "Plagiarizes", "ProvidesAssertionFor", "ProvidesConclusionsFor", "ProvidesDataFor", "ProvidesExcerptFor", "ProvidesMethodFor", "ProvidesQuotationFor", "Qualifies", "Refutes", "RepliesTo", "Retracts", "Reviews", "Ridicules", "SelfCitation", "SharesAuthorInstitutionWith", "SharesAuthorWith", "SharesFundingAgencyWith", "SharesJournalWith", "SharesPublicationVenueWith", "SpeculatesOn", "Supports", "Updates", "UsesConclusionsFrom", "UsesDataFrom", "UsesMethodIn")


#' Union type for valid block content.
#'
#' @return A `list` of class `Union` describing valid subtypes of this type
Expand Down Expand Up @@ -4404,7 +4455,14 @@ CreativeWorkTypes <- Union(CreativeWork, Article, AudioObject, Claim, Collection
#'
#' @return A `list` of class `Union` describing valid subtypes of this type
#' @export
EntityTypes <- Union(Entity, ArrayValidator, Article, AudioObject, BooleanValidator, Brand, Cite, CiteGroup, Claim, Code, CodeBlock, CodeChunk, CodeError, CodeExpression, CodeFragment, Collection, Comment, ConstantValidator, ContactPoint, CreativeWork, Datatable, DatatableColumn, Date, DefinedTerm, Delete, Emphasis, EnumValidator, Figure, Function, Grant, Heading, ImageObject, Include, IntegerValidator, Link, List, ListItem, Mark, Math, MathBlock, MathFragment, MediaObject, MonetaryGrant, NontextualAnnotation, Note, NumberValidator, Organization, Paragraph, Parameter, Periodical, Person, PostalAddress, Product, PropertyValue, PublicationIssue, PublicationVolume, Quote, QuoteBlock, Review, SoftwareApplication, SoftwareEnvironment, SoftwareSession, SoftwareSourceCode, StringValidator, Strong, Subscript, Superscript, Table, TableCell, TableRow, ThematicBreak, Thing, TupleValidator, Variable, VideoObject, VolumeMount)
EntityTypes <- Union(Entity, ArrayValidator, Article, AudioObject, BooleanValidator, Brand, CitationTypeEnumeration, Cite, CiteGroup, Claim, Code, CodeBlock, CodeChunk, CodeError, CodeExpression, CodeFragment, Collection, Comment, ConstantValidator, ContactPoint, CreativeWork, Datatable, DatatableColumn, Date, DefinedTerm, Delete, Emphasis, EnumValidator, Enumeration, Figure, Function, Grant, Heading, ImageObject, Include, IntegerValidator, Link, List, ListItem, Mark, Math, MathBlock, MathFragment, MediaObject, MonetaryGrant, NontextualAnnotation, Note, NumberValidator, Organization, Paragraph, Parameter, Periodical, Person, PostalAddress, Product, PropertyValue, PublicationIssue, PublicationVolume, Quote, QuoteBlock, Review, SoftwareApplication, SoftwareEnvironment, SoftwareSession, SoftwareSourceCode, StringValidator, Strong, Subscript, Superscript, Table, TableCell, TableRow, ThematicBreak, Thing, TupleValidator, Variable, VideoObject, VolumeMount)


#' All type schemas that are derived from Enumeration
#'
#' @return A `list` of class `Union` describing valid subtypes of this type
#' @export
EnumerationTypes <- Union(Enumeration, CitationTypeEnumeration)


#' All type schemas that are derived from Grant
Expand Down Expand Up @@ -4460,7 +4518,7 @@ NumberValidatorTypes <- Union(NumberValidator, IntegerValidator)
#'
#' @return A `list` of class `Union` describing valid subtypes of this type
#' @export
ThingTypes <- Union(Thing, Article, AudioObject, Brand, Claim, Collection, Comment, ContactPoint, CreativeWork, Datatable, DatatableColumn, DefinedTerm, Figure, Grant, ImageObject, ListItem, MediaObject, MonetaryGrant, Organization, Periodical, Person, PostalAddress, Product, PropertyValue, PublicationIssue, PublicationVolume, Review, SoftwareApplication, SoftwareEnvironment, SoftwareSession, SoftwareSourceCode, Table, VideoObject, VolumeMount)
ThingTypes <- Union(Thing, Article, AudioObject, Brand, CitationTypeEnumeration, Claim, Collection, Comment, ContactPoint, CreativeWork, Datatable, DatatableColumn, DefinedTerm, Enumeration, Figure, Grant, ImageObject, ListItem, MediaObject, MonetaryGrant, Organization, Periodical, Person, PostalAddress, Product, PropertyValue, PublicationIssue, PublicationVolume, Review, SoftwareApplication, SoftwareEnvironment, SoftwareSession, SoftwareSourceCode, Table, VideoObject, VolumeMount)


#' Union type for all validator types.
Expand Down
Loading

0 comments on commit a524c92

Please sign in to comment.