Skip to content

Commit

Permalink
Add basePath option
Browse files Browse the repository at this point in the history
Closes #1924
  • Loading branch information
Gerrit0 committed Jul 1, 2022
1 parent 90a9526 commit 98903d3
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -13,6 +13,7 @@
### Features

- Added `--htmlLang` option to set the [`lang`](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/lang) attribute in the generated HTML. Defaults to `en`, #1951.
- Added `--basePath` option to override TypeDoc's detected root directory, #1924.
- Added support for TypeDoc specific `:getter` and `:setter` meaning keywords in declaration references.
- Warnings caused by comment contents will now do a better job of including the location of the text that caused the warning.

Expand Down
6 changes: 5 additions & 1 deletion src/lib/converter/plugins/SourcePlugin.ts
Expand Up @@ -25,6 +25,9 @@ export class SourcePlugin extends ConverterComponent {
@BindOption("gitRemote")
readonly gitRemote!: string;

@BindOption("basePath")
readonly basePath!: string;

/**
* All file names to find the base path from.
*/
Expand Down Expand Up @@ -106,7 +109,8 @@ export class SourcePlugin extends ConverterComponent {
private onBeginResolve(context: Context) {
if (this.disableSources) return;

const basePath = getCommonDirectory([...this.fileNames]);
const basePath =
this.basePath || getCommonDirectory([...this.fileNames]);

for (const refl of Object.values(context.project.reflections)) {
for (const source of refl.sources || []) {
Expand Down
3 changes: 2 additions & 1 deletion src/lib/utils/entry-point.ts
Expand Up @@ -138,7 +138,8 @@ function getEntryPointsForPaths(
options: Options,
programs = getEntryPrograms(logger, options)
): DocumentationEntryPoint[] | undefined {
const baseDir = getCommonDirectory(inputFiles);
const baseDir =
options.getValue("basePath") || getCommonDirectory(inputFiles);
const entryPoints: DocumentationEntryPoint[] = [];

entryLoop: for (const fileOrDir of inputFiles.map(normalizePath)) {
Expand Down
1 change: 1 addition & 0 deletions src/lib/utils/options/declaration.ts
Expand Up @@ -88,6 +88,7 @@ export interface TypeDocOptionMap {
excludeNotDocumented: boolean;
excludeInternal: boolean;
disableSources: boolean;
basePath: string;
includes: string;
media: string;

Expand Down
5 changes: 5 additions & 0 deletions src/lib/utils/options/sources/typedoc.ts
Expand Up @@ -213,6 +213,11 @@ export function addTypeDocOptions(options: Pick<Options, "addDeclaration">) {
help: "Disable setting the source of a reflection when documenting it.",
type: ParameterType.Boolean,
});
options.addDeclaration({
name: "basePath",
help: "Specifies the base path to be used when displaying file paths.",
type: ParameterType.Path,
});
options.addDeclaration({
name: "excludeTags",
help: "Remove the listed block/modifier tags from doc comments.",
Expand Down

0 comments on commit 98903d3

Please sign in to comment.