Skip to content

Commit ddeb58b

Browse files
committed
fix: fix and improvemets
1 parent 2ad4f71 commit ddeb58b

File tree

14 files changed

+432
-59
lines changed

14 files changed

+432
-59
lines changed

.github/workflows/pr-commands.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252
env:
5353
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
5454
steps:
55-
- uses: actions/checkout@v3
55+
- uses: actions/checkout@v4
5656

5757
- uses: r-lib/actions/pr-fetch@v2
5858
with:

.lintr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ linters: linters_with_defaults(
55
)
66
exclusions: list(
77
"inst/",
8-
"man/",
9-
"vignettes/"
8+
"man/"
9+
# Removed "vignettes/" to enforce linting on vignettes
1010
)
1111
encoding: "UTF-8"

DESCRIPTION

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
Package: myrpackage
22
Type: Package
3-
Title: A Minimal R Package
4-
Version: 0.0.0.9000
3+
Title: Multilingual Greeting and Farewell Functions
4+
Version: 0.1.0
55
Authors@R:
66
person(given = "Diogo", family = "Ribeiro", email = "[email protected]", role = c("aut", "cre"), comment = c(ORCID = "0009-0001-2022-7072", affiliation = "ESMAD - Instituto Politécnico do Porto"))
7-
Description: A short description of what the package does.
7+
Description: Provides functions for greeting and saying farewell in multiple languages.
8+
The package supports English, Spanish, French, Portuguese, German, and Italian.
9+
It demonstrates proper R package structure, documentation, and testing practices.
10+
Functions include customization options for formatting and punctuation.
811
License: MIT + file LICENSE
912
Encoding: UTF-8
1013
LazyData: true

NEWS.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,27 @@
11
# myrpackage NEWS
22

3-
## myrpackage 0.0.0.9000 (Development version)
3+
## myrpackage 0.1.0
44

55
### New features
66

77
* Added `hello()` function for multilingual greetings
88
* Added `goodbye()` function for multilingual farewells
99
* Added comprehensive documentation and examples
1010
* Added unit tests for all functions
11+
* Added support for name capitalization in both functions
12+
* Added proper language validation with helpful warnings
1113

1214
### Package structure
1315

1416
* Initial package setup with proper R package structure
15-
* Added vignette for package introduction
17+
* Added vignettes for package introduction and advanced usage
1618
* Added continuous integration with GitHub Actions
1719
* Added code coverage tracking
1820
* Added package website with pkgdown
1921

2022
### Improvements
2123

2224
* Added input validation to all functions
23-
* Added support for multiple languages (English, Spanish, French, Portuguese)
25+
* Added support for multiple languages (English, Spanish, French, Portuguese, German, Italian)
2426
* Added proper documentation with roxygen2
27+
* Implemented utility functions for common operations

R/myrpackage-package.R

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,29 @@
11
#' @keywords internal
22
"_PACKAGE"
33

4-
#' myrpackage: A Minimal R Package
4+
#' myrpackage: A Multilingual Greeting Package
55
#'
66
#' @description
7-
#' A minimal R package that provides greeting functions.
8-
#' This package is designed to demonstrate proper R package structure
9-
#' and documentation practices.
7+
#' A friendly R package that provides greeting and farewell functions in multiple languages.
8+
#' This package demonstrates proper R package structure, documentation, and test practices.
9+
#' It is designed to be a simple but complete example of R package development.
1010
#'
1111
#' @section Main functions:
1212
#' \itemize{
1313
#' \item \code{\link{hello}} - Say hello in various languages
1414
#' \item \code{\link{goodbye}} - Say goodbye in various languages
1515
#' }
1616
#'
17+
#' @section Supported languages:
18+
#' \itemize{
19+
#' \item English (default)
20+
#' \item Spanish
21+
#' \item French
22+
#' \item Portuguese
23+
#' \item German
24+
#' \item Italian
25+
#' }
26+
#'
1727
#' @docType package
1828
#' @name myrpackage-package
1929
NULL

README.md

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
# myrpackage
1+
# myrpackage <img src="man/figures/logo.png" align="right" height="139" alt="myrpackage logo" />
22

33
<!-- badges: start -->
44
[![R-CMD-check](https://github.com/DiogoRibeiro7/myrpackage/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/DiogoRibeiro7/myrpackage/actions/workflows/R-CMD-check.yaml)
55
[![Codecov test coverage](https://codecov.io/gh/DiogoRibeiro7/myrpackage/branch/main/graph/badge.svg)](https://codecov.io/gh/DiogoRibeiro7/myrpackage?branch=main)
66
[![CRAN status](https://www.r-pkg.org/badges/version/myrpackage)](https://CRAN.R-project.org/package=myrpackage)
7-
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)
7+
[![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable)
88
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
99
<!-- badges: end -->
1010

11-
A minimal R package scaffold, structured for publication on [CRAN](https://cran.r-project.org/), with boilerplate files and metadata to begin development immediately.
11+
A friendly R package that provides greeting and farewell functions in multiple languages.
1212

1313
## Installation
1414

@@ -41,22 +41,49 @@ hello("amigos", language = "spanish")
4141
hello("mes amis", language = "french")
4242
#> Bonjour, mes amis!
4343

44+
# Say hello with capitalization
45+
hello("r users", capitalize = TRUE)
46+
#> Hello, R users!
47+
4448
# Say goodbye
4549
goodbye()
4650
#> Goodbye, world!
4751

4852
goodbye("friends", language = "portuguese")
4953
#> Adeus, friends!
54+
55+
# Customize punctuation
56+
goodbye("everyone", exclamation = FALSE)
57+
#> Goodbye, everyone.
5058
```
5159

5260
## Features
5361

54-
- 🌐 Multilingual greeting and farewell functions
62+
- 🌐 Multilingual greeting and farewell functions in 6 languages
63+
- 🔠 Text formatting options including capitalization
5564
- 📦 Proper R package structure
5665
- 📄 Comprehensive documentation
5766
- 🧪 Complete test coverage
5867
- 🔄 Continuous Integration workflow
5968

69+
## Supported Languages
70+
71+
- English (default)
72+
- Spanish
73+
- French
74+
- Portuguese
75+
- German
76+
- Italian
77+
78+
## Function Options
79+
80+
Both `hello()` and `goodbye()` support these parameters:
81+
82+
- `name`: Who to greet (default: "world")
83+
- `language`: Language to use (default: "english")
84+
- `exclamation`: Whether to add an exclamation mark (default: TRUE)
85+
- `capitalize`: Whether to capitalize the name (default: FALSE)
86+
6087
## Package Structure
6188

6289
```
@@ -66,16 +93,15 @@ myrpackage/
6693
├── R/ # R source code
6794
│ ├── hello.R # Hello function
6895
│ ├── goodbye.R # Goodbye function
96+
│ ├── utils.R # Utility functions
6997
│ ├── lifecycle.R # Lifecycle definitions
7098
│ └── myrpackage-package.R # Package documentation
7199
├── man/ # Documentation
72100
├── tests/ # Tests
73101
│ └── testthat/ # Unit tests
74102
├── vignettes/ # Long-form documentation
75-
│ └── intro.Rmd # Introduction vignette
76-
├── .Rbuildignore # Build exclusions
77-
├── .github/ # GitHub configuration
78-
│ └── workflows/ # CI/CD workflows
103+
│ ├── intro.Rmd # Introduction vignette
104+
│ └── advanced.Rmd # Advanced usage vignette
79105
├── inst/ # Installed files
80106
│ └── CITATION # Citation information
81107
└── LICENSE # MIT license

_pkgdown.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,14 @@ navbar:
2828
menu:
2929
- text: Getting Started
3030
href: articles/intro.html
31+
- text: Advanced Usage
32+
href: articles/advanced.html
3133
reference:
3234
text: Reference
3335
href: reference/index.html
3436
github:
3537
icon: fab fa-github fa-lg
38+
aria-label: GitHub
3639
href: https://github.com/DiogoRibeiro7/myrpackage
3740
news:
3841
text: News
@@ -48,8 +51,8 @@ reference:
4851
- title: "Package Information"
4952
desc: "Documentation about the package itself"
5053
contents:
51-
- "myrpackage-package" # Use quotes to ensure it's treated as a literal string
52-
- myrpackage-lifecycle
54+
- "myrpackage-package"
55+
- "myrpackage-lifecycle"
5356

5457
home:
5558
sidebar:

codecov.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ coverage:
66
default:
77
target: auto
88
threshold: 1%
9-
informational: true
9+
# Changed from informational to true to make codecov status checks required
10+
informational: false
1011
patch:
1112
default:
1213
target: auto
1314
threshold: 1%
14-
informational: true
15+
# Changed from informational to true to make codecov status checks required
16+
informational: false

inst/CITATION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ version <- meta$Version
55

66
bibentry(
77
bibtype = "Manual",
8-
title = "myrpackage: A Minimal R Package",
8+
title = "myrpackage: Multilingual Greeting and Farewell Functions",
99
author = person(given = "Diogo", family = "Ribeiro",
1010
email = "[email protected]",
1111
role = c("aut", "cre"),
@@ -17,7 +17,7 @@ bibentry(
1717
doi = "", # Add DOI when available
1818
textVersion = paste0(
1919
"Ribeiro, D. (", year, "). ",
20-
"myrpackage: A Minimal R Package. ",
20+
"myrpackage: Multilingual Greeting and Farewell Functions. ",
2121
"R package version ", version, ". ",
2222
"https://github.com/DiogoRibeiro7/myrpackage"
2323
)

tests/testthat/test-goodbye.R

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,15 @@ test_that("goodbye() supports different languages", {
2424
# Test Portuguese
2525
expect_output(goodbye(language = "portuguese"), "Adeus, world!")
2626

27-
# Test unknown language (should default to English)
28-
expect_output(goodbye(language = "german"), "Goodbye, world!")
27+
# Test German
28+
expect_output(goodbye(language = "german"), "Auf Wiedersehen, world!")
29+
30+
# Test Italian
31+
expect_output(goodbye(language = "italian"), "Arrivederci, world!")
32+
33+
# Test unknown language (should default to English with warning)
34+
expect_warning(goodbye(language = "german2"), "Language 'german2' not supported")
35+
expect_output(suppressWarnings(goodbye(language = "german2")), "Goodbye, world!")
2936
})
3037

3138
test_that("goodbye() correctly handles exclamation parameter", {
@@ -36,6 +43,14 @@ test_that("goodbye() correctly handles exclamation parameter", {
3643
expect_output(goodbye(exclamation = FALSE), "Goodbye, world.")
3744
})
3845

46+
test_that("goodbye() correctly handles capitalize parameter", {
47+
# Test with capitalize = FALSE (default)
48+
expect_output(goodbye("world", capitalize = FALSE), "Goodbye, world!")
49+
50+
# Test with capitalize = TRUE
51+
expect_output(goodbye("world", capitalize = TRUE), "Goodbye, World!")
52+
})
53+
3954
test_that("goodbye() validates input parameters", {
4055
# Test invalid name parameter
4156
expect_error(goodbye(name = c("world", "everyone")), "'name' must be a single character string")
@@ -48,12 +63,16 @@ test_that("goodbye() validates input parameters", {
4863
# Test invalid exclamation parameter
4964
expect_error(goodbye(exclamation = c(TRUE, FALSE)), "'exclamation' must be a single logical value")
5065
expect_error(goodbye(exclamation = "yes"), "'exclamation' must be a single logical value")
66+
67+
# Test invalid capitalize parameter
68+
expect_error(goodbye(capitalize = c(TRUE, FALSE)), "'capitalize' must be a single logical value")
69+
expect_error(goodbye(capitalize = "yes"), "'capitalize' must be a single logical value")
5170
})
5271

5372
test_that("goodbye() works with all combinations of parameters", {
5473
# Test with all parameters customized
5574
expect_output(
56-
goodbye(name = "friends", language = "spanish", exclamation = FALSE),
57-
"Adiós, friends."
75+
goodbye(name = "friends", language = "spanish", exclamation = FALSE, capitalize = TRUE),
76+
"Adiós, Friends."
5877
)
5978
})

0 commit comments

Comments
 (0)