check_links: Check links in your documents

Description Usage Arguments Details Value

View source: R/checker.R

Description

Check links in your documents

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
check_links(
  dir = ".",
  recurse = TRUE,
  regexp = "\\.html?$",
  glob = NULL,
  root_dir = dir,
  ignore_pattern = NULL,
  ignore_tag = NULL,
  check_external = TRUE,
  only_with_issues = TRUE,
  by = c("page", "resource"),
  show_summary = TRUE,
  checker_options = NULL,
  stop_on_error = FALSE,
  quiet = FALSE,
  ...
)

Arguments

dir

The directory to look for documents

recurse

Should sub-folders be searched for documents? (default 'TRUE').

regexp

A regular expression matching the names of the files to check.

glob

A wildcard pattern matching the names of the files to check.

root_dir

The path for the root of the website. By default, the same value as 'dir', but can be overriden to use another path (if testing only some files within the directory structure of the site) or a webserver address (e.g., 'http://localhost:4000', if testing a Jekyll site).

ignore_pattern

A vector of regular expressions matching the path of the links to ignore in the files (see Details).

ignore_tag

A vector of HTML tags to ignore.

check_external

Should external links be checked? If 'FALSE', only local links will be checked.

only_with_issues

Should the results include only the broken links (default) or also the valid links?

by

How should the results of the checks be aggregated?

show_summary

Should a list of all problematic links be displayed?

checker_options

An optional list that specifies which situations checker should consider invalid. See checker_options.

stop_on_error

When errors are thrown, should the call be interrupted? If 'FALSE', the error is displayed as a message on the terminal and the resuulting object is returned. If 'TRUE', an error is thrown and the function call is stopped.

quiet

Should the progress of the function be displayed?

...

additional parameters to be passed to 'grep' to match the file names to check.

Details

Data URI and mailto: links are not checked.

The by argument controls how the summary of the results is being displayed. Using page is typically more convenient for small sites, while resource works better for larger websites that use templates are more likely to have mispecified resources across many pages.

'checker' attempts to respect the rules specified by the 'robots.txt' files provided by the external servers. Thus some URLs might not be checked.

## Ignore pattern

If more than one regular expressions is provided to 'ignore_pattern', they will be evaluated in succession: thus, the order in which you provide them may matter. For local files, matching of the regular expressions is done on the fully expanded link paths. Make sure your regular expression don't inadvertently match patterns higher up in your tree files to the risk of excluding all files from being checked.

Value

a tibble with the name of the file that includes the link, the link, the expanded full path (useful for local/relative links), whether the link is valid, and possibly the message/HTTP code returned by the server.


fmichonneau/checker documentation built on July 3, 2020, 3:13 a.m.