milesj / docusaurus-plugin-typedoc-api

Docusaurus plugin that provides source code API documentation powered by TypeDoc.
71 stars 26 forks source link

Object literals and destructured parameters not rendering in docusaurus #147

Closed rash805115 closed 3 months ago

rash805115 commented 3 months ago

The @param supports Object Literals and Destructed Parameters as detailed here. But neither of them are supported by this plugin I think. I do not see them being rendered as expected.

I tried this example,

/**
 * @param options - documentation for the whole parameter
 * @param options.value - documentation for the `value` property
 * @param options.nested.value - NOT supported
 */
export function configure(options: { value: string; nested: { value: string } } | undefined) {}

and in the expected output, I only saw this plugin rendering the options param description.

Here is what I see.

Screenshot 2024-07-29 at 12 31 11 AM

But I expected individual rendering for options.value as well. I understand options.nested.value is not supported, which makes sense.

PS: While I have the opportunity, a sincere thank you for making this plugin. This has saved me a ton of time.

milesj commented 3 months ago

Yeah this isn't supported. I don't really maintain this much anymore, so it's not going to land unless someone contributes it.

rash805115 commented 3 months ago

No worries, I understand. I am trying to take a stab at it, but failing miserably since I don't know react all that much. This is what I have so far. If you can guide me, that would really increase my chances of making a PR.

I think the change needs to happen in MemberSignatureBody.tsx

<ul className="tsd-parameters">
    {sig.parameters?.map((param) => (
        <Fragment key={param.id}>
            <li >
                <h5>
                    <Flags flags={param.flags} />
                    {param.flags?.isRest && <span className="tsd-signature-symbol">...</span>}
                    {`${param.name}: `}
                    <Type type={param.type} />
                    <DefaultValue
                        comment={param.comment}
                        type={param.type}
                        value={param.defaultValue}
                    />
                </h5>

                <Comment comment={param.comment} />
            </li>

            // After param is rendered, I want to add more children if the type is "union".
            {(param.type as any).types.find((param2) => param2.type === 'reflection').declaration.children.map((param2) => (
                <Fragment key={param2.id}>
                    <li >
                        <Flags flags={param2.flags} />
                        {param2.flags?.isRest && <span className="tsd-signature-symbol">...</span>}
                        {`${param2.name}: `}
                        <Type type={param2.type} />
                        <Comment comment={param2.comment} />
                    </li>
                </Fragment>
            ))}
        </Fragment>
    ))}
</ul>

which does render the values, but not sure how to make this more generic.

Screenshot 2024-07-29 at 11 24 00 AM

Also need to understand what to do with nested. Since TypeDoc itself doesn't support it, just need to omit it out?

milesj commented 3 months ago

Lookin good. Should probably be a nested list so that it aligns correctly.

rash805115 commented 3 months ago

Thanks! Here is the PR https://github.com/milesj/docusaurus-plugin-typedoc-api/pull/148 to fix this issue. Let me know when/how can we release this.

Looks like this now,

Screenshot 2024-07-29 at 9 17 11 PM
rash805115 commented 3 months ago

Closing this, as the PR got merged. Thanks again.