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

Object literals and destructured parameters not rendering in docusaurus #147

Closed
rash805115 opened this issue Jul 29, 2024 · 5 comments
Closed

Comments

@rash805115
Copy link
Contributor

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
Copy link
Owner

milesj commented Jul 29, 2024

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
Copy link
Contributor Author

rash805115 commented Jul 29, 2024

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
Copy link
Owner

milesj commented Jul 29, 2024

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

rash805115 added a commit to rash805115/docusaurus-plugin-typedoc-api that referenced this issue Jul 30, 2024
@rash805115
Copy link
Contributor Author

rash805115 commented Jul 30, 2024

Thanks! Here is the PR #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

milesj pushed a commit that referenced this issue Aug 4, 2024
@rash805115
Copy link
Contributor Author

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

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

No branches or pull requests

2 participants