-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Include code snippets in sources Jars #19
Comments
Hm, I kind of share the sentiment. @jtulach, you got an idea? @pniederw, the relevant project is codesnippet4javadoc, pull requests are probably welcome. |
I agree. Its also my favorite way of browse external libraries and code in general. While I understand the advantages of codesnippets its lack of IDE support kills it. |
To be fair, after attaching Javadoc Jars to the IDE project (which at least Gradle doesn't do by default), documentation popup/window does reveal the sample code (in IntelliJ). But it's not the same experience as having it in the source code. I do understand the need to manage code snippets externally, and it has a clear benefit for users (code is more likely to be correct). Personally I prefer to use Asciidoclet for this, but it suffers from the same problem. There are two technical solutions I can think of:
|
I was hoping attaching Javadoc will solve the most critical problem. |
In the current situation for me the disadvantages outweigh the advantages. I'd rather live with the redundancy of having the test case defined in a TestClass as well. |
I don't have a strong opinion about the tradeoff here, but I disagree with the choice of keywords "BEGIN" and "END". They appears completely mysterious to the uninformed (human) reader, and we've seen examples in recent code reviews. Keywords that are more self-explanatory would help. |
@mlvdv +1 |
I don't understand what is wrong on sentences like "begin of sample xyz" and "end of sample xyz", but you are of course allowed to propose alternatives. Contribute to development of the codesnippets plugin by forking https://github.com/jtulach/codesnippet4javadoc ... |
In order to proceed with this inquiry, we need a representative project to demonstrate the issues on. I suggest to use simplelanguage with truffle@0.11 as that is the project users of Truffle API are supposed to start with and (unlike internal projects) it uses Java de-facto standard build system. After opening it in my IDE and downloading Javadoc for its libraries (one click on node representing project dependencies) I can confirm the code snippet is properly included and displayed when reading documentation in IDE's code completion: |
@jtulach My comment about keywords "BEGIN" and "END" comes from finding the declarations of those snippets (in code), not in their use (in JavaDoc). A reader who doesn't know about this mechanism will have no clue about how to figure out why they are there. |
@chrisseaton inspired me in #40 to investigate what it would take to embed the code snippets directly in the API itself. If we do what Chris did and use |
Here is Truffle code base rewritten to use the new embedded style. As far as I can tell the navigation is now OK. For majority of the cases the "go to definition" jumps to proper place. For the more complex cases (TruffleLanguage referencing PolyglotEngine) "Go to type" dialog works in my IDE. |
Pull request for mx created: graalvm/mx#65 |
#95 is merged. Closing. Enjoy navigable snippets! |
…truffle:pr/update-format-to-eclipse-45 to master The Travis gate already uses already the new formatter and fails because of that. The new formatter changes comment formatting slightly, as well as whitespace handling in some corner cases. This patch is the result of running mx gate with ECLIPSE_EXE pointing to an Eclipse 4.5.2 Signed-off-by: Stefan Marr git@stefan-marr.de * commit '3ae44b7d5fb30c7c7b7bd3668f335b982292a2b5': Use 4.5.2 instead of 4.5.1. Update hocon file to use 4.5.1 as Eclipse version. Update Truffle formatter to Eclipse 4.5.2
A very common way to read Javadoc is through the sources (Jars) attached to the IDE project. (It's much more convenient to search/browse sources in an IDE than Javadoc on a web page, and seeing both documentation and source code at the same time is very useful.) However, seeing Javadoc such as
Usage example: {@codesnippet BranchProfileSample}
isn't helpful - instead I'd like to see the code snippet itself. Therefore, please embed code snippets in sources before creating sources Jars. (And please make sure line numbers in class files remain intact.)The text was updated successfully, but these errors were encountered: