@wordpress/docgen 1.19.1-next.f435e9e01b.0 → 1.20.0-next.e230fbab09.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -30,8 +30,6 @@ module.exports = ( token ) => {
30
30
  case 'AssignmentExpression':
31
31
  name = t.declaration.left.name;
32
32
  break;
33
- //case 'FunctionDeclaration'
34
- //case 'ClassDeclaration'
35
33
  default:
36
34
  name = get( t.declaration, [ 'id', 'name' ], '*default*' );
37
35
  }
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- // See https://babeljs.io/docs/en/babel-types
4
+ // See https://babeljs.io/docs/en/babel-types.
5
5
  const { types: babelTypes } = require( '@babel/core' );
6
6
 
7
7
  /* eslint-disable jsdoc/valid-types */
@@ -270,14 +270,14 @@ function getTypeAnnotation( typeAnnotation ) {
270
270
  return 'boolean';
271
271
  }
272
272
  case 'TSConditionalType': {
273
- // Unsure what this is
273
+ // Unsure what this is.
274
274
  return '';
275
275
  }
276
276
  case 'TSConstructorType': {
277
277
  return `new ${ getFunctionTypeAnnotation( typeAnnotation, ': ' ) }`;
278
278
  }
279
279
  case 'TSExpressionWithTypeArguments': {
280
- // Unsure with this is
280
+ // Unsure with this is.
281
281
  return '';
282
282
  }
283
283
  case 'TSFunctionType': {
@@ -349,7 +349,7 @@ function getTypeAnnotation( typeAnnotation ) {
349
349
  ) }`;
350
350
  }
351
351
  case 'TSTypeQuery': {
352
- // unsure what this is
352
+ // Unsure what this is.
353
353
  return '';
354
354
  }
355
355
  case 'TSTypeReference': {
@@ -388,7 +388,7 @@ function getFunctionToken( token ) {
388
388
  }
389
389
 
390
390
  if ( babelTypes.isVariableDeclaration( resolvedToken ) ) {
391
- // ignore multiple variable declarations
391
+ // Ignore multiple variable declarations.
392
392
  resolvedToken = resolvedToken.declarations[ 0 ].init;
393
393
  }
394
394
 
@@ -418,7 +418,7 @@ function getArrayTagNamePosition( tag ) {
418
418
  function getQualifiedArrayPatternTypeAnnotation( tag, paramType ) {
419
419
  if ( babelTypes.isTSArrayType( paramType ) ) {
420
420
  if ( babelTypes.isTSTypeReference( paramType.elementType ) ) {
421
- // just get the element type for the array
421
+ // Just get the element type for the array.
422
422
  return paramType.elementType.typeName.name;
423
423
  }
424
424
  return getTypeAnnotation( paramType.elementType.typeAnnotation );
@@ -428,7 +428,7 @@ function getQualifiedArrayPatternTypeAnnotation( tag, paramType ) {
428
428
  );
429
429
  }
430
430
 
431
- // anything else, `Alias[ position ]`
431
+ // Anything else, `Alias[ position ]`.
432
432
  return `( ${ getTypeAnnotation( paramType ) } )[ ${ getArrayTagNamePosition(
433
433
  tag
434
434
  ) } ]`;
@@ -437,7 +437,7 @@ function getQualifiedArrayPatternTypeAnnotation( tag, paramType ) {
437
437
  function getQualifiedObjectPatternTypeAnnotation( tag, paramType ) {
438
438
  const memberName = tag.name.split( '.' ).slice( -1 )[ 0 ];
439
439
  if ( babelTypes.isTSTypeLiteral( paramType ) ) {
440
- // if it's a type literal we can try to find the member on the type
440
+ // If it's a type literal we can try to find the member on the type.
441
441
  const member = paramType.members.find(
442
442
  ( m ) => m.key.name === memberName
443
443
  );
@@ -445,7 +445,7 @@ function getQualifiedObjectPatternTypeAnnotation( tag, paramType ) {
445
445
  return getTypeAnnotation( member.typeAnnotation.typeAnnotation );
446
446
  }
447
447
  }
448
- // If we couldn't find a specific member for the type then we'll just return something like `Type[ memberName ]` to indicate the parameter is a member of that type
448
+ // If we couldn't find a specific member for the type then we'll just return something like `Type[ memberName ]` to indicate the parameter is a member of that type.
449
449
  const typeAnnotation = getTypeAnnotation( paramType );
450
450
  return `${ typeAnnotation }[ '${ memberName }' ]`;
451
451
  }
@@ -459,7 +459,7 @@ function getQualifiedObjectPatternTypeAnnotation( tag, paramType ) {
459
459
  function getParamTypeAnnotation( tag, declarationToken, paramIndex ) {
460
460
  const functionToken = getFunctionToken( declarationToken );
461
461
 
462
- // otherwise find the corresponding parameter token for the documented parameter
462
+ // Otherwise find the corresponding parameter token for the documented parameter.
463
463
  let paramToken = functionToken.params[ paramIndex ];
464
464
 
465
465
  // This shouldn't happen due to our ESLint enforcing correctly documented parameter names but just in case
@@ -525,7 +525,7 @@ function getVariableTypeAnnotation( declarationToken ) {
525
525
  }
526
526
 
527
527
  if ( babelTypes.isClassDeclaration( resolvedToken ) ) {
528
- // just use the classname if we're exporting a class
528
+ // Just use the classname if we're exporting a class.
529
529
  return resolvedToken.id.name;
530
530
  }
531
531
 
@@ -536,7 +536,7 @@ function getVariableTypeAnnotation( declarationToken ) {
536
536
  try {
537
537
  return getTypeAnnotation( resolvedToken.typeAnnotation.typeAnnotation );
538
538
  } catch ( e ) {
539
- // assume it's a fully undocumented variable, there's nothing we can do about that but fail silently.
539
+ // Assume it's a fully undocumented variable, there's nothing we can do about that but fail silently.
540
540
  }
541
541
  }
542
542
 
package/lib/index.js CHANGED
@@ -93,7 +93,7 @@ const runCustomFormatter = (
93
93
  const currentFileStack = [];
94
94
 
95
95
  module.exports = ( sourceFile, options ) => {
96
- // Input: process CLI args, prepare files, etc
96
+ // Input: process CLI args, prepare files, etc.
97
97
  const processDir = process.cwd();
98
98
  if ( sourceFile === undefined ) {
99
99
  process.stderr.write( '\n' );
@@ -116,7 +116,7 @@ module.exports = ( sourceFile, options ) => {
116
116
  ? path.join( processDir, options.output )
117
117
  : inputBase + '-api.md';
118
118
 
119
- // Process
119
+ // Process.
120
120
  const result = processFile( processDir, sourceFile );
121
121
  const filteredIR = result.ir.filter( ( symbol ) => {
122
122
  if ( isSymbolPrivate( symbol ) ) {
@@ -130,7 +130,7 @@ module.exports = ( sourceFile, options ) => {
130
130
  return true;
131
131
  } );
132
132
 
133
- // Ouput
133
+ // Ouput.
134
134
  if ( result === undefined ) {
135
135
  process.stdout.write(
136
136
  '\nFile was processed, but contained no ES6 module exports:'
@@ -190,7 +190,7 @@ module.exports = (
190
190
  docs.push( '\n' );
191
191
  docs.push( '\n' );
192
192
  } );
193
- docs.pop(); // remove last \n, we want one blank line at the end of the file.
193
+ docs.pop(); // Remove last \n, we want one blank line at the end of the file.
194
194
  } else {
195
195
  docs.push( 'Nothing to document.' );
196
196
  docs.push( '\n' );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/docgen",
3
- "version": "1.19.1-next.f435e9e01b.0",
3
+ "version": "1.20.0-next.e230fbab09.0",
4
4
  "description": "Autogenerate public API documentation from exports and JSDoc comments.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -39,5 +39,5 @@
39
39
  "publishConfig": {
40
40
  "access": "public"
41
41
  },
42
- "gitHead": "14b2846015dfb1b440ce93accdd03842ebe5f1cd"
42
+ "gitHead": "308df03e6a96ded732f9c4e32471b1b4f8dea54a"
43
43
  }