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

[SR-3693] Can't document function's closure parameter #46278

Open
krzyzanowskim opened this issue Jan 22, 2017 · 4 comments
Open

[SR-3693] Can't document function's closure parameter #46278

krzyzanowskim opened this issue Jan 22, 2017 · 4 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. documentation

Comments

@krzyzanowskim
Copy link
Contributor

Previous ID SR-3693
Radar rdar://problem/24961176
Original Reporter @krzyzanowskim
Type Bug

Attachment: Download

Environment

Xcode 8.2.1

Additional Detail from JIRA
Votes 1
Component/s Source Tooling
Labels Bug, Documentation
Assignee None
Priority Medium

md5: c0251d8272e90715239f2a066762fe64

Issue Description:

For the given function declaration, two issues (see attached screenshot):

    /// synopis
    ///
    /// - Parameters:
    ///   - string: sssss
    ///   - output: ooooo
    func update(str string: String, output: (_ string: String) -> Void)

1. "string" not "str" is documented
2. second "string" show up, but there is no way to add description for it

I'm not even sure where to report this.

@belkadan
Copy link
Contributor

cc @bitjammer

@bitjammer
Copy link
Member

I actually already implemented this in c20f3db, you simply nest parameter documentation underneath the closure parameter's documentation but it's not yet consumed in Xcode, which is probably why you are seeing 'string' documentation twice. We have a radar internally documenting the need for Xcode to display it - I'll add a note there.

Here are three examples of nesting below:

{{/// Partially applies a binary operator.
///
/// - Parameter a: The left-hand side to partially apply.
/// - Parameter combine: A binary operator.
/// - Parameter lhs: The left-hand side of the operator
/// - Parameter rhs: The right-hand side of the operator
/// - Returns: A result.
/// - Throws: Nothing.

/// Partially applies a binary operator.
///
/// - Parameters:
/// - a: The left-hand side to partially apply.
/// - combine: A binary operator.
/// - Parameter lhs: The left-hand side of the operator
/// - Parameter rhs: The right-hand side of the operator
/// - Returns: A result.
/// - Throws: Nothing.

/// Partially applies a binary operator.
///
/// - Parameters:
/// - a: The left-hand side to partially apply.
/// - combine: A binary operator.
/// - Parameters:
/// - lhs: The left-hand side of the operator
/// - rhs: The right-hand side of the operator
/// - Returns: A result.
/// - Throws: Nothing.}}

I've requested a release note for when this gets fixed, so keep an eye out. I'll ping those responsible, but I'm not sure when it will be complete. Also, one thing to note is that QuickHelp may not render your documentation if you add this, because the schema for the data that the compiler sends to Xcode for QuickHelp may not match up, sorry about that. It's on my radar.

@swift-ci
Copy link
Collaborator

Comment by Martijn Walraven (JIRA)

Before I open a separate issue, I'm wondering if this nested syntax would also fix some other issues I'm seeing. This is while using the 'flat' parameter list format currently supported in Xcode:

  • Parameters in optional closures do not seem to be documented

  • Parameters for a closure type specified through a type alias do not seem to be documented

@swift-ci
Copy link
Collaborator

swift-ci commented Feb 1, 2017

Comment by Martijn Walraven (JIRA)

To clarify, this is an example of a method I'm trying to document. I verified this isn't working in Xcode 8.3 beta 1 either. I tried both using the 'flat' parameter list format and nested parameters.

@bitjammer: Not sure if this is part of the existing issue, but it might be helpful to remind the Xcode team of the need to support optional closures and closures specified through a type alias as well.

/// Fetches a query from the server or from the local cache, depending on the current contents of the cache and the specified cache policy.
  ///
  /// - Parameters:
  ///   - query: The query to fetch.
  ///   - cachePolicy: A cache policy that specifies under what circumstances results should be fetched from the server or from the local cache.
  ///   - queue: A dispatch queue on which the result handler will be called. Defaults to the main queue.
  ///   - resultHandler: An optional closure that is called when query results are available or when an error occurs.
  ///   - result: The result of the fetched query, or `nil` if an error occurred.
  ///   - error: An error that indicates why the fetch failed, or `nil` if the fetch was succesful.
  /// - Returns: An object that can be used to cancel an in progress fetch.
  @discardableResult public func fetch<Query: GraphQLQuery>(query: Query, cachePolicy: CachePolicy = .returnCacheDataElseFetch, queue: DispatchQueue = DispatchQueue.main, resultHandler: OperationResultHandler<Query>? = nil) -> Cancellable {
    [...]
  }

public typealias OperationResultHandler<Operation: GraphQLOperation> = (_ result: GraphQLResult<Operation.Data>?, _ error: Error?) -> Void

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. documentation
Projects
None yet
Development

No branches or pull requests

4 participants