Package 'readme2vignette'

Title: Convert README to Vignette During Package Installation
Description: Convert README.md to vignettes when installing packages without vignettes.
Authors: Mao Kobayashi [aut, cre]
Maintainer: Mao Kobayashi <[email protected]>
License: MIT + file LICENSE
Version: 0.1.0
Built: 2024-09-25 06:18:33 UTC
Source: CRAN

Help Index


Add README to vignette

Description

If a package does not have a vignette but has a README.md, make the contents of the README.md be the vignette

Usage

add_readme_to_vignette(
  source,
  vignette_title = NULL,
  braced_vignette_title = "README",
  vignette_slug = "README",
  quiet = FALSE
)

Arguments

source

String. The directory path where the package is deployed.

vignette_title

String. The intended title of the vignette. If not provided, no title will be attached.

braced_vignette_title

String. The title of the vignette.

vignette_slug

String. filename to be used as the vignette. By default this will be README.

quiet

Logical. Whether to message about what is happening.

Details

Review the DISCRIPTION file and file structure and add the necessary dependencies and files.

Value

Invisible NULL.

Examples

## Not run: 
# In the package directory.
add_readme_to_vignette(".")

## End(Not run)

Attempts to install a package from CRAN with with convert README to Vignette during Package installation.

Description

The bulk of the code is based on remotes::install_cran(), for packages without vignette, convert README.md to vignette and install.

Usage

install_cran_with_readme(
  pkgs,
  repos = getOption("repos"),
  type = getOption("pkgType"),
  dependencies = NA,
  upgrade = c("default", "ask", "always", "never"),
  force = FALSE,
  quiet = FALSE,
  build = TRUE,
  build_opts = c("--no-resave-data", "--no-manual", "--no-build-vignettes"),
  build_manual = FALSE,
  readme_to_vignette = TRUE,
  build_vignettes = readme_to_vignette,
  ...
)

Arguments

pkgs

A character vector of packages to install.

repos

A character vector giving repositories to use.

type

Type of package to update.

dependencies

Which dependencies do you want to check? Can be a character vector (selecting from "Depends", "Imports", "LinkingTo", "Suggests", or "Enhances"), or a logical vector.

TRUE is shorthand for "Depends", "Imports", "LinkingTo" and "Suggests". NA is shorthand for "Depends", "Imports" and "LinkingTo" and is the default. FALSE is shorthand for no dependencies (i.e. just check this package, not its dependencies).

The value "soft" means the same as TRUE, "hard" means the same as NA.

You can also specify dependencies from one or more additional fields, common ones include:

  • Config/Needs/website - for dependencies used in building the pkgdown site.

  • Config/Needs/coverage for dependencies used in calculating test coverage.

upgrade

Should package dependencies be upgraded? One of "default", "ask", "always", or "never". "default" respects the value of the R_REMOTES_UPGRADE environment variable if set, and falls back to "ask" if unset. "ask" prompts the user for which out of date packages to upgrade. For non-interactive sessions "ask" is equivalent to "always". TRUE and FALSE are also accepted and correspond to "always" and "never" respectively.

force

Force installation, even if the remote state has not changed since the previous install.

quiet

If TRUE, suppress output.

build

If TRUE build the package before installing.

build_opts

Options to pass to ⁠R CMD build⁠, only used when build is TRUE.

build_manual

If FALSE, don't build PDF manual ('–no-manual').

readme_to_vignette

Logical value. If TRUE, installs the contents of README.md as Vignette for packages without Vignette, if README.md is available; if FALSE, the behavior is the same as remotes::install_cran().

build_vignettes

If FALSE, don't build package vignettes ('–no-build-vignettes').

...

Other arguments passed on to utils::install.packages().

Details

The code is basically based on remotes::install_cran(), that remotes version 2.4.2. It just intersperses the process of making README.md into vignettes if there are no vignettes when the package source is extracted during the installation.

The remotes package on which this code is based was created by the author of remotes and is now released at MIT. The author of the remotes package is currently listed as Developed by Gábor Csárdi, Jim Hester, Hadley Wickham, Winston Chang, Martin Morgan, Dan Tenenbaum, Posit Software, PBC. See r-lib/remote for detailed authorship.

Value

Invisible NULL.

Note

Binary format is not supported. The package must be installed from the source package.

Under the current specification, the images in the README.md are copied for the figures in the directories under ⁠man/figures/⁠, but not for the images in other directories, which are missing.

See Also

remotes::install_cran()

https://github.com/r-lib/remotes

https://remotes.r-lib.org/

Other package installation: install_github_with_readme()

Examples

## Not run: 
install_cran_with_readme("arabic2kansuji")

## End(Not run)

Attempts to install a package directly from GitHub with convert README to Vignette during Package installation.

Description

The bulk of the code is based on remotes::install_github(), for packages without vignette, convert README.md to vignette and install.

Usage

install_github_with_readme(
  repo,
  ref = "HEAD",
  subdir = NULL,
  auth_token = github_pat(quiet),
  host = "api.github.com",
  dependencies = NA,
  upgrade = c("default", "ask", "always", "never"),
  force = FALSE,
  quiet = FALSE,
  build = TRUE,
  build_opts = c("--no-resave-data", "--no-manual", "--no-build-vignettes"),
  build_manual = FALSE,
  readme_to_vignette = TRUE,
  build_vignettes = readme_to_vignette,
  repos = getOption("repos"),
  type = getOption("pkgType"),
  ...
)

Arguments

repo

Repository address in the format ⁠username/repo[/subdir][@ref|#pull|@*release]⁠. Alternatively, you can specify subdir and/or ref using the respective parameters (see below); if both are specified, the values in repo take precedence.

ref

Desired git reference. Could be a commit, tag, or branch name, or a call to github_pull() or github_release(). Defaults to "HEAD", which means the default branch on GitHub and for git remotes. See setting-the-default-branch for more details.

subdir

Subdirectory within repo that contains the R package.

auth_token

To install from a private repo, generate a personal access token (PAT) with at least repo scope in https://github.com/settings/tokens and supply to this argument. This is safer than using a password because you can easily delete a PAT without affecting any others. Defaults to the GITHUB_PAT environment variable.

host

GitHub API host to use. Override with your GitHub enterprise hostname, for example, "github.hostname.com/api/v3".

dependencies

Which dependencies do you want to check? Can be a character vector (selecting from "Depends", "Imports", "LinkingTo", "Suggests", or "Enhances"), or a logical vector.

TRUE is shorthand for "Depends", "Imports", "LinkingTo" and "Suggests". NA is shorthand for "Depends", "Imports" and "LinkingTo" and is the default. FALSE is shorthand for no dependencies (i.e. just check this package, not its dependencies).

The value "soft" means the same as TRUE, "hard" means the same as NA.

You can also specify dependencies from one or more additional fields, common ones include:

  • Config/Needs/website - for dependencies used in building the pkgdown site.

  • Config/Needs/coverage for dependencies used in calculating test coverage.

upgrade

Should package dependencies be upgraded? One of "default", "ask", "always", or "never". "default" respects the value of the R_REMOTES_UPGRADE environment variable if set, and falls back to "ask" if unset. "ask" prompts the user for which out of date packages to upgrade. For non-interactive sessions "ask" is equivalent to "always". TRUE and FALSE are also accepted and correspond to "always" and "never" respectively.

force

Force installation, even if the remote state has not changed since the previous install.

quiet

If TRUE, suppress output.

build

If TRUE build the package before installing.

build_opts

Options to pass to ⁠R CMD build⁠, only used when build is TRUE.

build_manual

If FALSE, don't build PDF manual ('–no-manual').

readme_to_vignette

Logical value. If TRUE, installs the contents of README.md as Vignette for packages without Vignette, if README.md is available; if FALSE, the behavior is the same as remotes::install_github().

build_vignettes

If FALSE, don't build package vignettes ('–no-build-vignettes').

repos

A character vector giving repositories to use.

type

Type of package to update.

...

Other arguments passed on to utils::install.packages().

Details

The code is basically based on remotes::install_github(), that remotes version 2.4.2. It just intersperses the process of making README.md into vignettes if there are no vignettes when the package source is extracted during the installation.

The remotes package on which this code is based was created by the author of remotes and is now released at MIT. The author of the remotes package is currently listed as Developed by Gábor Csárdi, Jim Hester, Hadley Wickham, Winston Chang, Martin Morgan, Dan Tenenbaum, Posit Software, PBC. See r-lib/remote for detailed authorship.

Value

Invisible NULL.

Note

Under the current specification, the images in the README.md are copied for the figures in the directories under ⁠man/figures/⁠, but not for the images in other directories, which are missing.

See Also

remotes::install_github()

https://github.com/r-lib/remotes

https://remotes.r-lib.org/

Other package installation: install_cran_with_readme()

Examples

## Not run: 
install_github_with_readme("indenkun/MissMech")

## End(Not run)