Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(dgeni): process API doc descriptions through markdown #2961

Merged
merged 1 commit into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion tools/dgeni/src/processors/markdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,14 @@ export class MarkdownCodeProcessor implements Processor {
$runAfter = ['paths-computed'];
$runBefore = ['rendering-docs'];
docTypes = [];
contentKey = 'content';

constructor() {}

$process(docs: Document[]) {
return docs.map((doc) => {
if(this.docTypes.includes(doc.docType)){
doc.content = marked.parse(doc.content);
doc[this.contentKey] = marked.parse(doc.content);
};
return doc;
});
Expand Down
6 changes: 6 additions & 0 deletions tools/dgeni/src/transforms/daffodil-api-package/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { FilterContainedDocsProcessor } from '../../processors/filterDocs';
import { FilterOutPrivatePropertiesProcessor } from '../../processors/filterOutPrivateProperties';
import { GenerateApiListProcessor } from '../../processors/generateApiList';
import { MakeTypesHtmlCompatibleProcessor } from '../../processors/makeTypesHtmlCompatible';
import { MarkdownCodeProcessor } from '../../processors/markdown';
import { PackagesProcessor } from '../../processors/packages';
import {
API_SOURCE_PATH,
Expand All @@ -39,6 +40,7 @@ export const apiDocs = new Package('daffodil-api', [
.processor(new AddLinkTagToDaffodilReferencesProcessor())
.processor(new GenerateApiListProcessor())
.processor(new PackagesProcessor())
.processor(new MarkdownCodeProcessor())
.factory('API_DOC_TYPES_TO_RENDER', (EXPORT_DOC_TYPES) => EXPORT_DOC_TYPES.concat(['component', 'directive', 'pipe', 'package']))
//Configure our package
.config((readFilesProcessor, readTypeScriptModules, tsParser) => {
Expand All @@ -59,6 +61,10 @@ export const apiDocs = new Package('daffodil-api', [
DAFF_DGENI_EXCLUDED_PACKAGES_REGEX + '/**/src/index.ts',
];
})
.config((markdown: MarkdownCodeProcessor, EXPORT_DOC_TYPES) => {
markdown.docTypes.push(...EXPORT_DOC_TYPES);
markdown.contentKey = 'description';
})
.config((computePathsProcessor, EXPORT_DOC_TYPES, generateApiList) => {

const API_SEGMENT = DAFF_DOC_KIND_PATH_SEGMENT_MAP[DaffDocKind.API];
Expand Down
Loading