Package 'newsmd'

Title: Creation of NEWS.md File
Description: Adding updates (version or bullet points) to the NEWS.md file.
Authors: Jakob Gepp [cre, aut]
Maintainer: Jakob Gepp <[email protected]>
License: MIT + file LICENSE
Version: 0.5.1
Built: 2025-02-07 03:11:31 UTC
Source: https://github.com/dschaykib/newsmd

Help Index


Combining dev-versions into the next version

Description

Combining dev-versions into the next version

Usage

combine_dev(text = "")

Arguments

text

a string vector with the content of the get_text method

Value

a string vector with the reduced NEWS.md text


Retrieve the version number of a NEWS.md file

Description

This function tries to extract the version number within a file. There are a few pitfalls:

* If the word "version" is within the text but denotes a dependency it is still detected. * If the files has a date before the version it will return the date instead of the version * It is assumed, that the NEWS.md files is updated from the top. Ergo the latest version is the first one.

Usage

get_version(file, latest = TRUE)

Arguments

file

a path to a file

latest

a Boolean, if TRUE (default) only the latest version is returned

Value

either a single string or a vector with version numbers


Manipulate the NEWS.md file

Description

Manipulate the NEWS.md file.

Format

An R6 class.

Methods

Public methods


Method new()

Create a new news object.

Usage
news$new(
  text = c(paste0("## version ", version), "", "---", "", "### NEWS.md setup", "",
    "- added NEWS.md creation with [newsmd](https://github.com/Dschaykib/newsmd)", ""),
  version = "0.0.0.9000",
  file = NULL
)
Arguments
text

vector with context for the news.md file.

version

current version of the package.

file

a text file with the current news.md file. Use NULL to create new file.

Returns

A new 'news' object.


Method print()

Print a news object.

Usage
news$print()

Method get_text()

Get the news object as a text.

Usage
news$get_text()
Returns

The context of the news file.


Method write()

Write and save a news object.

Usage
news$write(file = "NEWS.md", reduce_dev = FALSE)
Arguments
file

A path and file to where the news file is saved.

reduce_dev

A boolean, if TRUE dev version's points are combined into the next version


Method add_version()

Adds a version line to a news object.

Usage
news$add_version(x)
Arguments
x

A string with the version number.


Method add_subtitle()

Adds a subtitle line to a news object.

Usage
news$add_subtitle(x)
Arguments
x

A string with the subtitle.


Method add_bullet()

Adds a bullet points to the last subtitle.

Usage
news$add_bullet(x)
Arguments
x

A vector with the bullet points.


Method clone()

The objects of this class are cloneable with this method.

Usage
news$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

See Also

newsmd

Examples

## Create a template
my_news <- news$new()
my_news$add_subtitle("improved things 1")
my_news$add_bullet("point 1")
my_news$add_bullet("point 2")

Creating a NEWS.md file

Description

This is a convenience wrapper for news$new(). If you already have a NEWS file you can add it's path to newsmd().

Usage

newsmd(
  file = NULL,
  text = c(paste0("## version ", version), "", "---", "", "### NEWS.md setup", "",
    "- added NEWS.md creation with [newsmd](https://github.com/Dschaykib/newsmd)", ""),
  version = "0.0.0.9000"
)

Arguments

file

name of the NEWS file to load. If not given a new file NEWS.md is created.

text

a character scalar containing the initial text.

version

a character with the version in the format major.minor.patch.dev.

Details

This functions creates a news object, which can be saved as the NEWS.md file with the internal method write(). One can add versions, subtitles and bullet points to the news.

If an existing NEWS.md file is given, the version is extracted with get_version and the dev part is bumped up.

Examples

newsmd()