| Type: | Package |
| Title: | Generate Comment Boxes with Custom Alignment |
| Version: | 2.1.0 |
| Description: | Provides a function to generate comment boxes framed with '#' characters, with configurable width and text alignment (left, center, or right). Useful for formatting scripts and improving code readability. |
| License: | MIT + file LICENSE |
| URL: | https://gitlab.com/r-packages3/easycomment |
| Encoding: | UTF-8 |
| RoxygenNote: | 7.3.2 |
| Suggests: | testthat (≥ 3.0.0) |
| Config/testthat/edition: | 3 |
| NeedsCompilation: | no |
| Packaged: | 2026-04-11 10:41:52 UTC; root |
| Author: | Gregoire Muller [aut, cre] |
| Maintainer: | Gregoire Muller <muller.gregoire@protonmail.com> |
| Repository: | CRAN |
| Date/Publication: | 2026-04-11 11:00:02 UTC |
Generate a Comment Box
Description
Generates a comment box framed with # characters, with configurable
width and text alignment. Long words that exceed the inner width are
automatically split across multiple lines.
When section_title = TRUE (the default), the top border doubles as
a named RStudio code section header, so the comment text appears in the
document outline instead of "Untitled". The border_style parameter
offers five visual presets controlling the fill characters of the top and
bottom borders.
Usage
generate_comment_box(comment, width = 80, align = "center",
section_title = TRUE, border_style = "sharp",
print_box = TRUE)
Arguments
comment |
A non-empty string containing the comment to be framed. | ||||||||||||||||||
width |
The total width of the comment box in characters. Must be
greater than 4. Default is | ||||||||||||||||||
align |
The alignment of the text inside the box. One of
| ||||||||||||||||||
section_title |
Logical. If | ||||||||||||||||||
border_style |
Character string selecting the fill characters for the
top and bottom borders when
The top character must be one of | ||||||||||||||||||
print_box |
Logical. If |
Value
If print_box is TRUE, prints the comment box to the console
and returns it invisibly as a character string.
If print_box is FALSE, returns the comment box as a single
character string with newline characters (\n) separating each row.
Examples
# Style par défaut (sharp) : # en haut, / en bas
generate_comment_box("Chargement des données")
# Style double : = en haut, / en bas
generate_comment_box("Modélisation", border_style = "double")
# Style light : - en haut, ~ en bas, aligné à gauche
generate_comment_box("Paramètres", border_style = "light", align = "left")
# Style soft : = en haut, ~ en bas
generate_comment_box("Résultats", border_style = "soft")
# Style wave : # en haut, ~ en bas
generate_comment_box("Exports", border_style = "wave")
# Comportement d'origine : deux bordures pleines de #
generate_comment_box("Legacy box", section_title = FALSE)