Allow multiline @importFrom, @importClassesFrom, and @importMethodsFrom#1891
Merged
Conversation
…om (r-lib#1890) These tags now accept multi-line input, restoring the ability to spread imports across multiple lines for readability. They were incorrectly included in the single-line-only warning introduced in the tag_words() multiline check.
7d182ac to
d58367d
Compare
@importFrom, @importClassesFrom, and @importMethodsFrom now use single-paragraph multiline semantics: a blank line ends the tag, so content after a forgotten tag (e.g. @examples) is no longer absorbed into the namespace. Adds a "paragraph" mode to the tag parsers' multiline argument (r-lib#1890).
Replace the blank-line ('paragraph') terminator for @importFrom,
@importClassesFrom, and @importMethodsFrom with a hanging-indent rule:
continuation lines must be indented more than the first line, and the
first flush or blank line ends the tag. This also handles the case where
a forgotten tag's content is flush rather than separated by a blank line.
The multiline mode is now named 'indent' (r-lib#1890).
hadley
reviewed
Jun 26, 2026
| #' line is ignored, with a warning. Use this for tags where multiline input | ||
| #' is convenient but a blank line almost always signals a missing tag (e.g., | ||
| #' `@importFrom`). | ||
| #' * `"indent"`: the tag may span multiple lines, but continuation lines must |
Member
There was a problem hiding this comment.
Do you mind applying https://design.tidyverse.org/boolean-strategies.html#how-do-you-remediate-past-mistakes ? (but without the deprecation; just silently handle TRUE/FALSE since this is mostly an internal API)
hadley
reviewed
Jun 26, 2026
hadley
left a comment
Member
There was a problem hiding this comment.
Thanks for continuing to work on this! I'm planning a patch release next week so should be able to get it into the world soon.
hadley
approved these changes
Jun 27, 2026
| ## Individual tags | ||
|
|
||
| * Tags that expect single-line input now warn when they span multiple lines, catching a common class of mistake. Affected tags: `@aliases`, `@concept`, `@encoding`, `@exportClass`, `@exportMethod`, `@exportPattern`, `@exportS3Method`, `@importFrom`, `@importClassesFrom`, `@importMethodsFrom`, `@include`, `@includeRmd`, `@inheritDotParams`, `@inheritParams`, `@inheritSection`, `@keywords`, `@method`, `@name`, `@order`, `@rdname`, `@S3method`, `@template`, and `@useDynLib` (#1642, #1688). This may break some existing usage, but it prevents a wide range of otherwise silent errors. | ||
| * Tags that expect single-line input now warn when they span multiple lines, catching a common class of mistake. Affected tags: `@aliases`, `@concept`, `@encoding`, `@exportClass`, `@exportMethod`, `@exportPattern`, `@exportS3Method`, `@include`, `@includeRmd`, `@inheritDotParams`, `@inheritParams`, `@inheritSection`, `@keywords`, `@method`, `@name`, `@order`, `@rdname`, `@S3method`, `@template`, and `@useDynLib` (#1642, #1688). This may break some existing usage, but it prevents a wide range of otherwise silent errors. |
Member
There was a problem hiding this comment.
This should stay as is; otherwise I think we're good to merge.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Allow
@importFrom,@importClassesFrom, and@importMethodsFromto span multiple lines, restoring the ability to format imports across multiple lines for readability.Problem
These tags were incorrectly included in the single-line-only
warn_if_multiline()check introduced withtag_words(multiline = FALSE)(#1642, #1688). This caused warnings like:for perfectly valid multi-line import declarations:
Fix
Pass
multiline = TRUEtotag_words()for the three import tag parsers, allowing them to accept multi-line input while still enforcing themin = 2word requirement.Changes
R/namespace.R: Addmultiline = TRUEtotag_words()for@importFrom,@importClassesFrom, and@importMethodsFromtests/testthat/test-namespace.R: Replace the multiline warning snapshot test with positive tests for all three tagstests/testthat/_snaps/namespace.md: Remove the old snapshot entryNEWS.md: Remove import tags from single-line list; add new bullet for multiline supportFixes #1890.