Skip to content
This repository has been archived by the owner on Jan 27, 2022. It is now read-only.

Commit

Permalink
feat(NontextualAnnotation): Adds node type for text that has a non-te…
Browse files Browse the repository at this point in the history
…xtual annotation

Closes #211.
  • Loading branch information
nokome committed Sep 8, 2020
1 parent 665842a commit 9b593eb
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 6 deletions.
23 changes: 20 additions & 3 deletions py/stencila/schema/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -2030,6 +2030,23 @@ def __init__(
self.funders = funders


class NontextualAnnotation(Mark):
"""Inline text that has a non-textual annotation."""

def __init__(
self,
content: Array["InlineContent"],
id: Optional[str] = None,
meta: Optional[Dict[str, Any]] = None
) -> None:
super().__init__(
content=content,
id=id,
meta=meta
)



class Organization(Thing):
"""An organization such as a school, NGO, corporation, club, etc."""

Expand Down Expand Up @@ -3665,7 +3682,7 @@ def __init__(
"""
All type schemas that are derived from Entity
"""
EntityTypes = Union["Entity", "ArrayValidator", "Article", "AudioObject", "BooleanValidator", "Brand", "Cite", "CiteGroup", "Code", "CodeBlock", "CodeChunk", "CodeError", "CodeExpression", "CodeFragment", "Collection", "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", "NumberValidator", "Organization", "Paragraph", "Parameter", "Periodical", "Person", "PostalAddress", "Product", "PropertyValue", "PublicationIssue", "PublicationVolume", "Quote", "QuoteBlock", "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", "Cite", "CiteGroup", "Code", "CodeBlock", "CodeChunk", "CodeError", "CodeExpression", "CodeFragment", "Collection", "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", "NumberValidator", "Organization", "Paragraph", "Parameter", "Periodical", "Person", "PostalAddress", "Product", "PropertyValue", "PublicationIssue", "PublicationVolume", "Quote", "QuoteBlock", "SoftwareApplication", "SoftwareEnvironment", "SoftwareSession", "SoftwareSourceCode", "StringValidator", "Strong", "Subscript", "Superscript", "Table", "TableCell", "TableRow", "ThematicBreak", "Thing", "TupleValidator", "Variable", "VideoObject", "VolumeMount"]


"""
Expand All @@ -3677,13 +3694,13 @@ def __init__(
"""
Union type for valid inline content.
"""
InlineContent = Union[None, bool, int, float, str, "CodeFragment", "CodeExpression", "Delete", "Emphasis", "ImageObject", "Link", "MathFragment", "Quote", "Strong", "Subscript", "Superscript", "Cite", "CiteGroup"]
InlineContent = Union[None, bool, int, float, str, "CodeFragment", "CodeExpression", "Delete", "Emphasis", "ImageObject", "Link", "MathFragment", "NontextualAnnotation", "Quote", "Strong", "Subscript", "Superscript", "Cite", "CiteGroup"]


"""
All type schemas that are derived from Mark
"""
MarkTypes = Union["Mark", "Delete", "Emphasis", "Quote", "Strong", "Subscript", "Superscript"]
MarkTypes = Union["Mark", "Delete", "Emphasis", "NontextualAnnotation", "Quote", "Strong", "Subscript", "Superscript"]


"""
Expand Down
1 change: 1 addition & 0 deletions r/NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export(MediaObject)
export(MediaObjectTypes)
export(MonetaryGrant)
export(Node)
export(NontextualAnnotation)
export(NumberValidator)
export(NumberValidatorTypes)
export(Organization)
Expand Down
31 changes: 28 additions & 3 deletions r/R/types.R
Original file line number Diff line number Diff line change
Expand Up @@ -2108,6 +2108,31 @@ MonetaryGrant <- function(
}


#' Inline text that has a non-textual annotation.
#'
#' @name NontextualAnnotation
#' @param content The content that is marked. \bold{Required}.
#' @param id The identifier for this item.
#' @param meta Metadata associated with this item.
#' @seealso \code{\link{Mark}}
#' @export
NontextualAnnotation <- function(
content,
id,
meta
){
self <- Mark(
content = content,
id = id,
meta = meta
)
self$type <- as_scalar("NontextualAnnotation")

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


#' An organization such as a school, NGO, corporation, club, etc.
#'
#' @name Organization
Expand Down Expand Up @@ -3809,7 +3834,7 @@ CreativeWorkTypes <- Union(CreativeWork, Article, AudioObject, Collection, Datat
#' All type schemas that are derived from Entity
#'
#' @export
EntityTypes <- Union(Entity, ArrayValidator, Article, AudioObject, BooleanValidator, Brand, Cite, CiteGroup, Code, CodeBlock, CodeChunk, CodeError, CodeExpression, CodeFragment, Collection, 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, NumberValidator, Organization, Paragraph, Parameter, Periodical, Person, PostalAddress, Product, PropertyValue, PublicationIssue, PublicationVolume, Quote, QuoteBlock, 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, Cite, CiteGroup, Code, CodeBlock, CodeChunk, CodeError, CodeExpression, CodeFragment, Collection, 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, NumberValidator, Organization, Paragraph, Parameter, Periodical, Person, PostalAddress, Product, PropertyValue, PublicationIssue, PublicationVolume, Quote, QuoteBlock, SoftwareApplication, SoftwareEnvironment, SoftwareSession, SoftwareSourceCode, StringValidator, Strong, Subscript, Superscript, Table, TableCell, TableRow, ThematicBreak, Thing, TupleValidator, Variable, VideoObject, VolumeMount)


#' All type schemas that are derived from Grant
Expand All @@ -3821,13 +3846,13 @@ GrantTypes <- Union(Grant, MonetaryGrant)
#' Union type for valid inline content.
#'
#' @export
InlineContent <- Union("NULL", "logical", "numeric", "character", CodeFragment, CodeExpression, Delete, Emphasis, ImageObject, Link, MathFragment, Quote, Strong, Subscript, Superscript, Cite, CiteGroup)
InlineContent <- Union("NULL", "logical", "numeric", "character", CodeFragment, CodeExpression, Delete, Emphasis, ImageObject, Link, MathFragment, NontextualAnnotation, Quote, Strong, Subscript, Superscript, Cite, CiteGroup)


#' All type schemas that are derived from Mark
#'
#' @export
MarkTypes <- Union(Mark, Delete, Emphasis, Quote, Strong, Subscript, Superscript)
MarkTypes <- Union(Mark, Delete, Emphasis, NontextualAnnotation, Quote, Strong, Subscript, Superscript)


#' All type schemas that are derived from Math
Expand Down
1 change: 1 addition & 0 deletions schema/InlineContent.schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ anyOf:
- $ref: ImageObject
- $ref: Link
- $ref: MathFragment
- $ref: NontextualAnnotation
- $ref: Quote
- $ref: Strong
- $ref: Subscript
Expand Down
15 changes: 15 additions & 0 deletions schema/NontextualAnnotation.schema.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
title: NontextualAnnotation
'@id': stencila:NontextualAnnotation
extends: Mark
role: secondary
status: stable
category: prose
description: Inline text that has a non-textual annotation.
$comment: |
Use cases include annotating spelling errors, denoting proper names in Chinese text,
representing underline text, and other forms of annotation. See
- https://developer.mozilla.org/en-US/docs/Web/HTML/Element/u
- http://html5doctor.com/u-element/
- https://jats.nlm.nih.gov/archiving/tag-library/1.1/element/underline.html
- https://github.com/jgm/pandoc-types/blob/master/src/Text/Pandoc/Definition.hs#L320
properties: {}

0 comments on commit 9b593eb

Please sign in to comment.