I'll also mention that DocC to some extent tries to encourage documentation for API that follows many of the recommendations in Swift API design guidelines.
In addition to making a distinction between parameter names and argument labels:
βββββββββββββββββ¬ββββββββββ parameter names
βββ΄ββ ββ΄β
func move(from start: Point, to end: Point)
βββ¬β ββ¬
β°ββββββββββββββββββ΄βββββββββββββ argument labels
There's a specific recommendation about naming parameters:
Choose parameter names to serve documentation. Even though parameter names do not appear at a function or methodβs point of use, they play an important explanatory role.
Choose these names to make documentation easy to read. For example, these names make documentation read naturally:
+ /// Return an `Array` containing the elements of `self`
+ /// that satisfy `predicate`.
+ func filter(_ predicate: (Element) -> Bool) -> [Generator.Element]
+
+ /// Replace the given `subRange` of elements with `newElements`.
+ mutating func replaceRange(_ subRange: Range, with newElements: [E])
These, however, make the documentation awkward and ungrammatical:
- /// Return an `Array` containing the elements of `self`
- /// that satisfy `includedInResult`.
- func filter(_ includedInResult: (Element) -> Bool) -> [Generator.Element]
-
- /// Replace the range of elements indicated by `r` with
- /// the contents of `with`.
- mutating func replaceRange(_ r: Range, with: [E])
There is also a recommendation about about omitting words that repeat type information:
Omit needless words. Every word in a name should convey salient information at the use site.
More words may be needed to clarify intent or disambiguate meaning, but those that are redundant with information the reader already possesses should be omitted. In particular, omit words that merely repeat type information.
+ public mutating func removeElement(_ member: Element) -> Element?
+
+ allViews.removeElement(cancelButton)
In this case, the word Element adds nothing salient at the call site. This API would be better:
- public mutating func remove(_ member: Element) -> Element?
-
- allViews.remove(cancelButton) // clearer
My interpretation of these two recommendations togetherβwhen applied to this specific updateStatus exampleβis that:
- because the parameter type is
Product it's redundant to mention "product" in the argument label, meaning that the argument label becomes "for"
- to make the signature and documentation read naturally; a good name for the
Product parameter would be "product" so that the signature and documentation can read as "update status for product".
To some extent, DocC's warnings about parameters is assuming that the API follows these recommendations, and that's what the warnings are trying to steer you towards.
If you and your team prefer different naming conventions and these DocC warnings are getting in your way, you can disable them by passing the --disable-parameters-and-returns-validation flag to DocC.