Comments (14)
Hm, I kind of share the sentiment.
Not sure about the technical solution though. Seems problematic.
@jtulach, you got an idea?
Generally, I like that the code examples are checked by the compiler. With the changes we have this is absolutely necessary.
@pniederw, the relevant project is codesnippet4javadoc, pull requests are probably welcome.
from graal.
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.
from graal.
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:
- Embed snippets in source code before compiling (perhaps only for published builds).
- Improve IDEs to display Javadoc (e.g. taken from attached Javadoc Jar) in-place.
from graal.
I was hoping attaching Javadoc will solve the most critical problem.
from graal.
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.
from graal.
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.
from graal.
@mlvdv +1
from graal.
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 ...
from graal.
In order to proceed with this inquiry, we need a representative project to demonstrate the issues on. I suggest to use simplelanguage with [email protected] 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:
We should verify the same behavior is achievable in the other two supported IDEs when working with the simplelanguage project.
from graal.
@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.
from graal.
@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 @link
instead of @codesnippet
we'll get the same Javadoc and our IDEs will properly navigate from the Javadoc to the actual code snippet. Implemented as jtulach/codesnippet4javadoc@515fdd1
from graal.
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.
from graal.
Pull request for mx created: graalvm/mx#65
from graal.
#95 is merged. Closing. Enjoy navigable snippets!
from graal.
Related Issues (20)
- Problem java.lang.NoClassDefFoundError: sun/misc/Unsafe
- [GR-52454] Native Image shutdown hooks don't run upon SIGINT HOT 2
- [GR-52453] [jfr] jdk.ContainerConfiguration doesn't set hostTotalMemory correctly
- [GR-52484] [jfr] jdk.PhysicalMemory event doesn't set 'usedSize' HOT 3
- Is there any problem with graalvm checking illegal strings? HOT 2
- [GR-52483] Native Image call graph imprecision HOT 7
- [GR-52515] META-INF/native-image/... files are ignored in some JARs (large, zip64, self-extracting) HOT 6
- Main entry point class 'HelloWorld.java' neither found on... on M2 HOT 5
- [GR-52475] Error with native image for ktfmt - Resource not found: /org/jetbrains/kotlin/cli/jvm/compiler/KotlinCoreEnvironment$Companion.class HOT 1
- Is there anything missing when graalvm-11uses JVM parameters to run java code? HOT 3
- GraalVM crashes with "fatal error: Initial size of CodeCache is too small" HOT 2
- [GR-52473] Serialization of arrays is not supported in Native Image HOT 4
- Classes not getting initialized HOT 1
- Build a spring boot3 project with hibernate-search and lucene backend, throw a 'undefined reference' error HOT 1
- [GR-52560] Size regression from GraalVM CE 23.0 to GraalVM for JDK 21 (CE) for `byte[] for code metadata` HOT 2
- JSON Metadata Versioning, Backwards Compatibility, and Evolution
- [GR-52553] Defining new classes at runtime is not supported HOT 2
- [GR-52591] Warning: Error processing trace entry map(size=5, {(tracer,reflect),(function,getSystemResource),(caller_class,org.apache.logging.log4j.core.util.Loader),(result,true),(args,[null])}): java.lang.NullPointerException HOT 7
- Caused by: java.lang.IllegalArgumentException: Method "list" could not be invoked HOT 14
- [GR-52611] Add the ability to add comments to JSON configuration file entries HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from graal.