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

Fix docs mismatch #21

Merged
merged 1 commit into from
Mar 31, 2018
Merged

Fix docs mismatch #21

merged 1 commit into from
Mar 31, 2018

Conversation

jakeheis
Copy link
Contributor

This fixes the issue where Beak incorrectly matches up doc comments with functions when global variables are declared above the functions. A basic example of this issue can be seen with a Beak file such as:

public let str = String(repeating: " ", count: 4)

/// This is the first func
public func firstFunc() {

}

/// This is the second func
public func secondFunc() {

}

Beak incorrectly matches docs with functions as such:

 > beak list
Functions:

  firstFunc: This is the second func
  secondFunc:

My implementation of the fix, while I believe it is the most clean and simple, is not necessarily the most performant (given the index(where:) call inside the for loop). I thought it best to leave it simple for now, but I'm happy to optimize if you think it's necessary

@yonaskolb
Copy link
Owner

Good catch, nice one! I don't think the performance hits will hurt us in any significant way.

It would be great if SourceKitten was able to return Structure and Docs together, that way we wouldn't have to merge them. I'll open an issue there

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.

2 participants