Skip to content

fix: render constructors as new ClassName(params) format#11

Open
davanesh wants to merge 5 commits intowebpack:mainfrom
davanesh:fix/constructor-rendering
Open

fix: render constructors as new ClassName(params) format#11
davanesh wants to merge 5 commits intowebpack:mainfrom
davanesh:fix/constructor-rendering

Conversation

@davanesh
Copy link

Closes #2

What this does

Overrides the constructor partial to render constructors in the Node.js doc format instead of the default TypeDoc output.

Before:

Constructors

Constructor

  • options {ContainerPluginOptions}

After:

new ContainerPlugin(options)

  • options {ContainerPluginOptions}

Changes

  • Override constructor partial to format as new ClassName(params)
  • Optional params are wrapped in square brackets: new Stats([options])
  • Removed ### Constructors / Methods / Properties group headings
  • Removed *** horizontal rule separators between members
  • Override memberContainer to correctly pass heading levels down the chain

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Mar 12, 2026

CLA Signed

The committers listed above are authorized under a signed CLA.

@avivkeller
Copy link
Member

avivkeller commented Mar 12, 2026

@davanesh Can you rebase?

@davanesh davanesh force-pushed the fix/constructor-rendering branch from 6c923d3 to e72176d Compare March 12, 2026 20:46
@davanesh
Copy link
Author

Done! Rebased and force pushed.

Copy link
Member

@avivkeller avivkeller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a few changes that I think will be nice, but this is some great great work and I can't wait to see more!

Comment on lines +144 to +145
//DEBUG
// console.log("KIND:", model.kind, "NAME:", model.name, "CONSTRUCTOR KIND:", ReflectionKind.Constructor);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove this debug comment

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed 👍

Comment on lines +154 to +160
declarationTitle: (model) => {
return this.helpers.typedListItem({
name: model.name,
type: model.type,
comment: model.comment,
});
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
declarationTitle: (model) => {
return this.helpers.typedListItem({
name: model.name,
type: model.type,
comment: model.comment,
});
},
declarationTitle: this.helpers.typedListItem,

Comment on lines +161 to +175
memberContainer: (model, options) => {
const md = [];
if (!this.router.hasOwnDocument(model) &&
![ReflectionKind.Constructor].includes(model.kind)) {
md.push(
"#".repeat(options.headingLevel) + " " +
this.partials.memberTitle(model)
);
}
md.push(this.partials.member(model, {
headingLevel: options.headingLevel + 1, // ← methods get ####
nested: options.nested,
}));
return md.filter(Boolean).join("\n\n");
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think overriding the constructor in memberTitle is better than outright skipping it? WDYT?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh that's a much cleaner approach! On it 🔥

@avivkeller avivkeller force-pushed the fix/constructor-rendering branch from e72176d to 2f0b9c9 Compare March 12, 2026 21:37
@avivkeller
Copy link
Member

avivkeller commented Mar 12, 2026

(Rebased for CI/CD). Note that you'll need to run npm run lint:fix && npm run format + npm run generate-docs.

@davanesh davanesh force-pushed the fix/constructor-rendering branch from 2f0b9c9 to e2b9d89 Compare March 13, 2026 08:32
Copy link
Member

@alexander-akait alexander-akait left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@avivkeller We currently only support @deprecated, if we want to add them we need to add them to our schema generator, @experimental is not a problem, @beta and @legacy - not sure we need it, because @deprecated already handle such things

Copy link
Member

@avivkeller avivkeller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Can you revert the block quote changes, and other unrelated changes

  2. Let's add a re-usable helper for signature creation

@davanesh
Copy link
Author

On it!

@davanesh
Copy link
Author

Done, reverted blockquote changes and moved constructor logic into a buildConstructorTitle helper 😊

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

Successfully merging this pull request may close these issues.

Constructors

3 participants