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

Improve detection of inherited documentation comments for parameter and return validation #1130

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

d-ronnqvist
Copy link
Contributor

@d-ronnqvist d-ronnqvist commented Dec 19, 2024

Bug/issue #, if applicable: rdar://134534169

Summary

This uses the same logic that DocC uses elsewhere to detect if a documentation comment is inherited from the current module to avoid validating parameters and return values for inherited documentation comments. Theses warnings won't be actionable since their location isn't from this module's code.

Dependencies

None.

Testing

Build documentation for Outer.docc.zip and pass --enable-inherited-docs.
There shouldn't be any parameter or return value warnings emitted.

If you want to recreate Outer.symbols.json;

  • Define two modules; an inner and an outer where the outer depend on the inner.

  • In the inner module, define a protocol with a func that has parameter and return value warnings:

// in Inner

public protocol SomeProtocol {
    /// A documentation comment with warnings
    /// - Parameter notFound: This parameter does not exist.
    /// - Returns: This function doesn't return anything.
    func someMethod()
}
  • In the outer module, conform to that protocol and don't override the documentation comment:
import Inner

public struct SomeStruct: Inner.SomeProtocol {
    // don't override doc comment
    public func someMethod() {}
}

Checklist

Make sure you check off the following items. If they cannot be completed, provide a reason.

  • Added tests
  • Ran the ./bin/test script and it succeeded
  • Updated documentation if necessary Not applicable.

@d-ronnqvist d-ronnqvist requested a review from anferbui December 19, 2024 17:27
@d-ronnqvist
Copy link
Contributor Author

@swift-ci please test

@d-ronnqvist d-ronnqvist force-pushed the no-param-warnings-for-inherited-docs branch from e8f4c0f to d09bc3e Compare December 19, 2024 17:58
@d-ronnqvist
Copy link
Contributor Author

@swift-ci please test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant