Skip to content

Commit 70ab81a

Browse files
committed
Expose Converter.parseRawComment
Closes #2004
1 parent e13a8f7 commit 70ab81a

File tree

3 files changed

+17
-12
lines changed

3 files changed

+17
-12
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
### Features
44

55
- Added support for `*.ghe.com` and `*.github.us` GitHub enterprise domains for source links, #2001.
6+
- Expose `Converter.parseRawComment` for plugins to parse additional markdown files, #2004.
67

78
### Thanks!
89

src/lib/converter/converter.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,18 @@ export class Converter extends ChildableComponent<
183183
return convertType(context, node);
184184
}
185185

186+
/**
187+
* Parse the given file into a comment. Intended to be used with markdown files.
188+
*/
189+
parseRawComment(file: MinimalSourceFile) {
190+
return parseComment(
191+
lexCommentString(file.text),
192+
this.config,
193+
file,
194+
this.application.logger
195+
);
196+
}
197+
186198
/**
187199
* Compile the files within the given context and convert the compiler symbols to reflections.
188200
*
@@ -264,11 +276,8 @@ export class Converter extends ChildableComponent<
264276

265277
if (entryPoint.readmeFile) {
266278
const readme = readFile(entryPoint.readmeFile);
267-
const comment = parseComment(
268-
lexCommentString(readme),
269-
context.converter.config,
270-
new MinimalSourceFile(readme, entryPoint.readmeFile),
271-
context.logger
279+
const comment = this.parseRawComment(
280+
new MinimalSourceFile(readme, entryPoint.readmeFile)
272281
);
273282

274283
if (comment.blockTags.length || comment.modifierTags.size) {

src/lib/converter/plugins/PackagePlugin.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import type { Context } from "../context";
77
import { BindOption, EntryPointStrategy, readFile } from "../../utils";
88
import { getCommonDirectory } from "../../utils/fs";
99
import { nicePath } from "../../utils/paths";
10-
import { lexCommentString } from "../comments/rawLexer";
11-
import { parseComment } from "../comments/parser";
1210
import { MinimalSourceFile } from "../../utils/minimalSourceFile";
1311

1412
/**
@@ -105,11 +103,8 @@ export class PackagePlugin extends ConverterComponent {
105103
const project = context.project;
106104
if (this.readmeFile) {
107105
const readme = readFile(this.readmeFile);
108-
const comment = parseComment(
109-
lexCommentString(readme),
110-
context.converter.config,
111-
new MinimalSourceFile(readme, this.readmeFile),
112-
context.logger
106+
const comment = context.converter.parseRawComment(
107+
new MinimalSourceFile(readme, this.readmeFile)
113108
);
114109

115110
if (comment.blockTags.length || comment.modifierTags.size) {

0 commit comments

Comments
 (0)