get_lines_between_tags: Cut Code Chunks From a File

View source: R/get_lines_between_tags.R

get_lines_between_tagsR Documentation

Cut Code Chunks From a File

Description

Get all lines between tagged lines. The tagged lines themselves may be in- or excluded from the selection.

Usage

get_lines_between_tags(
  file_name,
  keep_tagged_lines = TRUE,
  begin_pattern = "ROXYGEN_START",
  end_pattern = "ROXYGEN_STOP",
  from_first_line = TRUE,
  to_last_line = TRUE
)

Arguments

file_name

The name of the R code file to be parsed.

keep_tagged_lines

Keep tagged lines output?

begin_pattern

A pattern that marks the line beginning a roxygen2 chunk.

end_pattern

A pattern that marks the line ending a roxygen2 chunk.

from_first_line

Use first line as tagged line if first tag found matches the end_pattern?

to_last_line

Use last line as tagged line if last tag found matches the begin_pattern?

Value

A character vector of matching lines.

Note

If you know the file to contain valid roxygen2 code only, you do not need to tag any lines if you keep from_first_line and to_last_line both TRUE: in this case the whole file will be returned.

See Also

Other file utilities: clipboard_path(), delete_trailing_blank_lines(), delete_trailing_whitespace(), develop_test(), file_copy(), file_modified_last(), file_save(), find_files(), get_mtime(), get_unique_string(), grep_file(), is_files_current(), is_path(), paths, search_files(), split_code_file(), touch()


fritools documentation built on Nov. 19, 2023, 1:06 a.m.