comments: Extract all comments or functions from a file

extract_commentR Documentation

Extract all comments or functions from a file

Description

Vectorize all comments from the file

Usage

extract_comment(file)

remove_content_in_quotes(line)

remove_comment(line)

clean_file(file, output_file)

get_func_def(file)

Arguments

file

file to parse

line

string vector to remove contents within quotes or comments

output_file

file path to write the output of the new file

Value

vector of all comments within a file

Examples

## Not run: 
ex_file1 <- "path/file1.R"
# get all comments
cmmts <- extract_comment(ex_file1)
cmmts

## End(Not run)

## Not run: 
# Ex to clean out comments from file
file_path <- ".testR"
output_file_path <- ".cleaned_script.R"
clean_file(file_path, output_file_path)

## End(Not run)

# example code

## Not run: 
# Ex to get all defined functions
# within a file
file_path <- ".testR"
get_func_def(file_path)

## End(Not run)

quickcode documentation built on April 11, 2025, 5:49 p.m.