Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add utility process #95

Merged
merged 1 commit into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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