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

Parse docstrings within structs as K"doc" #511

Merged
merged 1 commit into from
Oct 6, 2024
Merged

Conversation

c42f
Copy link
Member

@c42f c42f commented Oct 5, 2024

Julia's ecosystem (including Base.Docs and flisp lowering) assumes that strings within struct definitions are per-field docstrings, but the flisp parser doesn't handle these - they are only recognized when the struct itself has a docstring and are processed by the @doc macro recursing into the struct's internals. For example, the following doesn't result in any docs attached to A.

struct A
    "x_docs"
    x

    "y_docs"
    y
end

This change adds K"doc" node parsing to the insides of a struct, making the semantics clearer in the parser tree and making it possible to address this problems in the future within JuliaLowering.

Also ensure that the Expr form is unaffected by this change.

Julia's ecosystem (including Base.Docs and flisp lowering) assumes that
strings within `struct` definitions are per-field docstrings, but the
flisp parser doesn't handle these - they are only recognized when the
struct itself has a docstring and are processed by the `@doc` macro
recursing into the struct's internals. For example, the following
doesn't result in any docs attached to `A`.

```julia
struct A
    "x_docs"
    x

    "y_docs"
    y
end
```

This change adds `K"doc"` node parsing to the insides of a struct,
making the semantics clearer in the parser tree and making it possible
to address this problems in the future within JuliaLowering.

Also ensure that the `Expr` form is unaffected by this change.
@c42f c42f merged commit 98c202a into main Oct 6, 2024
36 checks passed
@c42f c42f deleted the caf/docstrings-in-structs branch October 6, 2024 00:49
@c42f
Copy link
Member Author

c42f commented Oct 6, 2024

I think this should be pretty safe and reasonable (comments welcome though)

It's technically breaking for SyntaxNode but I still haven't released 1.0 soo 😅 ahh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant