-
-
Notifications
You must be signed in to change notification settings - Fork 4
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
Add a "default" badge to renamed symbols #15
Comments
I totally agree with this one, but it is a different topic so I extracted it to its own issue. I also think we should add this badge by default to all renamed symbols, not needing users to opt-in with some JSDoc tag. We need to investigate how feasible it is with TypeDoc, and if not feasible at all, the first step would be to create a feature request there. |
This comment was marked as outdated.
This comment was marked as outdated.
TypeDoc renders reflection flags (small static set of options) and modifier tags for the reflection there. Flags are not rendered in the index, however. I'm not aware of any nice way to get them to show up there. It's really not designed to do that. |
You'll probably also want a listener on BOOTSTRAP_END to ensure |
That's very helpful @Gerrit0, we will play with it. Thank you so much! |
This comment was marked as outdated.
This comment was marked as outdated.
https://stackblitz.com/edit/stackblitz-starters-qfzmql?file=index.js jsimport { Application, Converter, Comment, ReflectionFlag } from 'typedoc';
/** @param {Readonly<import('typedoc').Application>} app */
export function load(app) {
app.on(Application.EVENT_BOOTSTRAP_END, () => {
const tags = new Set(app.options.getValue('inlineTags'));
tags.add('@default');
app.options.setValue('inlineTags', [...tags]);
});
/**
* @param {import('typedoc').Context} context
* @param {import('typedoc').DeclarationReflection} reflection
*/
function handleCreateDeclaration(context, reflection) {
if (['default', 'export='].includes(reflection.name) && reflection.parent) {
let name = reflection.parent.getFriendlyFullName();
name = name.split('/').at(-1);
name = name.trim();
name = name.replace(/[_.\- ]+(\w)/g, (m, x) => x.toUpperCase());
reflection.name = name;
reflection.setFlag(ReflectionFlag.DefaultValue, true);
reflection.setFlag(ReflectionFlag.ExportAssignment, true);
console.log(reflection.flags);
reflection.comment ??= new Comment();
reflection.comment.summary.unshift({
kind: 'inline-tag',
tag: '@default',
});
reflection.comment.modifierTags.add('@default');
console.log('reflection.comment', reflection.comment);
for (const r of reflection.getAllSignatures()) {
r.setFlag(ReflectionFlag.DefaultValue, true);
r.setFlag(ReflectionFlag.ExportAssignment, true);
console.log(r.flags);
r.comment ??= new Comment();
r.comment.summary.unshift({ kind: 'inline-tag', tag: '@default' });
r.comment.modifierTags.add('@default');
console.log('r.comment', r.comment);
}
}
}
app.converter.on(Converter.EVENT_CREATE_DECLARATION, handleCreateDeclaration);
} what did it was this: reflection.setFlag(ReflectionFlag.DefaultValue, true);
reflection.setFlag(ReflectionFlag.ExportAssignment, true); |
this seems to work too and you can insert any text you want into it: reflection.flags.push('goobledegook'); https://stackblitz.com/edit/stackblitz-starters-23xcer?file=index.js |
another trick i figured out is that you can override the ☝ ill admit, even just that with the still weird jsimport { Converter, ReflectionKind } from 'typedoc';
/** @param {Readonly<import('typedoc').Application>} app */
export function load(app) {
/**
* @param {import('typedoc').Context} context
* @param {import('typedoc').DeclarationReflection} reflection
*/
function handleCreateDeclaration(context, reflection) {
if (['default', 'export='].includes(reflection.name) && reflection.parent) {
reflection.kind = ReflectionKind.Property;
}
}
app.converter.on(Converter.EVENT_CREATE_DECLARATION, handleCreateDeclaration);
} |
This comment was marked as off-topic.
This comment was marked as off-topic.
It looks amazing! |
BTW my preferred option is to keep the current behavior of this plugin but add the "Default" badge to the renamed properties. |
ideally it'd be nice to have something like this where the (default) is there and informing you that, yes, this is the default export and not a named export BUT also being out of the way enough to not clutter it? idk the technical feasibility of this tho
you can sorta do this now with the
@exports default
or some other@summary THIS IS THE DEFAULT EXPORT
in your jsdoc comment but it's not quite the same lolOriginally posted by @jcbhmr in #14 (comment)
The text was updated successfully, but these errors were encountered: