-
Notifications
You must be signed in to change notification settings - Fork 710
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
Default exports should retain their name #1521
Comments
I am fairly strongly against this - docs should reflect what is actually exported, not what names are used locally to refer to the exports. However, most people who run into the issue of to many symbols named If this still isn't good enough, you could do the name change with a plugin. |
@Gerrit0 What if it's the reverse? Similar to the screenshot below: |
I guess I'd be okay with this... would rather have it be a plugin, but there isn't a good way of doing that right now. It should be possible (and fairly easy) to do with a plugin in 0.22, since that's being planned with extensibility built into the themes.
Only if you consider a generating documentation that accurately reflects your code to be a bug! 0.19 and earlier included an incredible amount of hackiness in order to get results that produced decent docs... 0.20's approach is far superior once you understand how it works. I think your question in #1526 should help with that. |
So, there is no way to work around it for now, and the best option is to wait for TypeDoc 0.22 and then create a plugin for that? |
You could create a plugin today - it just won't integrate as cleanly into the architecture. This will rename default exports using their local name, if available, but it doesn't provide any indication that the value was a default export. // TypeDoc 0.20.x, CC0
const { Converter } = require("typedoc")
exports.load = function({ application }) {
application.converter.on(Converter.EVENT_CREATE_DECLARATION, (_context, reflection, node) => {
if (!node || !node.name || reflection.name !== "default") return;
reflection.name = node.name.getText();
});
}; |
@Gerrit0 thank you SO MUCH. It's a plugin now: https://github.com/felipecrs/typedoc-plugin-rename-defaults |
I found this thread debugging another issue that the plugin doesn't appear to solve. Consider two classes: // menu.ts
import { event, EventEmitter } from './decorators';
export default class Menu {
@event() select: EventEmitter<MenuItem>
}
// menu-item.ts
export default class MenuItem {
// ...
} The Update: I stand corrected...the |
@Gerrit0 - I don't know the specifics, but the fact that this requires a plugin seems unusual. Instead of a plugin that has to be maintained by someone in the community, wouldn't it be better to add an optional parameter to "fix" this? Ideally it would have the class / interface name like one would expect, but perhaps also display a visible flag / badge / whatever in the documentation that denotes it is technically "default" under the hood. |
You're seeing a bunch of |
BTW, |
Can you explain that, please? If I enter only one file as an entry point, TypeDoc ignores the rest (does not follow imports) and generates documentation only with README. ExampleI have some entry
If I run If i run What am I doing wrong? Why it doesn't follow imports? |
TypeDoc follows exports, because that's what's visible to your users. Imports are an implementation detail. From the outside, there's no difference between these: import { actuallyDoIt } from "./helpers"
export function doThings(a, b) {
return actuallyDoIt(a, b)
}
// ---------
import { actuallyDoIt as someRandomThingToAvoidConflicts } from "./helpers"
export function doThings(a, b) {
return someRandomThingToAvoidConflicts(a, b)
} |
How can I use the plugin in a config file? I'm using docusaurus-plugin-typedoc |
{
"plugin": ["./path/to/plugin.js"]
} Note: paths in config files are relative to the config file |
@felipecrs Thank YOU so much for taking the initiative. |
Against |
@Gerrit0 Good afternoon I agree with you that there is no point in describing variables that are not exported But what about the interfaces that are exported and inside which there are parameters from the same directory and they are not exported but are used inside the exported interface How will a person who opens the documentation understand what exactly needs to be put in the required parameter? Example: export interface User {
detail: Detail
}
interface Detail {
name: string;
age: number
} |
To avoid having a log of "default" references. Visit below links to know more, * https://github.com/felipecrs/typedoc-plugin-rename-defaults#readme * TypeStrong/typedoc#1521
Search Terms
default exports
Problem
Currently, the name of default exports will be removed and renamed to
default
, which could cause confusion like the screenshot below.The
default
ofpayload is default
is NOT the default export of this module.Suggested Solution
If the default export is named (like
function named() {...}
,class Named {...}
,const named = ...
, etc.), TypeDoc should retain its name and add adefault
badge to indicate it's a default export. Any types that referencing it should use the original name as well, and notdefault
.The text was updated successfully, but these errors were encountered: