From 4f518a6287afd9125a5ceff3ca00fb260501dcff Mon Sep 17 00:00:00 2001 From: Gerrit Birkeland Date: Tue, 17 Dec 2024 20:06:25 -0700 Subject: [PATCH] Support `@include` in readme file Ref: #2814 --- CHANGELOG.md | 4 ++++ src/lib/converter/converter.ts | 5 ++++- src/lib/converter/plugins/IncludePlugin.ts | 2 +- src/lib/converter/plugins/PackagePlugin.ts | 8 ++++++++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 52dfb6042..2458b31f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ title: Changelog ## Unreleased +### Bug Fixes + +- `@include` and `@includeCode` now work in the readme file, #2814. + ## v0.27.5 (2024-12-14) ### Bug Fixes diff --git a/src/lib/converter/converter.ts b/src/lib/converter/converter.ts index 8d56499b6..75f3f2c56 100644 --- a/src/lib/converter/converter.ts +++ b/src/lib/converter/converter.ts @@ -248,6 +248,9 @@ export class Converter extends AbstractComponent { */ static readonly EVENT_RESOLVE_END = ConverterEvents.RESOLVE_END; + /** @internal @hidden */ + includePlugin: IncludePlugin; + constructor(owner: Application) { super(owner); @@ -304,7 +307,7 @@ export class Converter extends AbstractComponent { new PackagePlugin(this); new SourcePlugin(this); new TypePlugin(this); - new IncludePlugin(this); + this.includePlugin = new IncludePlugin(this); new MergeModuleWithPlugin(this); } diff --git a/src/lib/converter/plugins/IncludePlugin.ts b/src/lib/converter/plugins/IncludePlugin.ts index c7e43a19b..8e07c6aa3 100644 --- a/src/lib/converter/plugins/IncludePlugin.ts +++ b/src/lib/converter/plugins/IncludePlugin.ts @@ -46,7 +46,7 @@ export class IncludePlugin extends ConverterComponent { } } - private checkIncludeTagsParts( + checkIncludeTagsParts( refl: Reflection, relative: string, parts: CommentDisplayPart[], diff --git a/src/lib/converter/plugins/PackagePlugin.ts b/src/lib/converter/plugins/PackagePlugin.ts index a8f63a1e1..e14338492 100644 --- a/src/lib/converter/plugins/PackagePlugin.ts +++ b/src/lib/converter/plugins/PackagePlugin.ts @@ -135,6 +135,14 @@ export class PackagePlugin extends ConverterComponent { ); project.readme = content; + + // This isn't ideal, but seems better than figuring out the readme + // path over in the include plugin... + this.owner.includePlugin.checkIncludeTagsParts( + project, + Path.dirname(this.readmeFile), + content, + ); } if (this.packageJson) {