Operators are not included in the generated documentation if there are multiple operators with the same name #263
Description
It's possible to use an operator name multiple times and create multiple definitions for an operator with the same name. It can be defined up to three times.
- As a prefix operator.
- As an infix operator.
- As a posfix operator.
For example, the given Swift source (where the operators don't make too much sense, there are better ideas for custom operators out there):
infix operator ≠
public func ≠ (lhs: String, rhs: String) -> Bool {
lhs != rhs
}
public func ≠ (lhs: Int, rhs: Int) -> Bool {
lhs != rhs
}
prefix operator ≠
public prefix func ≠ (arg: String) -> Bool { false }
will create the following documentation (after the fixes in #262) which is missing the declaration of the infix operator and all the operator implementations of the infix operator:
This is more or less an artifact how Identifier
works for operators. It does not differentiate between the different kind of operators, therefore an infix operator has the same identifier as a postfix operator as a prefix operator.
I can see multiple ways how we fix this.
1. Make Identifier
have a different Equatable
and Hashable
for operators and create different OperatorPage
s for the different kind of operators. Not sure if I like it.
2. Change a little bit the OperatorPage
. Currently it works with the assumption that an operator name has exactly one definition. We could collect all different operator definitions (prefix, infix, postfix) on the same page and then group the implementations by definition.
Update: My initial assumption was wrong. It's way more trivial. We already create multiple pages for the different kind of operators, but the last operator declaration always wins because it overwrites the page of the previous declaration: