-
Notifications
You must be signed in to change notification settings - Fork 98
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is off to a great start!
What are you thinking as far as how to distinguish among prefix
/ infix
/ postfix
operators in the generated UI?
I'm lacking the imagination how the visuals for this could look like. One idea: We could use the type names display the operators with their type names. E.g. we would display an infix operator However, this omits the return type of the operation, but the return type might be rather important for custom DSLs with custom operators. Regarding the implementation then: My current approach simply changed the Also, it's rather easy to distinguish between prefix, infix and postfix operators. The first and the latter always need to have a modifier in the method implementation. But should we add this kind of logic into swift-doc or should we extend SwiftSemantics? |
Thanks again for taking a stab at this, @Lukas-Stuehrk. After digging into this a bit more, I realized that I'd originally conflated operators with functions that implement an operator. This became a lot clearer when I tried running To clarify, this is an operator: infix operator ≈ : ComparisonPrecedence ...and this is a function implementing that operator: public func ≈ <T>(lhs: T, rhs: T) -> Bool where T : FloatingPoint {
return lhs == rhs || lhs.nextDown == rhs || lhs.nextUp == rhs
} I think your change is the correct — functions that implement an operator should be grouped in type pages. My latest changes build on this by doing the following:
I also updated the CSS to add a custom style for operators. Here's what all of that looks like: Operator page: Home page: |
123d040
to
26dd273
Compare
With this change, operators are separated from methods. Additionally, they are displayed with only their operator.
In the sidebar of the HTML page:

And in the documentation:

This resolves #123.