Skip to content

Commit ad39cce

Browse files
committed
Theming: URL generation of imported declarations
Point the URLs of imported declarations to their original exported declaration.
1 parent 01f040c commit ad39cce

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

src/lib/output/themes/DefaultTheme.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -382,11 +382,15 @@ export class DefaultTheme extends Theme {
382382
* @returns The altered urls array.
383383
*/
384384
static buildUrls(reflection: DeclarationReflection, urls: UrlMapping[]): UrlMapping[] {
385-
const mapping = DefaultTheme.getMapping(reflection);
385+
let urlReflection = reflection;
386+
while (urlReflection.importedFrom) {
387+
urlReflection = urlReflection.importedFrom;
388+
}
389+
const mapping = DefaultTheme.getMapping(urlReflection);
386390
if (mapping) {
387391
if (!reflection.url || !DefaultTheme.URL_PREFIX.test(reflection.url)) {
388-
const url = [mapping.directory, DefaultTheme.getUrl(reflection) + '.html'].join('/');
389-
urls.push(new UrlMapping(url, reflection, mapping.template));
392+
const url = [mapping.directory, DefaultTheme.getUrl(urlReflection) + '.html'].join('/');
393+
urls.push(new UrlMapping(url, urlReflection, mapping.template));
390394

391395
reflection.url = url;
392396
reflection.hasOwnDocument = true;
@@ -395,13 +399,13 @@ export class DefaultTheme extends Theme {
395399
for (let key in reflection.children) {
396400
const child = reflection.children[key];
397401
if (mapping.isLeaf) {
398-
DefaultTheme.applyAnchorUrl(child, reflection);
402+
DefaultTheme.applyAnchorUrl(child, urlReflection);
399403
} else {
400404
DefaultTheme.buildUrls(child, urls);
401405
}
402406
}
403407
} else {
404-
DefaultTheme.applyAnchorUrl(reflection, reflection.parent);
408+
DefaultTheme.applyAnchorUrl(reflection, urlReflection.parent);
405409
}
406410

407411
return urls;
@@ -415,14 +419,18 @@ export class DefaultTheme extends Theme {
415419
*/
416420
static applyAnchorUrl(reflection: Reflection, container: Reflection) {
417421
if (!reflection.url || !DefaultTheme.URL_PREFIX.test(reflection.url)) {
418-
let anchor = DefaultTheme.getUrl(reflection, container, '.');
419-
if (reflection['isStatic']) {
422+
let urlReflection = reflection;
423+
while (urlReflection instanceof DeclarationReflection && urlReflection.importedFrom) {
424+
urlReflection = urlReflection.importedFrom;
425+
}
426+
let anchor = DefaultTheme.getUrl(urlReflection, container, '.');
427+
if (urlReflection['isStatic']) {
420428
anchor = 'static-' + anchor;
421429
}
422430

423431
reflection.url = container.url + '#' + anchor;
424432
reflection.anchor = anchor;
425-
reflection.hasOwnDocument = false;
433+
reflection.hasOwnDocument = reflection !== urlReflection;
426434
}
427435

428436
reflection.traverse((child) => {

0 commit comments

Comments
 (0)