Ambient icon indicating copy to clipboard operation
Ambient copied to clipboard

Add component `Description` automatically from rust comment

Open FredrikNoren opened this issue 2 years ago • 4 comments

Right now we have to do this to both get the description in the API docs and on the component:

components!("app", {
    // My fancy test component
    @[Description["My fancy test component"]]
    testy: String,
});

It would be nice if doing just // comment would automatically add a Description to the component.

FredrikNoren avatar Mar 02 '23 11:03 FredrikNoren

The // comment is not possible as // comments are stripped before macro invocations.

Capturing doc-comments have to be done in the form of meta-attributes, e.g #[doc = "comment"]

Through some matching trickery it is likely possible

ten3roberts avatar Mar 02 '23 13:03 ten3roberts

@ten3roberts Oh sorry, I mean ///. Is that also not possible?

FredrikNoren avatar Mar 02 '23 14:03 FredrikNoren

/// is possible, I think. It may be simpler to generate the doc comment from the macro than to parse the doc comment in the macro.

philpax avatar Mar 02 '23 16:03 philpax

I may have been a bit unclear.

Capturing doc-comments /// comment is definitely possible, although a little tricky.

What I meant i that they need to be matched in the #[doc = "comment"] style as they desugar into that before the macros are evaluated. The /// comment syntax is only sugar.

In fact, we already capture doc attributes, but only forward them to the declared component function

ten3roberts avatar Mar 03 '23 09:03 ten3roberts

All API components now come from ambient.toml (instead of being outputted to ambient.toml), so this is no longer necessary.

philpax avatar May 04 '23 13:05 philpax