Skip to content

Commit

Permalink
feat(dgeni): process API doc descriptions through markdown (#2961)
Browse files Browse the repository at this point in the history
  • Loading branch information
griest024 authored Aug 8, 2024
1 parent 1858e22 commit 5ffbb6f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
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

0 comments on commit 5ffbb6f

Please sign in to comment.