Skip to content

Commit ab7eab6

Browse files
committed
Require input globs to have posix path sep
Resolves #2825 Hopefully this works on Windows without too many more changes...
1 parent 772133e commit ab7eab6

35 files changed

+607
-408
lines changed

.config/mocha.fast.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55
"spec": ["src/test/**/*.test.ts", "src/test/**/*.test.tsx"],
66
"timeout": 5000,
77
"watch-files": ["src/**/*.ts", "src/**/*.tsx"],
8-
"node-option": ["import=tsx"]
8+
"node-option": ["import=tsx", "conditions=typedoc-ts"]
99
}

.config/mocha.full.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
"timeout": 0,
44
"spec": ["src/test/**/*.test.ts", "src/test/**/*.test.tsx"],
55
"exclude": ["src/test/packages/**"],
6-
"node-option": ["import=tsx"]
6+
"node-option": ["import=tsx", "conditions=typedoc-ts"]
77
}

.config/mocha.test-explorer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"extension": ["ts"],
44
"ignore": ["src/test/slow/**", "src/test/packages/**"],
55
"package": "./package.json",
6-
"node-option": ["import=tsx"],
6+
"node-option": ["import=tsx", "conditions=typedoc-ts"],
77
"slow": 500,
88
"spec": ["src/**/*.test.ts", "src/**/*.test.tsx"],
99
"timeout": 0,

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"editor.tabSize": 4
3434
},
3535

36-
"mochaExplorer.nodeArgv": ["--import=tsx"],
36+
"mochaExplorer.nodeArgv": ["--import=tsx", "--conditions=typedoc-ts"],
3737

3838
"eslint.workingDirectories": [".", "./example"],
3939
"mochaExplorer.configFile": ".config/mocha.test-explorer.json",

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ title: Changelog
44

55
## Beta
66

7+
- TypeDoc now expects all input globs paths to be specified with `/` path separators, #2825.
78
- Added a `--router` option which can be used to modify TypeDoc's output folder
89
structure. This can be extended with plugins, #2111.
910
- TypeDoc will now only create references for symbols re-exported from modules.
11+
- API: `Path` and `PathArray` parameter types now always contain normalized paths.
1012
- API: Introduced a `Router` which is used for URL creation. `Reflection.url`,
1113
`Reflection.anchor`, and `Reflection.hasOwnDocument` have been removed.
1214
- Removed `jp` translations from `lang`, to migrate switch to `ja`.

package.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,13 @@
105105
]
106106
},
107107
"imports": {
108-
"#utils": "./dist/lib/utils-common/index.js"
108+
"#utils": {
109+
"typedoc-ts": "./src/lib/utils-common/index.ts",
110+
"default": "./dist/lib/utils-common/index.js"
111+
},
112+
"#node-utils": {
113+
"typedoc-ts": "./src/lib/utils/index.ts",
114+
"default": "./dist/lib/utils/index.js"
115+
}
109116
}
110117
}

src/lib/application.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {
1919

2020
import { Option, Options } from "./utils/index.js";
2121
import type { TypeDocOptions } from "./utils/options/declaration.js";
22-
import { unique } from "#utils";
22+
import { type GlobString, unique } from "#utils";
2323
import { ok } from "assert";
2424
import {
2525
type DocumentationEntryPoint,
@@ -35,8 +35,7 @@ import { validateExports } from "./validation/exports.js";
3535
import { validateDocumentation } from "./validation/documentation.js";
3636
import { validateLinks } from "./validation/links.js";
3737
import { ApplicationEvents } from "./application-events.js";
38-
import { findTsConfigFile } from "./utils/tsconfig.js";
39-
import { deriveRootDir, glob, readFile } from "./utils/fs.js";
38+
import { deriveRootDir, findTsConfigFile, glob, readFile } from "#node-utils";
4039
import { addInferredDeclarationMapPaths } from "./models/reflections/ReflectionSymbolId.js";
4140
import { Internationalization, type TranslatedString } from "./internationalization/internationalization.js";
4241
import { FileRegistry, ValidatingFileRegistry } from "./models/FileRegistry.js";
@@ -162,7 +161,7 @@ export class Application extends AbstractComponent<
162161

163162
/** @internal */
164163
@Option("entryPoints")
165-
accessor entryPoints!: string[];
164+
accessor entryPoints!: GlobString[];
166165

167166
/**
168167
* The version number of TypeDoc.

src/lib/converter/converter.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,8 @@ import { getDocumentEntryPoints, MinimalSourceFile, Option, readFile } from "../
2222
import { convertType } from "./types.js";
2323
import { ConverterEvents } from "./converter-events.js";
2424
import { convertSymbol } from "./symbols.js";
25-
import { createMinimatch, matchesAny, nicePath } from "../utils/paths.js";
26-
import type { Minimatch } from "minimatch";
27-
import { hasAllFlags, hasAnyFlag, unique } from "#utils";
25+
import { MinimatchSet, nicePath } from "../utils/paths.js";
26+
import { type GlobString, hasAllFlags, hasAnyFlag, unique } from "#utils";
2827
import type { DocumentationEntryPoint } from "../utils/entry-point.js";
2928
import type { CommentParserConfig } from "./comments/index.js";
3029
import type { CommentStyle, ValidationOptions } from "../utils/options/declaration.js";
@@ -88,9 +87,9 @@ export interface ConverterEvents {
8887
export class Converter extends AbstractComponent<Application, ConverterEvents> {
8988
/** @internal */
9089
@Option("externalPattern")
91-
accessor externalPattern!: string[];
92-
private externalPatternCache?: Minimatch[];
93-
private excludeCache?: Minimatch[];
90+
accessor externalPattern!: GlobString[];
91+
private externalPatternCache?: MinimatchSet;
92+
private excludeCache?: MinimatchSet;
9493

9594
/** @internal */
9695
@Option("excludeExternals")
@@ -588,17 +587,17 @@ export class Converter extends AbstractComponent<Application, ConverterEvents> {
588587
}
589588

590589
private isExcluded(symbol: ts.Symbol) {
591-
this.excludeCache ??= createMinimatch(
590+
this.excludeCache ??= new MinimatchSet(
592591
this.application.options.getValue("exclude"),
593592
);
594593
const cache = this.excludeCache;
595594

596-
return (symbol.getDeclarations() ?? []).some((node) => matchesAny(cache, node.getSourceFile().fileName));
595+
return (symbol.getDeclarations() ?? []).some((node) => cache.matchesAny(node.getSourceFile().fileName));
597596
}
598597

599598
/** @internal */
600599
isExternal(symbol: ts.Symbol) {
601-
this.externalPatternCache ??= createMinimatch(this.externalPattern);
600+
this.externalPatternCache ??= new MinimatchSet(this.externalPattern);
602601
const cache = this.externalPatternCache;
603602

604603
const declarations = symbol.getDeclarations();
@@ -613,7 +612,7 @@ export class Converter extends AbstractComponent<Application, ConverterEvents> {
613612
// If there are any non-external declarations, treat it as non-external
614613
// This is possible with declaration merging against external namespaces
615614
// (e.g. merging with HTMLElementTagNameMap)
616-
return declarations.every((node) => matchesAny(cache, node.getSourceFile().fileName));
615+
return declarations.every((node) => cache.matchesAny(node.getSourceFile().fileName));
617616
}
618617

619618
processDocumentTags(reflection: Reflection, parent: ContainerReflection) {

src/lib/converter/plugins/PackagePlugin.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,21 @@ import * as Path from "path";
22

33
import { ConverterComponent } from "../components.js";
44
import type { Context } from "../context.js";
5-
import { EntryPointStrategy, Option, readFile } from "../../utils/index.js";
6-
import { deriveRootDir, discoverInParentDir, discoverPackageJson } from "../../utils/fs.js";
7-
import { nicePath } from "../../utils/paths.js";
8-
import { MinimalSourceFile } from "../../utils/minimalSourceFile.js";
95
import type { ProjectReflection } from "../../models/index.js";
106
import { ApplicationEvents } from "../../application-events.js";
11-
import { join } from "path";
127
import { ConverterEvents } from "../converter-events.js";
138
import type { Converter } from "../converter.js";
9+
import type { GlobString } from "#utils";
10+
import {
11+
discoverInParentDir,
12+
discoverPackageJson,
13+
type EntryPointStrategy,
14+
getCommonDirectory,
15+
MinimalSourceFile,
16+
nicePath,
17+
Option,
18+
readFile,
19+
} from "#node-utils";
1420

1521
/**
1622
* A handler that tries to find the package.json and readme.md files of the
@@ -24,7 +30,7 @@ export class PackagePlugin extends ConverterComponent {
2430
accessor entryPointStrategy!: EntryPointStrategy;
2531

2632
@Option("entryPoints")
27-
accessor entryPoints!: string[];
33+
accessor entryPoints!: GlobString[];
2834

2935
@Option("includeVersion")
3036
accessor includeVersion!: boolean;
@@ -72,12 +78,8 @@ export class PackagePlugin extends ConverterComponent {
7278
this.readmeContents = undefined;
7379
this.packageJson = undefined;
7480

75-
const entryFiles = this.entryPointStrategy === EntryPointStrategy.Packages
76-
? this.entryPoints.map((d) => join(d, "package.json"))
77-
: this.entryPoints;
78-
7981
const dirName = this.application.options.packageDir ??
80-
Path.resolve(deriveRootDir(entryFiles));
82+
Path.resolve(getCommonDirectory(this.entryPoints.map(g => `${g}/`)));
8183

8284
this.application.logger.verbose(
8385
`Begin readme.md/package.json search at ${nicePath(dirName)}`,

src/lib/converter/plugins/SourcePlugin.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { SourceReference } from "../../models/index.js";
1010
import { gitIsInstalled, RepositoryManager } from "../utils/repository.js";
1111
import { ConverterEvents } from "../converter-events.js";
1212
import type { Converter } from "../converter.js";
13+
import type { NormalizedPath } from "#utils";
1314

1415
/**
1516
* A handler that attaches source file information to reflections.
@@ -31,7 +32,7 @@ export class SourcePlugin extends ConverterComponent {
3132
accessor sourceLinkTemplate!: string;
3233

3334
@Option("basePath")
34-
accessor basePath!: string;
35+
accessor basePath!: NormalizedPath;
3536

3637
/**
3738
* All file names to find the base path from.

0 commit comments

Comments
 (0)