Skip to content

Commit

Permalink
feat(dgeni,docs-utils): add kind to documents (#3396)
Browse files Browse the repository at this point in the history
  • Loading branch information
griest024 authored Jan 7, 2025
1 parent 0579eb4 commit a26cde4
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 6 deletions.
7 changes: 6 additions & 1 deletion apps/daffio/src/app/docs/testing/factories/docs.factory.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import { Injectable } from '@angular/core';
import { faker } from '@faker-js/faker/locale/en_US';

import { sample } from '@daffodil/core';
import { DaffModelFactory } from '@daffodil/core/testing';
import { DaffGuideDoc } from '@daffodil/docs-utils';
import {
DaffDocKind,
DaffGuideDoc,
} from '@daffodil/docs-utils';

export class MockDoc implements DaffGuideDoc {
id = String(faker.datatype.number(1000));
kind = sample(Object.values(DaffDocKind));
title = faker.lorem.words();
contents = faker.lorem.paragraph();
// TODO: implement child models
Expand Down
3 changes: 3 additions & 0 deletions libs/docs-utils/src/doc/type.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { DaffBreadcrumb } from '@daffodil/docs-utils';

import { DaffDocKind } from '../kind/public_api';

/**
* A basic generated document that represents some piece of documentation.
*/
Expand All @@ -8,4 +10,5 @@ export interface DaffDoc {
title: string;
contents: string;
breadcrumbs: Array<DaffBreadcrumb>;
kind: DaffDocKind;
}
5 changes: 3 additions & 2 deletions tools/dgeni/src/processors/convertToJson.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import {
export const CONVERT_TO_JSON_PROCESSOR_NAME = 'convertToJson';

export class ConvertToJsonProcessor implements Processor {
name = CONVERT_TO_JSON_PROCESSOR_NAME;
$runBefore = ['writeFilesProcessor'];
readonly name = CONVERT_TO_JSON_PROCESSOR_NAME;
readonly $runAfter = ['docs-rendered'];
readonly $runBefore = ['writeFilesProcessor'];
docTypes = [];
/**
* Extra doc fields to be copied into the written JSON document.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export class AddPackageExportsProcessor implements Processor {
if (this.docTypes.includes(doc.docType)) {
doc.data = {
breadcrumbs: doc.breadcrumbs,
kind: doc.kind,
...getPackageInfo(doc),
};
}
Expand Down
9 changes: 6 additions & 3 deletions tools/dgeni/src/transforms/daffodil-base-package/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ import * as basePackage from 'dgeni-packages/base';
import * as nunjucksPackage from 'dgeni-packages/nunjucks';
import * as path from 'path';

import { ABSOLUTIFY_PATHS_PROCESSOR_PROVIDER } from '../../processors/absolutify-paths';
import {
ABSOLUTIFY_PATHS_PROCESSOR_NAME,
ABSOLUTIFY_PATHS_PROCESSOR_PROVIDER,
} from '../../processors/absolutify-paths';
import { ADD_KIND_PROCESSOR_PROVIDER } from '../../processors/add-kind';
import { BREADCRUMB_PROCESSOR_PROVIDER } from '../../processors/breadcrumb';
import {
Expand All @@ -30,7 +33,7 @@ export const daffodilBasePackage = new Package('daffodil-base', [
])
.processor({ name: 'absolutify-paths', $runAfter: ['paths-computed'], $process: (d) => d })
.processor(...ABSOLUTIFY_PATHS_PROCESSOR_PROVIDER)
.processor({ name: 'paths-absolutified', $runAfter: ['absolutify-paths'], $process: (d) => d })
.processor({ name: 'paths-absolutified', $runAfter: [ABSOLUTIFY_PATHS_PROCESSOR_NAME], $process: (d) => d })
.processor(...ADD_KIND_PROCESSOR_PROVIDER)
.factory(...ID_SANITIZER_PROVIDER)
.processor(...BREADCRUMB_PROCESSOR_PROVIDER)
Expand Down Expand Up @@ -78,5 +81,5 @@ export const daffodilBasePackage = new Package('daffodil-base', [
})

.config((convertToJson: ConvertToJsonProcessor) => {
convertToJson.extraFields.push('breadcrumbs');
convertToJson.extraFields.push('breadcrumbs', 'kind');
});

0 comments on commit a26cde4

Please sign in to comment.