-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dgeni): add doc kind to document (#3037)
- Loading branch information
Showing
6 changed files
with
75 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { Document } from 'dgeni'; | ||
|
||
import { | ||
DaffDocKind, | ||
daffDocsGetKind, | ||
} from '@daffodil/docs-utils'; | ||
|
||
import { FilterableProcessor } from '../utils/filterable-processor.type'; | ||
|
||
/** | ||
* A dgeni document which has had the doc kind added. | ||
*/ | ||
export interface KindedDocument extends Document { | ||
kind: DaffDocKind; | ||
} | ||
|
||
/** | ||
* Adds doc kind based on file path. | ||
*/ | ||
export class AddKindProcessor implements FilterableProcessor { | ||
readonly name = 'addKind'; | ||
readonly $runAfter = ['files-read']; | ||
readonly $runBefore = ['processing-docs']; | ||
|
||
docTypes = []; | ||
|
||
$process(docs: Array<Document>): Array<KindedDocument> { | ||
return docs.map((doc) => { | ||
if (this.docTypes.includes(doc.docType)) { | ||
doc.kind = daffDocsGetKind(doc.fileInfo.filePath); | ||
} | ||
return doc; | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Processor } from 'dgeni'; | ||
|
||
/** | ||
* A type of processor that will only process docs of a specfic type. | ||
* All other doc types will be ignored and pass through unchanged. | ||
*/ | ||
export interface FilterableProcessor extends Processor { | ||
/** | ||
* The types of docs to process. | ||
*/ | ||
docTypes: Array<string>; | ||
} |