Skip to content

Commit 6fba569

Browse files
authored
feat: add utility process (#95)
1 parent 4082332 commit 6fba569

File tree

3 files changed

+34
-7
lines changed

3 files changed

+34
-7
lines changed

src/ParsedDocumentation.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ export declare type BaseDocumentationContainer = {
9090
export declare type ProcessBlock = {
9191
main: boolean;
9292
renderer: boolean;
93+
utility: boolean;
9394
exported: boolean;
9495
};
9596
export declare type ModuleDocumentationContainer = {

src/__tests__/markdown-helpers.spec.ts

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -530,48 +530,72 @@ foo`),
530530
});
531531

532532
describe('findProcess()', () => {
533-
it('should be available in main processe only', () => {
533+
it('should be available in main process only', () => {
534534
var proc = findProcess(getTokens('Process: [Main](../glossary.md#main-process)'));
535535
expect(proc.main).toEqual(true);
536536
expect(proc.renderer).toEqual(false);
537+
expect(proc.utility).toEqual(false);
537538
});
538539

539-
it('should be available in renderer processe only', () => {
540+
it('should be available in renderer process only', () => {
540541
var proc = findProcess(getTokens('Process: [Renderer](../glossary.md#renderer-process)'));
541542
expect(proc.main).toEqual(false);
542543
expect(proc.renderer).toEqual(true);
544+
expect(proc.utility).toEqual(false);
543545
});
544546

545-
it('should be available in both processes', () => {
547+
it('should be available in utility process only', () => {
548+
var proc = findProcess(getTokens('Process: [Utility](../glossary.md#utility-process)'));
549+
expect(proc.main).toEqual(false);
550+
expect(proc.renderer).toEqual(false);
551+
expect(proc.utility).toEqual(true);
552+
});
553+
554+
it('should be available in main and renderer processes', () => {
546555
var proc = findProcess(
547556
getTokens(
548557
'Process: [Main](../glossary.md#main-process), [Renderer](../glossary.md#renderer-process)',
549558
),
550559
);
551560
expect(proc.main).toEqual(true);
552561
expect(proc.renderer).toEqual(true);
562+
expect(proc.utility).toEqual(false);
553563
});
554564

555-
it('should be available in both processes', () => {
565+
it('should be available in main and renderer processes', () => {
556566
var proc = findProcess(
557567
getTokens(
558568
'Process: [Renderer](../glossary.md#renderer-process), [Main](../glossary.md#main-process)',
559569
),
560570
);
561571
expect(proc.main).toEqual(true);
562572
expect(proc.renderer).toEqual(true);
573+
expect(proc.utility).toEqual(false);
574+
});
575+
576+
it('should be available in main and utility processes', () => {
577+
var proc = findProcess(
578+
getTokens(
579+
'Process: [Main](../glossary.md#main-process), [Utility](../glossary.md#renderer-process)',
580+
),
581+
);
582+
expect(proc.main).toEqual(true);
583+
expect(proc.renderer).toEqual(false);
584+
expect(proc.utility).toEqual(true);
563585
});
564586

565-
it('should be available in both processes', () => {
587+
it('should be available in all processes', () => {
566588
var proc = findProcess(getTokens(''));
567589
expect(proc.main).toEqual(true);
568590
expect(proc.renderer).toEqual(true);
591+
expect(proc.utility).toEqual(true);
569592
});
570593

571-
it('should be available in both processes', () => {
594+
it('should be available in all processes', () => {
572595
var proc = findProcess([]);
573596
expect(proc.main).toEqual(true);
574597
expect(proc.renderer).toEqual(true);
598+
expect(proc.utility).toEqual(true);
575599
});
576600
});
577601

src/markdown-helpers.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -818,6 +818,7 @@ export const findProcess = (tokens: Token[]): ProcessBlock => {
818818
const procs: ProcessBlock = {
819819
main: false,
820820
renderer: false,
821+
utility: false,
821822
exported: !ptks.some(
822823
ptk => ptk.type === 'text' && ptk.content.startsWith('This class is not exported'),
823824
),
@@ -826,11 +827,12 @@ export const findProcess = (tokens: Token[]): ProcessBlock => {
826827
if (ptk.type !== 'text') continue;
827828
if (ptk.content === 'Main') procs.main = true;
828829
if (ptk.content === 'Renderer') procs.renderer = true;
830+
if (ptk.content === 'Utility') procs.utility = true;
829831
}
830832
return procs;
831833
}
832834
}
833-
return { main: true, renderer: true, exported: false };
835+
return { main: true, renderer: true, utility: true, exported: false };
834836
};
835837

836838
export const slugifyHeading = (heading: string): string => {

0 commit comments

Comments
 (0)