-
Notifications
You must be signed in to change notification settings - Fork 413
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
Use inherited docs when local ones are missing #190
Comments
Any progress on this? It's been over a year. |
No progress on this to report, the task is up for the taking. Why not take this opportunity to contribute to a feature you need, @petrmanek? |
Any progress on this? @petrmanek @jpsim |
@istx25 None at all. I'd be happy to contribute, but I'm not a ruby guy... |
Neither am I! A guy or experienced with Ruby. hahahah. 😉 I too am basically/completely new to Ruby and I got started as of two days ago. Use this as an opportunity to learn and write Ruby. There are plenty of people that will be able to provide feedback and help you in the progress. |
Never let not being experienced with something stop you. 💕 Heck, we could implement the feature together. |
No Ruby experience necessary. This feature could be written entirely in Swift, since it falls squarely in the purview of SourceKitten. |
the purr view of SourceKitten. 😆 |
But sounds good to me. Even better. I have Swift experience so I'm even more comfortable implementing this at some point if no one else grabs it. |
Definitely! This is basically expected if you come over from the Java world. |
Thought: /// Makes objects of type `T`
protocol Maker {
associatedtype T
/// Makes a `T`
static func make(from: String) -> T
}
class Foo: Maker {
typealias T = Int
static func make(from: String) -> Int {
return Int(from)
}
} When inheriting the documentation from the protocol, should |
Any progress on this? We just ran into this... |
Related: If |
Interestingly enough, Xcode automatically adds the comments when displaying the "interface" of a source file (by using the side by side view):
Maybe this can be used somehow? |
At some point I noticed Xcode had started doing a better job of this, but until now I never stopped to investigate exactly what it does. At this point (Xcode 9.4), Quick Help does this perfectly. Protocol conformance methods fall back to the protocol definitions, and subclass overrides fall back to their parent methods. Subclassed methods even get a note about how far up the inheritance chain the documentation came from. I think I would prefer if these were exempt from the coverage percentage and warnings, because from now on I actually want them blank so that they can inherit. As for the rendered documentation, the simplest would be to consider them implicit and not list them in the documentation. How many entries for |
@SDGGiesbrecht I disagree with hiding them, since then someone reading the documentation cannot be sure they are implemented. But this should definitely be a configurable option. @jpsim Regarding the implementation, not sure what the best way to go about this is. One could be to open an issue with Swift itself. Another option would be to first generate the interface file for everything and then run documentation on that. The third option would be to use the method described in the linked issue to a) extract the protocol / superclass info and lookup documentation for that. Though this is more of a sourcekitten issue. |
I don’t understand. If the source even compiled, then the methods must be available. If a type conforms to I can also see the use of having a complete list of everything the type can do, including all inherited capabilities. I realize a client may just want to know what a type can do, not sort through an unfamiliar conformance tree. I would definitely vouch for that style too, especially with an “Expand Conformances” button so the reader can toggle at will. The difficulty is that it would require a lot more that just displaying inherited documentation for whatever overrides are found. Take |
Hi @galli-leo, it would be great if you're interested in working on this. The way I think we should do this is to make use of the inherited docs that Jazzy already has (from SourceKit request.cursorinfo) -- these are in the The jazzy code needed is to process this XML into HTML -- not a huge task but more than a few minutes. Can offer some more pointers if you are interested! This would work out of the box on Linux as well. |
The documentation may have been written in terms of associated types and/or type parameters which are mode concrete by the implementing type. It might be useful to repeat both signature and documentation with the concrete types. That said, having a separate section for inherited methods linking to their implementation/documentation might be prudent. Another idea is a link to where the implementation comes from. |
I meant more in reference to custom protocols, where a user might not have a quick way to check if a certain protocol is supported. Additionally, the point of documentation is not to have the compiler run something to find out if a method exists. I do think for simple protocols (e.g. Equatable) it makes sense to hide them.
My idea would be to have a section inside the declaration, that can be opened up to reveal all classes or protocols a function is inherited from, with their respective doc comment and a link to them. Very basic hacked together example: @johnfairh My idea would unfortunately not work when using the key.doc.full_as_xml, as that won't give us a reference to what type a function was inherited from. Additionally, I would like to implement linking std entries (e.g. String reference or CustomStringConvertible as seen above) as well.
Yeah I think that's the best option, especially since you can inherit a function from multiple classes and or protocol. (e.g. overriding a method in a subclass that also is required by a protocol). In such cases it makes sense (imo) to have an overview of both the superclass and protocol documentation. |
Well, |
@johnfairh Ah thanks for the pointers, maybe my issue with SourceKitten isn't even needed in that case. Though I guess the only way to get the correct documentation location for stdlib, would still be the custom xcode requests? (I don't think they are in the SourceKitten issue (jpsim/SourceKitten#525), but there is a request that get's you the location of the docset and the location of a stdlib (or iOS framework) symbol inside the docset) |
Oh exciting! Be nice if we could use that output to construct a portable link to the online docs (see veeeeery old issue #13) - but either way these APIs are definitely worth investigating. |
@johnfairh Unfortunately that command was removed in Xcode 9.3, that's why I want to go this route (The output of the aforementioned request looks quite similar though, so I guess they just moved it to SourceKit). Will try to get a sample of that request today or tomorrow. |
So I must have misremembered, but unfortunately, the request I had in mind, does not give us any information regarding the documentation location. However, after some digging and reverse engineering the Framework Xcode uses for Documentation, I found the following file: Xcode.app/Contents/SharedFrameworks/DNTDocumentationSupport.framework/Versions/A/Resources/external/map.db`. This has a list of the links to all the external documentations, like this:
I already found out that the first to letters have some meaning (first letter is either h, t or c and the second letter is s for swift, c for objective c and j for javascript). Maybe the other part is a hash of somesorts? If you have any idea what it might be or how Xcode is exactly reading from this db with a symbol, please let me know. |
I have been very happy to see the ball rolling on this again, and I think all of the discussed possibilities are an improvement from the status quo, so I say this somewhat regrettably... It is no longer clear to me whether we are still talking about re‐using inherited content, or just providing a link to it published elsewhere. Unfortunately it occurred to me today that if we are actually using the content, then we run into copyright and licensing issues [exasperated sigh]. Just because Xcode has access to a Even the documentation of the Standard Library asserts copyright and declares “All rights reserved.” (In this case though—since whatever can be parsed from the raw source is under the same licence as the source itself—a complete re‐use of Standard Library documentation comments would be fine within the terms of its Apache licence.) But other modules, such as AppKit, have almost no source available for use under any licence. Forwarding a Quick Help note inherited from AppKit into documentation generated by Jazzy would be a violation of international copyright law—especially if the result were then published online. That fact throws annoying complications into what we are considering here: A. Links to external things are fine. A and B are safe to do by default. C would probably have to be opt‐in on a per‐module basis, since there is no way Jazzy can tell which modules belong to C and which belong to D. |
@SDGGiesbrecht
All in all, just make it an extra option with a small legal disclaimer and jazzy doesn‘t have any issue. Something like „Enabling this option could potentially open yourselfs to lawsuits. While quoting external documentation should fall under fair use, companies could still try to sue.“ I strongly think that this feature would never cause any copyright issues, unless you somehow only have inherited docs and don‘t change any of them. Still you could then argue that the specific arrangement and styling of the „quotes“ is fair use. P.S.
That‘s for the whole developer page, isn‘t it? Also it‘s a standard thing to put at the bottom of any page, doesn‘t mean anything. Copyright is granted to everything, you don‘t have to explicitly declare it. |
That’s good enough if its the best that can be done. But it would still be nice to turn it on and off for individual modules if it is not too hard to implement that way.
The Doctrine of Fair Use only carries legal weight in the United States. (Though some countries do have roughly comparable rules—but not all.) Jazzy may be published from the US, but its users are everywhere, and it is the user doing the copying.
The right to quote is the second principle of the Berne Convention, signed by the entire industrialized world. The problem is that it is subject to a “reasonable limit” (interpreted differently by different countries). If someone publishes a module with a
Xcode only displays what it is given (either source or a
I highly doubt that as well. But in some countries it is the state, not the copyright holder, who is responsible to bring charges. (The Agreement on Trade-Related Aspects of Intellectual Property Rights even requires all states to do so for infringement on larger scales, but Jazzy’s output would never reach that scale.) There are also third‐party modules to consider, not just Apple’s. Even then I agree it is unlikely, but it comes down to a moral question: “Is it okay to speed just because there are no police around?” (You have a right to remain silent. :P)
Jazzy’s users are not limited to open source projects.
Jazzy (i.e. Realm) would never be the one liable (or else such a country’s laws need fixing). It would be the user who is liable.
Something like that, yes. But maybe less frightening: “Be aware that this will copy documentation from dependencies. Make sure you have the rights to do so.” Again, it would be nice to toggle for specific modules. |
Just thought I'd pop in and say I'd love this feature, similar to how modern PHP has it with phpdoc. The docs in PHP look like this:
I'd love to see this with swiftdoc and Jazzy supporting it:
or similar... |
Manually triggered inheritance like this can be done with Workspace before running Jazzy, at least when the parent source code is available. This issue thread is more about making the whole process completely automatic like it is in Xcode. |
Hello, why is this issue tagged as "priority-low"? This is a major feature. |
Any news on this? |
Plus one on this one. Any best practice people are applying to overcome this limitation while not implemented ? |
For example, Alamofire documents declarations in its protocols, but not the implementations of the types inheriting from those protocols.
See URLStringConvertible as an example.
The text was updated successfully, but these errors were encountered: