Skip to content

Commit

Permalink
feat(dgeni,daffio): guides-list.json -> index.json (#2881)
Browse files Browse the repository at this point in the history
  • Loading branch information
griest024 committed Jun 16, 2024
1 parent 7659261 commit bea169f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 15 deletions.
2 changes: 1 addition & 1 deletion apps/daffio/src/app/docs/services/docs.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe('DaffioDocsService', () => {

service.getPackageList().subscribe((guides) => {
expect(guides).toEqual(mockGuideList);
expect(fetchAssetServiceSpy.fetch).toHaveBeenCalledWith('/assets/daffio/docs/packages/guide-list.json');
expect(fetchAssetServiceSpy.fetch).toHaveBeenCalledWith('/assets/daffio/docs/packages/index.json');
done();
});
});
Expand Down
4 changes: 2 additions & 2 deletions apps/daffio/src/app/docs/services/docs.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ export class DaffioDocsService<T extends DaffioDoc = DaffioDoc, V extends Daffio
}

getPackageList(): Observable<V> {
return this.fetchAsset.fetch<V>(`${this.docsPath}docs/packages/guide-list.json`);
return this.fetchAsset.fetch<V>(`${this.docsPath}docs/packages/index.json`);
}

getGuidesList(): Observable<V> {
return this.fetchAsset.fetch<V>(`${this.docsPath}docs/guides/guide-list.json`);
return this.fetchAsset.fetch<V>(`${this.docsPath}docs/guides/index.json`);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const base = new Package('daffodil-guides-base', [daffodilBasePackage])
});

export const packageDocsPackage = new Package('daffodil-package-docs', [base])
.processor(new GenerateGuideListProcessor())
.processor(new GenerateGuideListProcessor({ outputFolder: 'packages' }))
.config((readFilesProcessor) => {
readFilesProcessor.basePath = API_SOURCE_PATH;
readFilesProcessor.sourceFiles = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,10 @@ import {

import { generateNavigationTrieFromDocuments } from '../helpers/navigation-trie';


export interface GenerateGuideListConfiguration {
outputFolder: string;
};

export const DefaultGenerateGuideListConfiguration: GenerateGuideListConfiguration = {
outputFolder: 'packages',
};

export const transformGuideDoc = (doc: Document): TransformedDocument => ({
id: doc.id,
title: doc.title,
Expand All @@ -25,11 +20,8 @@ export class GenerateGuideListProcessor implements Processor {
name = 'generateGuideList';
$runAfter = ['docs-processed'];
$runBefore = ['rendering-docs'];
config: GenerateGuideListConfiguration;

constructor(config?: GenerateGuideListConfiguration) {
this.config = { ...DefaultGenerateGuideListConfiguration, ...config };
}
constructor(private config: GenerateGuideListConfiguration) {}

$process(docs: Document[]): Document[] {
// hardcode design path
Expand All @@ -42,8 +34,8 @@ export class GenerateGuideListProcessor implements Processor {
docs.push({
docType: 'navigation-list',
template: 'guide-list.template.json',
path: this.config.outputFolder + '/guide-list.json',
outputPath: this.config.outputFolder + '/guide-list.json',
path: this.config.outputFolder + '/index.json',
outputPath: this.config.outputFolder + '/index.json',
data: generateNavigationTrieFromDocuments(docsWithoutDesignChildren.map(transformGuideDoc)),
});

Expand Down

0 comments on commit bea169f

Please sign in to comment.