| Title: | Generate Comment Boxes with Custom Alignment |
|---|---|
| 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. |
| Authors: | Gregoire Muller [aut, cre] |
| Maintainer: | Gregoire Muller <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 2.1.0 |
| Built: | 2026-05-11 09:42:24 UTC |
| Source: | https://github.com/cran/easyComment |
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.
generate_comment_box(comment, width = 80, align = "center", section_title = TRUE, border_style = "sharp", print_box = TRUE)generate_comment_box(comment, width = 80, align = "center", section_title = TRUE, border_style = "sharp", print_box = TRUE)
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 |
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.
# 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)# 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)