Skip to content

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

c42f added a commit to JuliaLang/julia that referenced this pull request Oct 17, 2025
…#511)

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