Skip to content

Commit

Permalink
fix(Cite): Rename to citationPrefix and citationSuffix
Browse files Browse the repository at this point in the history
  • Loading branch information
nokome committed Mar 20, 2021
1 parent 79dcfaf commit 379dffc
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 22 deletions.
26 changes: 13 additions & 13 deletions py/stencila/schema/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@ class Cite(Entity):
citationMode: Optional["ECitationMode"] = None
"""Determines how the citation is shown within the surrounding text."""

citationPrefix: Optional[str] = None
"""Text to show before the citation."""

citationSuffix: Optional[str] = None
"""Text to show after the citation."""

content: Optional[Array["InlineContent"]] = None
"""Optional structured content/text of this citation."""

Expand All @@ -126,25 +132,19 @@ class Cite(Entity):
for example, "1-6, 9, 55".
"""

prefix: Optional[str] = None
"""Text to show before the citation."""

suffix: Optional[str] = None
"""Text to show after the citation."""


def __init__(
self,
target: str,
citationMode: Optional["ECitationMode"] = None,
citationPrefix: Optional[str] = None,
citationSuffix: Optional[str] = None,
content: Optional[Array["InlineContent"]] = None,
id: Optional[str] = None,
meta: Optional[Dict[str, Any]] = None,
pageEnd: Optional[Union[int, str]] = None,
pageStart: Optional[Union[int, str]] = None,
pagination: Optional[str] = None,
prefix: Optional[str] = None,
suffix: Optional[str] = None
pagination: Optional[str] = None
) -> None:
super().__init__(
id=id,
Expand All @@ -154,6 +154,10 @@ def __init__(
self.target = target
if citationMode is not None:
self.citationMode = citationMode
if citationPrefix is not None:
self.citationPrefix = citationPrefix
if citationSuffix is not None:
self.citationSuffix = citationSuffix
if content is not None:
self.content = content
if pageEnd is not None:
Expand All @@ -162,10 +166,6 @@ def __init__(
self.pageStart = pageStart
if pagination is not None:
self.pagination = pagination
if prefix is not None:
self.prefix = prefix
if suffix is not None:
self.suffix = suffix


class CiteGroup(Entity):
Expand Down
14 changes: 7 additions & 7 deletions r/R/types.R
Original file line number Diff line number Diff line change
Expand Up @@ -90,28 +90,28 @@ BooleanValidator <- function(
#' @name Cite
#' @param target The target of the citation (URL or reference ID). \bold{Required}.
#' @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 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".
#' @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 prefix Text to show before the citation.
#' @param suffix Text to show after the citation.
#' @return A `list` of class `Cite`
#' @seealso \code{\link{Entity}}
#' @export
Cite <- function(
target,
citationMode,
citationPrefix,
citationSuffix,
content,
id,
meta,
pageEnd,
pageStart,
pagination,
prefix,
suffix
pagination
){
self <- Entity(
id = id,
Expand All @@ -120,12 +120,12 @@ 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("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[["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)
self[["pagination"]] <- check_property("Cite", "pagination", FALSE, missing(pagination), "character", pagination)
self[["prefix"]] <- check_property("Cite", "prefix", FALSE, missing(prefix), "character", prefix)
self[["suffix"]] <- check_property("Cite", "suffix", FALSE, missing(suffix), "character", suffix)
class(self) <- c(class(self), "Cite")
self
}
Expand Down
10 changes: 8 additions & 2 deletions schema/Cite.schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,20 @@ properties:
Any description of pages that is not separated into pageStart and pageEnd;
for example, "1-6, 9, 55".
type: string
prefix:
citationPrefix:
'@id': stencila:citationPrefix
description: Text to show before the citation.
type: string
suffix:
$comment: |
Previously this was name `prefix` but for consistency with `citationMode`
and `honorificPrefix`, to avoid ambiguity with other prefixes was renamed
to `citationPrefix`.
citationSuffix:
'@id': stencila:citationSuffix
description: Text to show after the citation.
type: string
$comment: |
See comment on `citationPrefix` regarding naming.
target:
'@id': stencila:target
description: The target of the citation (URL or reference ID).
Expand Down

0 comments on commit 379dffc

Please sign in to comment.