Skip to content
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

Add support for documentation comments #624

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

BinderDavid
Copy link

@BinderDavid BinderDavid commented Oct 2, 2024

Part of the solution to #325

@BinderDavid BinderDavid force-pushed the feature/add-doc-comments branch from 9b9f163 to e992c7e Compare October 2, 2024 12:57
@BinderDavid BinderDavid force-pushed the feature/add-doc-comments branch from 61f0067 to 283dc2f Compare October 2, 2024 16:42
@jiribenes jiribenes added feature New feature or request quality-of-life labels Oct 2, 2024
jiribenes added a commit that referenced this pull request Oct 4, 2024
In preparation for @BinderDavid's #624,
I went through the stdlib
and tried to change doc comments to use `///` :)
@jiribenes
Copy link
Contributor

jiribenes commented Feb 18, 2025

@b-studios, I took a look at how to continue, and the biggest problem I could see is that when we'll need two different annotations.
One for Tree -> DocComment in parser, and one for Symbol -> DocComment which gets populated in Namer, and then used in the LSP (on hover -> resolve to symbol -> retrieve the doc comment from symbol).

Is there a better way? We could also store the DocComment on the AST node of a declaration, but I remember you were somewhat opposed to this. Or should we somehow keep only the Tree -> DocComment annotation, and then when hovering, do a "resolve to symbol -> resolve to tree -> retrieve the doc comment from tree"?

WDYT?


object Annotations {
  // ... existing annotations ...

  type DocComments = Vector[String]

  /**
   * Documentation comments for symbols such as functions, types, effects etc.
   * Stores multiple doc comments in order of appearance.
   */
  val Documentation = Annotation[symbols.Symbol, DocComments](
    "Documentation",
    "documentation comments associated with"
  )

@b-studios
Copy link
Collaborator

b-studios commented Feb 18, 2025

Will we only have doc comments on things that are symbols? If yes, then we can always go from tree to symbol and only store Symbol -> DocComment, no?

ah... there is a hole in my reasoning. This will only be possible after Namer...

@b-studios
Copy link
Collaborator

Maybe easiest to store it in the tree, but I have to see how this looks and whether this is too annoying when doing source to source rewritings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request quality-of-life
Projects
Status: Waiting for Review
Development

Successfully merging this pull request may close these issues.

3 participants