Giter VIP home page Giter VIP logo

Comments (14)

smarr avatar smarr commented on July 21, 2024

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.

chumer avatar chumer commented on July 21, 2024

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.

pniederw avatar pniederw commented on July 21, 2024

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:

  1. Embed snippets in source code before compiling (perhaps only for published builds).
  2. Improve IDEs to display Javadoc (e.g. taken from attached Javadoc Jar) in-place.

from graal.

jtulach avatar jtulach commented on July 21, 2024

I was hoping attaching Javadoc will solve the most critical problem.

from graal.

chumer avatar chumer commented on July 21, 2024

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.

mlvdv avatar mlvdv commented on July 21, 2024

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.

woess avatar woess commented on July 21, 2024

@mlvdv +1

from graal.

jtulach avatar jtulach commented on July 21, 2024

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.

jtulach avatar jtulach commented on July 21, 2024

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:
codesnippet-in-the-ide
We should verify the same behavior is achievable in the other two supported IDEs when working with the simplelanguage project.

from graal.

mlvdv avatar mlvdv commented on July 21, 2024

@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.

jtulach avatar jtulach commented on July 21, 2024

@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.

jtulach avatar jtulach commented on July 21, 2024

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.

jtulach avatar jtulach commented on July 21, 2024

Pull request for mx created: graalvm/mx#65

from graal.

jtulach avatar jtulach commented on July 21, 2024

#95 is merged. Closing. Enjoy navigable snippets!

from graal.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.