-
Notifications
You must be signed in to change notification settings - Fork 414
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
Autolink declarations #490
Conversation
@@ -448,6 +458,7 @@ def self.autolink(docs, root_decls) | |||
doc.abstract = autolink_text(doc.abstract, doc, root_decls) | |||
doc.return = autolink_text(doc.return, doc, root_decls) if doc.return | |||
doc.children = autolink(doc.children, root_decls) | |||
doc.declaration &&= autolink_text(doc.declaration, doc, root_decls, true) |
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.
Ok perhaps this could be rewritten to be consisent with the above doc.return = autolink(..) if doc.return
style?
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.
If I refactor this to doc.declaration = .. if doc.declaration
the line gets too long and rubocop complains :( Should I refactor anyway and disable the rubocop warning?
Woohoo! This is nice. Could you please address @segiddins's style feedback, push the changes to the integration specs (you should have commit access now 🎉) and then we'll be able to take a look at the specs diff and look at the changes in a web browser. Thanks! |
@esad now that I've made a few fixes to jazzy and generally brought it back to good health (or at least I hope), could you please revive this so we can include it in the next release? |
@jpsim Almost there. Rubocop is complaining about a few things, so I wanted to ask for advice how to best deal with it:
Not sure if I can split the Regarding the line length offence for |
…uped and ungrouped docs. Necessary for autolink to be able to correctly find enums.
This is a great start @esad! There are a few behaviors that I think should be addressed before getting this in: First, disabling auto-linking to the same page you're already on: This is a screenshot taken from building the integration specs with this branch, and includes links from Alamofire's Second, disabling links to types not defined in the module: This is another screenshot taken from building the integration specs with this branch, and includes links from Alamofire's Those are the only two issues I can identify with this for now. Another modification we could consider is preserving the syntax color of the type from rouge, distinguishing between hyperlinks and non-links some other way, like underlines... I'm not too picky if we do this or not. |
As for the rubocop violations, do whatever you prefer there. |
Version 0.6.1
…enames and style/rubocop fixes.
You can find it at CHANGELOG.md.
Generated by 🚫 danger |
I've addressed the two things you mentioned above, updated the integration specs and tweaked rubocop rules a bit. Travis is failing because of missing CHANGELOG entry, I was think that you may want to craft that one? The fact that we don't autolink on the same page anymore will also affect previous autolinking logic, where this was not respected, so for example in the abstract for https://realm.io/docs/objc/latest/api/Classes/RLMRealm.html#/c:objc(cs)RLMRealm(cm)defaultRealm, the I've also updated the logic not to perform autolinking to extensions (such as I had some issues with integration specs for MiscJazzyFeatures having extra As for Rubocop, I've tried to disable as little checks as possible and comply with the style, but I had to disable complexity checks for the autolinking method, however I think it's still quite readable. I've also globally disabled a recently introduced style check for multiline block chaining that IMHO makes no sense (see rubocop/rubocop#2338), which was also causing some old code in I've also updated the code to autolink declarations from the the "other language declaration", introduced in v0.6.1. |
…uped and ungrouped docs. Necessary for autolink to be able to correctly find enums.
Hey @esad, there were conflicts since merging #569 so I worked to resolve those and rebuild the integration specs to better review this. I did this in the jazzy@jp-autolink-decls and specs@jp-autolink-decls branches. The main issue I can find with this are that some declarations now link to themselves: |
…s equal, to prevent linking to the same page in certain cases.
@jpsim I've merged your changes and extended the check to prevent autolinking to the same page in the cases like the one you mentioned above. Can you have another look? |
I'll review this again today @esad. I have to thank you for your patience, I know it's been tedious to keep this updated 😬 |
CI is only failing due to lack of a CHANGELOG entry |
@jpsim I thought that's what the intended behavior per your comment in #490 (comment) was - can you clarify in more detail what do you think the behavior should be when it comes to linking to the same page? Link everything except to itself and to the toplevel declaration of the current page ( |
Sorry for not being clear, yes I agree with your description of the intended behavior:
|
…autolinking to different declarations on the same page
@jpsim Updated. Could you have one more look? |
Looks good, I've continued this in #588 |
@jpsim Thanks for taking over with the latest merge, looks good. |
This solves #483 - autolinking return and argument types in the method declarations in both Swift and Objective-C.
I've reused the same autolinking logic already used for text, with an additional flag that instead of running it inside
<code>
, runs it inside rogue (syntax highlighting) emitted<span>
tags of special classes.The diff for the integration specs will be quite huge as this affects lots of generated html - so it would be a good idea if you someone can take a look at what this does to their own docs - the output for both Realm ObjC and Swift looks good (and has nice links in the return and argument types!)