Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow more than one given name in Authors@R #672

Merged
merged 5 commits into from Oct 3, 2017
Merged

Allow more than one given name in Authors@R #672

merged 5 commits into from Oct 3, 2017

Conversation

@sgibb
Copy link
Contributor

@sgibb sgibb commented Oct 2, 2017

The Authors@R field in the DESCRIPTION file uses the person class for
managing the authors. If a author has more than one given name
roxygenise failed with an error in package_authors:

Error in vapply(unclass(authors), author_desc, character(1)) :
    values must be length 1,
but FUN(X[[1]]) result is length 2

Example DESCRIPTION:

Authors@R: c(person(given=c("First", "Second"), "Family", role="aut", 
                    email="first.second.family@email.tld"),
             person("Given", "Family", role=c("aut", "cre"), email="given.family@email.tld"))

This commit concatenates all given names separated by a space to solve
this error, e.g. "First Second Family \\email{first.second.family@email.tld}".

For most western cultures that should be fine. Unfortunately
I don't know anything about other naming schemes.

@sgibb sgibb changed the title Allow more than on given name in Authors@R Allow more than one given name in Authors@R Oct 2, 2017
The Authors@R field in the DESCRIPTION file uses the `person` class for
managing the authors. If a author has more than one given name
`roxygenise` failed with an error in `package_authors`:

    Error in vapply(unclass(authors), author_desc, character(1)) :
        values must be length 1,
    but FUN(X[[1]]) result is length 2

This commit concatenates all given names separated by a space to solve
this error. For most western cultures that should be fine. Unfortunately
I don't know anything about other naming schemes.
@hadley
Copy link
Member

@hadley hadley commented Oct 2, 2017

Closely reading the documentation for person() suggests that we should do the same thing for family too. Would you mind adding that code? I'll also give some smaller feedback on the style.

@@ -36,7 +36,7 @@ package_authors <- function(desc) {
}

author_desc <- function(x) {
desc <- x$given
desc <- paste0(x$given, collapse=" ")
Copy link
Member

@hadley hadley Oct 2, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please use spaces around =?

Copy link
Contributor Author

@sgibb sgibb Oct 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

context("Object: Package")

test_that("author with one given name ", {
expect_equal(author_desc(list(given="Given",
Copy link
Member

@hadley hadley Oct 2, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please use the line breaking/identing rules described at http://style.tidyverse.org/syntax.html#long-lines ?

You can use styler to do so automatically.

Copy link
Contributor Author

@sgibb sgibb Oct 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -0,0 +1,34 @@
context("Object: Package")

test_that("author with one given name ", {
Copy link
Member

@hadley hadley Oct 2, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a special case of the next test, so I probably would drop it.

Copy link
Contributor Author

@sgibb sgibb Oct 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

)
})

test_that("Authors@R with more than one given name ", {
Copy link
Member

@hadley hadley Oct 2, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you modify only author_desc(), I wouldn't bother adding tests for other functions.

Copy link
Contributor Author

@sgibb sgibb Oct 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

})

test_that("author with more than one given name ", {
expect_equal(author_desc(list(given=c("First", "Second"),
Copy link
Member

@hadley hadley Oct 2, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you construct with person()? That should make simpler as you won't need to supply all the arguments.

Copy link
Contributor Author

@sgibb sgibb Oct 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@sgibb
Copy link
Contributor Author

@sgibb sgibb commented Oct 3, 2017

@hadley thanks for your review. Sorry for not reading your style guide first. I also added the concatenation for the family names.


test_that("author with more than one given/family name ", {
expect_equal(author_desc(
person(
Copy link
Member

@hadley hadley Oct 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should just be indented by four spaces - otherwise looks great!

Copy link
Contributor Author

@sgibb sgibb Oct 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry. I used styler now.

@hadley
Copy link
Member

@hadley hadley commented Oct 3, 2017

Great! One last thing - can you please add a bullet to news briefly describing change and crediting yourself?

@hadley hadley merged commit 2f7525d into r-lib:master Oct 3, 2017
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants