Skip to content

Commit b4e5dbd

Browse files
committed
Set default value for name and description to null.
Updated types in core. Updated templates. Updated tests.
1 parent 4fb2c7c commit b4e5dbd

File tree

10 files changed

+22
-18
lines changed

10 files changed

+22
-18
lines changed

packages/doxdox-core/src/types.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export interface Method {
1818
slug: string;
1919
name: string;
2020
fullName: string;
21-
description: string;
21+
description: string | null;
2222
params: Param[];
2323
returns: Param[];
2424
private: boolean;
@@ -29,7 +29,7 @@ export interface Package extends Options {
2929
}
3030

3131
export interface Param {
32-
name?: string;
33-
description: string;
32+
name: string | null;
33+
description: string | null;
3434
types: string[];
3535
}

packages/doxdox-parser-jsdoc/src/index.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@ const getRootDirPath = (url) => {};`
5050
private: false,
5151
returns: expect.arrayContaining([
5252
expect.objectContaining({
53-
name: undefined,
53+
name: null,
54+
description: 'Path to package.json file.',
5455
types: ['Promise.<(string|null)>']
5556
})
5657
]),
@@ -68,7 +69,8 @@ const getRootDirPath = (url) => {};`
6869
private: false,
6970
returns: expect.arrayContaining([
7071
expect.objectContaining({
71-
name: undefined,
72+
name: null,
73+
description: 'Directory path.',
7274
types: ['string']
7375
})
7476
]),

packages/doxdox-parser-jsdoc/src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,15 @@ const parser = async (cwd: string, path: string): Promise<File> => {
4646
)
4747
.map((jsdoc: Jsdoc) => {
4848
const params = (jsdoc.params || []).map(
49-
({ name, description = '', type = {} }) => ({
49+
({ name = null, description = null, type = {} }) => ({
5050
name,
5151
description,
5252
types: type.names || []
5353
})
5454
);
5555

5656
const returns = (jsdoc.returns || []).map(
57-
({ name, description = '', type = {} }) => ({
57+
({ name = null, description = null, type = {} }) => ({
5858
name,
5959
description,
6060
types: type.names || []
@@ -77,7 +77,7 @@ const parser = async (cwd: string, path: string): Promise<File> => {
7777
.map(param => param.name)
7878
.filter(name => name && !name.match(/\./))
7979
.join(', ')})`,
80-
description: jsdoc.description || '',
80+
description: jsdoc.description || null,
8181
params,
8282
returns,
8383
private: isPrivate

packages/doxdox-renderer-bootstrap/src/index.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ describe('bootstrap', () => {
3737
],
3838
returns: [
3939
{
40+
name: null,
4041
description: 'Return description',
4142
types: ['void']
4243
}

packages/doxdox-renderer-bootstrap/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ ${md
4141
...method.params.map(({ name, types, description }) => [
4242
name,
4343
`<code>${types.join('</code>, <code>')}</code>`,
44-
description
44+
description || ''
4545
])
4646
])
4747
)
@@ -57,7 +57,7 @@ ${
5757
${method.returns.map(
5858
param => `<p><code>${param.types.join('</code>, <code>')}</code></p>
5959
60-
<p>${param.description}</p>`
60+
${param.description ? `<p>${param.description}</p>` : ''}`
6161
)}`
6262
: ''
6363
}

packages/doxdox-renderer-dash/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ ${md
6464
...method.params.map(({ name, types, description }) => [
6565
name,
6666
`<code>${types.join('</code>, <code>')}</code>`,
67-
description
67+
description || ''
6868
])
6969
])
7070
)
@@ -80,7 +80,7 @@ ${
8080
${method.returns.map(
8181
param => `<p><code>${param.types.join('</code>, <code>')}</code></p>
8282
83-
<p>${param.description}</p>`
83+
${param.description ? `<p>${param.description}</p>` : ''}`
8484
)}`
8585
: ''
8686
}

packages/doxdox-renderer-github-wiki/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ ${markdownTable([
1919
...method.params.map(({ name, types, description }) => [
2020
name,
2121
types.join(', '),
22-
description
22+
description || ''
2323
])
2424
])}`
2525
: ''
@@ -31,7 +31,7 @@ ${
3131
3232
${method.returns.map(
3333
param => `${param.types.join(', ')}
34-
${param.description}`
34+
${param.description || ''}`
3535
)}`
3636
: ''
3737
}

packages/doxdox-renderer-markdown/src/index.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ describe('markdown', () => {
3737
],
3838
returns: [
3939
{
40+
name: null,
4041
description: 'Return description',
4142
types: ['void']
4243
}

packages/doxdox-renderer-markdown/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ ${markdownTable([
1515
...method.params.map(({ name, types, description }) => [
1616
name,
1717
types.join(', '),
18-
description
18+
description || ''
1919
])
2020
])}`
2121
: ''
@@ -27,7 +27,7 @@ ${
2727
2828
${method.returns.map(
2929
param => `${param.types.join(', ')}
30-
${param.description}`
30+
${param.description || ''}`
3131
)}`
3232
: ''
3333
}

packages/doxdox-renderer-pdf/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ ${md
3838
...method.params.map(({ name, types, description }) => [
3939
name,
4040
`<code>${types.join('</code>, <code>')}</code>`,
41-
description
41+
description || ''
4242
])
4343
])
4444
)
@@ -54,7 +54,7 @@ ${
5454
${method.returns.map(
5555
param => `<p><code>${param.types.join('</code>, <code>')}</code></p>
5656
57-
<p>${param.description}</p>`
57+
${param.description ? `<p>${param.description}</p>` : ''}`
5858
)}`
5959
: ''
6060
}

0 commit comments

Comments
 (0)