Skip to content

Commit

Permalink
Correct getAlias to always get unique aliases
Browse files Browse the repository at this point in the history
... even if there's only one entry point.

Resolves #1845
  • Loading branch information
Gerrit0 committed Apr 10, 2022
1 parent 1357984 commit a429a02
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 28 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Expand Up @@ -18,6 +18,7 @@ These TODOs will be resolved before a full release. ([GitHub project](https://gi

- `@inheritDoc` now follows the behavior specified by TSDoc when copying comments with a reference.
- The `gaSite` option has been removed since Google Analytics now infers the site automatically, updated Google Analytics script to latest version, #1846.
- Comments on export declarations will only overrides comments for references and namespaces, #1901.
- The deprecated `listInvalidSymbolLinks` option has been removed. Use `validation.invalidLink` instead.
- The deprecated `true` and `false` values have been removed from `--emit`, to migrate replace `true` with `"both"` and `false` with `"docs"`.
- Links are no longer be resolved against a global list of all symbols. See [the documentation](https://typedoc.org/guides/link-resolution/) for details on link resolution.
Expand All @@ -28,7 +29,6 @@ These TODOs will be resolved before a full release. ([GitHub project](https://gi
- Listeners to `Converter.EVENT_CREATE_TYPE_PARAMETER` and `Converter.EVENT_CREATE_DECLARATION` will now never be passed a `ts.Node` as their third argument.
- Constant variables which are interpreted as functions will no longer have the `ReflectionFlag.Const` flag set.
- Removed deprecated `removeReaderByName`, `addDeclarations` and `removeDeclarationByName` methods on `Options`.
- Comments on export declarations will only overrides comments for references and namespaces, #1901.

### Features

Expand All @@ -47,6 +47,7 @@ These TODOs will be resolved before a full release. ([GitHub project](https://gi
- Improved comment discovery on destructured exported functions, #1770.
- Links which refer to members within a reference reflection will now correctly resolve to the referenced reflection's member, #1770.
- Correctly detect optional parameters in JavaScript projects using JSDoc, #1804.
- Fixed identical anchor links for reflections with the same name, #1845.
- JS exports defined as `exports.foo = ...` will now be converted as variables rather than properties.

### Thanks!
Expand Down
12 changes: 3 additions & 9 deletions src/lib/models/reflections/abstract.ts
Expand Up @@ -414,18 +414,12 @@ export abstract class Reflection {
alias = "reflection-" + this.id;
}

let target = <Reflection>this;
while (
target.parent &&
!target.parent.isProject() &&
!target.hasOwnDocument
) {
let target = this as Reflection;
while (target.parent && !target.hasOwnDocument) {
target = target.parent;
}

if (!target._aliases) {
target._aliases = new Map();
}
target._aliases ||= new Map();

let suffix = "";
if (!target._aliases.has(alias)) {
Expand Down
19 changes: 1 addition & 18 deletions src/lib/output/themes/default/DefaultTheme.tsx
Expand Up @@ -25,12 +25,6 @@ interface TemplateMapping {
*/
kind: ReflectionKind[];

/**
* Can this mapping have children or should all further reflections be rendered
* to the defined output page?
*/
isLeaf: boolean;

/**
* The name of the directory the output files should be written to.
*/
Expand Down Expand Up @@ -73,43 +67,36 @@ export class DefaultTheme extends Theme {
private mappings: TemplateMapping[] = [
{
kind: [ReflectionKind.Class],
isLeaf: false,
directory: "classes",
template: this.reflectionTemplate,
},
{
kind: [ReflectionKind.Interface],
isLeaf: false,
directory: "interfaces",
template: this.reflectionTemplate,
},
{
kind: [ReflectionKind.Enum],
isLeaf: false,
directory: "enums",
template: this.reflectionTemplate,
},
{
kind: [ReflectionKind.Namespace, ReflectionKind.Module],
isLeaf: false,
directory: "modules",
template: this.reflectionTemplate,
},
{
kind: [ReflectionKind.TypeAlias],
isLeaf: false,
directory: "types",
template: this.reflectionTemplate,
},
{
kind: [ReflectionKind.Function],
isLeaf: false,
directory: "functions",
template: this.reflectionTemplate,
},
{
kind: [ReflectionKind.Variable],
isLeaf: false,
directory: "variables",
template: this.reflectionTemplate,
},
Expand Down Expand Up @@ -225,11 +212,7 @@ export class DefaultTheme extends Theme {
}

for (const child of reflection.children || []) {
if (mapping.isLeaf) {
DefaultTheme.applyAnchorUrl(child, reflection);
} else {
this.buildUrls(child, urls);
}
this.buildUrls(child, urls);
}
} else if (reflection.parent) {
DefaultTheme.applyAnchorUrl(reflection, reflection.parent);
Expand Down

0 comments on commit a429a02

Please sign in to comment.