Skip to content

Commit

Permalink
fix: Fix broken link in packages index.
Browse files Browse the repository at this point in the history
  • Loading branch information
tgreyuk committed Apr 19, 2024
1 parent 96a9850 commit 58adf37
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 59 deletions.
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/docusaurus-plugin-typedoc/README.md
Expand Up @@ -2,7 +2,7 @@

![npm](https://img.shields.io/npm/v/docusaurus-plugin-typedoc%2Fnext?&logo=npm) [![Build Status](https://github.com/tgreyuk/typedoc-plugin-markdown/actions/workflows/ci.yml/badge.svg?branch=next)](https://github.com/tgreyuk/typedoc-plugin-markdown/actions/workflows/ci.yml)

A Docusaurus plugin to integrate TypeDoc into a Docusaurus project.
A Docusaurus plugin to integrate TypeDoc ( + typedoc-plugin-markdown ) into a Docusaurus project.

## Installation

Expand Down
@@ -1,5 +1,5 @@
import { heading, link, table } from '@plugin/libs/markdown';
import { escapeChars } from '@plugin/libs/utils';
import { escapeChars, getFileNameWithExtension } from '@plugin/libs/utils';
import { MarkdownThemeContext } from '@plugin/theme';
import * as path from 'path';
import { ProjectReflection } from 'typedoc';
Expand All @@ -19,6 +19,13 @@ export function packagesIndex(
Boolean(projectPackage.packageVersion),
);

const fileExtension = this.options.getValue('fileExtension');

const entryFileName = getFileNameWithExtension(
this.options.getValue('entryFileName'),
fileExtension,
);

if (this.options.getValue('indexFormat') === 'table') {
const headers = [this.getText('label.name')];
if (includeVersion) {
Expand All @@ -30,9 +37,7 @@ export function packagesIndex(
const packageMeta = this.getPackageMetaData(projectPackage.name);

const urlTo = Boolean(projectPackage.readme)
? `${path.dirname(projectPackage.url || '')}/${this.options.getValue(
'entryFileName',
)}`
? `${path.dirname(projectPackage.url || '')}/${entryFileName}`
: projectPackage.url;

const rows = [
Expand All @@ -51,9 +56,7 @@ export function packagesIndex(
} else {
const packagesList = model.children?.map((projectPackage) => {
const urlTo = Boolean(projectPackage.readme)
? `${path.dirname(projectPackage.url || '')}/${this.options.getValue(
'entryFileName',
)}`
? `${path.dirname(projectPackage.url || '')}/${entryFileName}`
: projectPackage.url;
return urlTo
? `- ${link(
Expand Down
3 changes: 1 addition & 2 deletions packages/typedoc-plugin-markdown/test/fixtures/config.ts
Expand Up @@ -144,14 +144,13 @@ const config: Record<string, Fixture> = {
plugin: [path.join(__dirname, 'custom-plugins', 'navigation-plugin.mjs')],
entryPointStrategy: 'packages',
name: 'packages-example',
entryFileName: 'index.md',
disableSources: true,
navigation: {
includeGroups: true,
},
},
options: [
{},
{ entryFileName: 'index.md' },
{
excludeScopesInPaths: true,
mergeReadme: true,
Expand Down
Expand Up @@ -220,7 +220,7 @@ exports[`Navigation should get Navigation Json for packages: (Output File Strate
]
}
],
"path": "package-1/index.md"
"path": "package-1/README.md"
},
{
"title": "package-1b",
Expand All @@ -237,7 +237,7 @@ exports[`Navigation should get Navigation Json for packages: (Output File Strate
]
}
],
"path": "package-1b/index.md"
"path": "package-1b/README.md"
},
{
"title": "package-2",
Expand All @@ -246,7 +246,7 @@ exports[`Navigation should get Navigation Json for packages: (Output File Strate
{
"title": "module-1",
"kind": 2,
"path": "package-2/module-1/index.md",
"path": "package-2/module-1/README.md",
"children": [
{
"title": "Interfaces",
Expand All @@ -263,7 +263,7 @@ exports[`Navigation should get Navigation Json for packages: (Output File Strate
{
"title": "module-2",
"kind": 2,
"path": "package-2/module-2/index.md",
"path": "package-2/module-2/README.md",
"children": [
{
"title": "Interfaces",
Expand All @@ -278,7 +278,7 @@ exports[`Navigation should get Navigation Json for packages: (Output File Strate
]
}
],
"path": "package-2/index.md"
"path": "package-2/README.md"
},
{
"title": "@scope/package-3",
Expand All @@ -287,7 +287,7 @@ exports[`Navigation should get Navigation Json for packages: (Output File Strate
{
"title": "index",
"kind": 2,
"path": "package-3/index/index.md",
"path": "package-3/index/README.md",
"children": [
{
"title": "Interfaces",
Expand All @@ -304,7 +304,7 @@ exports[`Navigation should get Navigation Json for packages: (Output File Strate
{
"title": "module-1",
"kind": 2,
"path": "package-3/module-1/index.md",
"path": "package-3/module-1/README.md",
"children": [
{
"title": "Interfaces",
Expand All @@ -321,7 +321,7 @@ exports[`Navigation should get Navigation Json for packages: (Output File Strate
{
"title": "module-2",
"kind": 2,
"path": "package-3/module-2/index.md",
"path": "package-3/module-2/README.md",
"children": [
{
"title": "Interfaces",
Expand All @@ -336,7 +336,7 @@ exports[`Navigation should get Navigation Json for packages: (Output File Strate
]
}
],
"path": "package-3/index.md"
"path": "package-3/README.md"
},
{
"title": "package-4",
Expand All @@ -353,7 +353,7 @@ exports[`Navigation should get Navigation Json for packages: (Output File Strate
]
}
],
"path": "package-4/index.md"
"path": "package-4/README.md"
},
{
"title": "package-5",
Expand All @@ -362,7 +362,7 @@ exports[`Navigation should get Navigation Json for packages: (Output File Strate
{
"title": "module2",
"kind": 2,
"path": "package-5/module2/index.md",
"path": "package-5/module2/README.md",
"children": [
{
"title": "Interfaces",
Expand All @@ -386,7 +386,7 @@ exports[`Navigation should get Navigation Json for packages: (Output File Strate
{
"title": "module2",
"kind": 2,
"path": "package-6/module2/index.md",
"path": "package-6/module2/README.md",
"children": [
{
"title": "Interfaces",
Expand Down Expand Up @@ -551,13 +551,13 @@ exports[`Navigation should get Navigation Json for packages: (Output File Strate
"title": "@scope/package-1",
"kind": 2,
"children": [],
"path": "package-1/index.md"
"path": "package-1/README.md"
},
{
"title": "package-1b",
"kind": 2,
"children": [],
"path": "package-1b/index.md"
"path": "package-1b/README.md"
},
{
"title": "package-2",
Expand All @@ -574,7 +574,7 @@ exports[`Navigation should get Navigation Json for packages: (Output File Strate
"path": "package-2/module-2.md"
}
],
"path": "package-2/index.md"
"path": "package-2/README.md"
},
{
"title": "@scope/package-3",
Expand All @@ -583,7 +583,7 @@ exports[`Navigation should get Navigation Json for packages: (Output File Strate
{
"title": "index",
"kind": 2,
"path": "package-3/module_index.md",
"path": "package-3/index.md",
"children": [
{
"title": "Interfaces",
Expand Down Expand Up @@ -632,7 +632,7 @@ exports[`Navigation should get Navigation Json for packages: (Output File Strate
]
}
],
"path": "package-3/index.md"
"path": "package-3/README.md"
},
{
"title": "package-4",
Expand All @@ -649,7 +649,7 @@ exports[`Navigation should get Navigation Json for packages: (Output File Strate
]
}
],
"path": "package-4/index.md"
"path": "package-4/README.md"
},
{
"title": "package-5",
Expand Down
Expand Up @@ -115,7 +115,7 @@ exports[`Packages should compile member page for packages: (Output File Strategy
***
[packages-example v0.0](../../index.md) / [@scope/package-1](../index.md) / PackageInterface
[packages-example v0.0](../../README.md) / [@scope/package-1](../README.md) / PackageInterface
# Interface: PackageInterface
Expand Down Expand Up @@ -176,11 +176,11 @@ Some text.
| Name | Version | Description |
| :------ | :------ | :------ |
| [@scope/package-1](package-1/index.md) | 1.0.0 | Description for package-1 |
| [package-1b](package-1b/index.md) | - | - |
| [package-2](package-2/index.md) | 1.0.0 | - |
| [@scope/package-3](package-3/index.md) | - | Description for package 3 |
| [package-4](package-4/index.md) | - | - |
| [@scope/package-1](package-1/README.md) | 1.0.0 | Description for package-1 |
| [package-1b](package-1b/README.md) | - | - |
| [package-2](package-2/README.md) | 1.0.0 | - |
| [@scope/package-3](package-3/README.md) | - | Description for package 3 |
| [package-4](package-4/README.md) | - | - |
| [package-5](package-5/package-5.md) | - | - |
| [package-6](package-6.md) | - | - |
"
Expand Down
Expand Up @@ -362,31 +362,31 @@ exports[`Urls should gets Urls for packages entry points: outputFileStrategy: me

exports[`Urls should gets Urls for packages entry points: outputFileStrategy: members 2`] = `
[
"index.md",
"package-1/index.md",
"README.md",
"package-1/README.md",
"package-1/interfaces/PackageInterface.md",
"package-1b/index.md",
"package-1b/README.md",
"package-1b/interfaces/PackageInterface.md",
"package-2/index.md",
"package-2/module-1/index.md",
"package-2/README.md",
"package-2/module-1/README.md",
"package-2/module-1/interfaces/PackageInterface1.md",
"package-2/module-2/index.md",
"package-2/module-2/README.md",
"package-2/module-2/interfaces/PackageInterface2.md",
"package-3/index/index.md",
"package-3/README.md",
"package-3/index/README.md",
"package-3/index/interfaces/PackageInterfaceForIndexModule.md",
"package-3/index.md",
"package-3/module-1/index.md",
"package-3/module-1/README.md",
"package-3/module-1/interfaces/PackageInterface1.md",
"package-3/module-2/index.md",
"package-3/module-2/README.md",
"package-3/module-2/interfaces/PackageInterface2.md",
"package-4/index.md",
"package-4/README.md",
"package-4/interfaces/PackageInterface.md",
"package-5/module1/interfaces/PackageInterface1.md",
"package-5/module2/index.md",
"package-5/module2/README.md",
"package-5/module2/interfaces/PackageInterface2.md",
"package-5/package-5.md",
"package-6/module1/interfaces/PackageInterface1.md",
"package-6/module2/index.md",
"package-6/module2/README.md",
"package-6/module2/interfaces/PackageInterface2.md",
"package-6.md",
]
Expand Down Expand Up @@ -421,20 +421,20 @@ exports[`Urls should gets Urls for packages entry points: outputFileStrategy: mo

exports[`Urls should gets Urls for packages entry points: outputFileStrategy: modules 2`] = `
[
"index.md",
"package-1/index.md",
"package-1b/index.md",
"package-2/index.md",
"README.md",
"package-1/README.md",
"package-1b/README.md",
"package-2/README.md",
"package-2/module-1.md",
"package-2/module-2.md",
"package-3/README.md",
"package-3/index.md",
"package-3/interfaces/PackageInterface1.md",
"package-3/interfaces/PackageInterface2.md",
"package-3/interfaces/PackageInterfaceForIndexModule.md",
"package-3/module-1.md",
"package-3/module-2.md",
"package-3/module_index.md",
"package-4/index.md",
"package-4/README.md",
"package-4/interfaces/PackageInterface.md",
"package-5/module2.md",
"package-5/package-5.md",
Expand Down
Expand Up @@ -2,7 +2,7 @@ import { expectFileToEqual } from '@devtools/testing';

describe(`Packages`, () => {
test(`should compile readmes for a packages`, () => {
expectFileToEqual('packages', 'members', 'index.md');
expectFileToEqual('packages', 'members', ['index.md', 'README.md']);
expectFileToEqual('packages', 'members', '@scope/package-1/index.md', 1);
});

Expand Down

0 comments on commit 58adf37

Please sign in to comment.