Skip to content

Commit

Permalink
feat: add utility process (#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
devm33 authored Oct 6, 2023
1 parent 4082332 commit 6fba569
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/ParsedDocumentation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ export declare type BaseDocumentationContainer = {
export declare type ProcessBlock = {
main: boolean;
renderer: boolean;
utility: boolean;
exported: boolean;
};
export declare type ModuleDocumentationContainer = {
Expand Down
36 changes: 30 additions & 6 deletions src/__tests__/markdown-helpers.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -530,48 +530,72 @@ foo`),
});

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

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

it('should be available in both processes', () => {
it('should be available in utility process only', () => {
var proc = findProcess(getTokens('Process: [Utility](../glossary.md#utility-process)'));
expect(proc.main).toEqual(false);
expect(proc.renderer).toEqual(false);
expect(proc.utility).toEqual(true);
});

it('should be available in main and renderer processes', () => {
var proc = findProcess(
getTokens(
'Process: [Main](../glossary.md#main-process), [Renderer](../glossary.md#renderer-process)',
),
);
expect(proc.main).toEqual(true);
expect(proc.renderer).toEqual(true);
expect(proc.utility).toEqual(false);
});

it('should be available in both processes', () => {
it('should be available in main and renderer processes', () => {
var proc = findProcess(
getTokens(
'Process: [Renderer](../glossary.md#renderer-process), [Main](../glossary.md#main-process)',
),
);
expect(proc.main).toEqual(true);
expect(proc.renderer).toEqual(true);
expect(proc.utility).toEqual(false);
});

it('should be available in main and utility processes', () => {
var proc = findProcess(
getTokens(
'Process: [Main](../glossary.md#main-process), [Utility](../glossary.md#renderer-process)',
),
);
expect(proc.main).toEqual(true);
expect(proc.renderer).toEqual(false);
expect(proc.utility).toEqual(true);
});

it('should be available in both processes', () => {
it('should be available in all processes', () => {
var proc = findProcess(getTokens(''));
expect(proc.main).toEqual(true);
expect(proc.renderer).toEqual(true);
expect(proc.utility).toEqual(true);
});

it('should be available in both processes', () => {
it('should be available in all processes', () => {
var proc = findProcess([]);
expect(proc.main).toEqual(true);
expect(proc.renderer).toEqual(true);
expect(proc.utility).toEqual(true);
});
});

Expand Down
4 changes: 3 additions & 1 deletion src/markdown-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -818,6 +818,7 @@ export const findProcess = (tokens: Token[]): ProcessBlock => {
const procs: ProcessBlock = {
main: false,
renderer: false,
utility: false,
exported: !ptks.some(
ptk => ptk.type === 'text' && ptk.content.startsWith('This class is not exported'),
),
Expand All @@ -826,11 +827,12 @@ export const findProcess = (tokens: Token[]): ProcessBlock => {
if (ptk.type !== 'text') continue;
if (ptk.content === 'Main') procs.main = true;
if (ptk.content === 'Renderer') procs.renderer = true;
if (ptk.content === 'Utility') procs.utility = true;
}
return procs;
}
}
return { main: true, renderer: true, exported: false };
return { main: true, renderer: true, utility: true, exported: false };
};

export const slugifyHeading = (heading: string): string => {
Expand Down

0 comments on commit 6fba569

Please sign in to comment.