Skip to content

Commit

Permalink
Expose Converter.parseRawComment
Browse files Browse the repository at this point in the history
Closes #2004
  • Loading branch information
Gerrit0 committed Jul 17, 2022
1 parent e13a8f7 commit 70ab81a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -3,6 +3,7 @@
### Features

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

### Thanks!

Expand Down
19 changes: 14 additions & 5 deletions src/lib/converter/converter.ts
Expand Up @@ -183,6 +183,18 @@ export class Converter extends ChildableComponent<
return convertType(context, node);
}

/**
* Parse the given file into a comment. Intended to be used with markdown files.
*/
parseRawComment(file: MinimalSourceFile) {
return parseComment(
lexCommentString(file.text),
this.config,
file,
this.application.logger
);
}

/**
* Compile the files within the given context and convert the compiler symbols to reflections.
*
Expand Down Expand Up @@ -264,11 +276,8 @@ export class Converter extends ChildableComponent<

if (entryPoint.readmeFile) {
const readme = readFile(entryPoint.readmeFile);
const comment = parseComment(
lexCommentString(readme),
context.converter.config,
new MinimalSourceFile(readme, entryPoint.readmeFile),
context.logger
const comment = this.parseRawComment(
new MinimalSourceFile(readme, entryPoint.readmeFile)
);

if (comment.blockTags.length || comment.modifierTags.size) {
Expand Down
9 changes: 2 additions & 7 deletions src/lib/converter/plugins/PackagePlugin.ts
Expand Up @@ -7,8 +7,6 @@ import type { Context } from "../context";
import { BindOption, EntryPointStrategy, readFile } from "../../utils";
import { getCommonDirectory } from "../../utils/fs";
import { nicePath } from "../../utils/paths";
import { lexCommentString } from "../comments/rawLexer";
import { parseComment } from "../comments/parser";
import { MinimalSourceFile } from "../../utils/minimalSourceFile";

/**
Expand Down Expand Up @@ -105,11 +103,8 @@ export class PackagePlugin extends ConverterComponent {
const project = context.project;
if (this.readmeFile) {
const readme = readFile(this.readmeFile);
const comment = parseComment(
lexCommentString(readme),
context.converter.config,
new MinimalSourceFile(readme, this.readmeFile),
context.logger
const comment = context.converter.parseRawComment(
new MinimalSourceFile(readme, this.readmeFile)
);

if (comment.blockTags.length || comment.modifierTags.size) {
Expand Down

0 comments on commit 70ab81a

Please sign in to comment.