@wordpress/docgen 1.24.0 → 1.25.1-next.957ca95e4c.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.
@@ -1,8 +1,3 @@
1
- /**
2
- * External dependencies
3
- */
4
- const { get } = require( 'lodash' );
5
-
6
1
  /**
7
2
  * Returns the export entry records of the given export statement.
8
3
  * Unlike [the standard](http://www.ecma-international.org/ecma-262/9.0/#exportentry-record),
@@ -31,7 +26,7 @@ module.exports = ( token ) => {
31
26
  name = t.declaration.left.name;
32
27
  break;
33
28
  default:
34
- name = get( t.declaration, [ 'id', 'name' ], '*default*' );
29
+ name = t.declaration.id?.name ?? '*default*';
35
30
  }
36
31
  return name;
37
32
  };
@@ -64,7 +59,7 @@ module.exports = ( token ) => {
64
59
  name.push( {
65
60
  localName: specifier.local.name,
66
61
  exportName: specifier.exported.name,
67
- module: get( token.source, [ 'value' ], null ),
62
+ module: token.source?.value ?? null,
68
63
  lineStart: specifier.loc.start.line,
69
64
  lineEnd: specifier.loc.end.line,
70
65
  } )
@@ -1,8 +1,3 @@
1
- /**
2
- * External dependencies
3
- */
4
- const { get } = require( 'lodash' );
5
-
6
1
  /**
7
2
  * Internal dependencies
8
3
  */
@@ -154,8 +149,8 @@ module.exports = (
154
149
  ir.push( {
155
150
  path,
156
151
  name: entry.exportName,
157
- description: get( doc, [ 'description' ], UNDOCUMENTED ),
158
- tags: get( doc, [ 'tags' ], [] ),
152
+ description: doc?.description ?? UNDOCUMENTED,
153
+ tags: doc?.tags ?? [],
159
154
  lineStart: entry.lineStart,
160
155
  lineEnd: entry.lineEnd,
161
156
  } );
@@ -1,8 +1,3 @@
1
- /**
2
- * External dependencies
3
- */
4
- const { last } = require( 'lodash' );
5
-
6
1
  /**
7
2
  * Function that returns the leading comment
8
3
  * of a Espree node.
@@ -14,7 +9,10 @@ const { last } = require( 'lodash' );
14
9
  module.exports = ( declaration ) => {
15
10
  let comments;
16
11
  if ( declaration.leadingComments ) {
17
- const lastComment = last( declaration.leadingComments );
12
+ const lastComment =
13
+ declaration.leadingComments[
14
+ declaration.leadingComments.length - 1
15
+ ];
18
16
  if ( lastComment ) {
19
17
  comments = lastComment.value;
20
18
  }
@@ -394,7 +394,7 @@ function getTypeAnnotation( typeAnnotation ) {
394
394
  *
395
395
  * @param {ASTNode} token Contains either a function or a call to a function-wrapper.
396
396
  *
397
- * TODO: Remove the special-casing here once we're able to infer the types from TypeScript itself.
397
+ * TODO: Remove the special-casing here once we're able to infer the types from TypeScript itself.
398
398
  */
399
399
  function unwrapWrappedSelectors( token ) {
400
400
  if ( babelTypes.isFunctionDeclaration( token ) ) {
package/lib/index.js CHANGED
@@ -3,7 +3,6 @@
3
3
  */
4
4
  const fs = require( 'fs' );
5
5
  const path = require( 'path' );
6
- const { last } = require( 'lodash' );
7
6
 
8
7
  /**
9
8
  * Internal dependencies
@@ -60,7 +59,10 @@ const processFile = ( rootDir, inputFile ) => {
60
59
  const result = engine(
61
60
  relativePath,
62
61
  data,
63
- getIRFromRelativePath( rootDir, last( currentFileStack ) )
62
+ getIRFromRelativePath(
63
+ rootDir,
64
+ currentFileStack[ currentFileStack.length - 1 ]
65
+ )
64
66
  );
65
67
  currentFileStack.pop();
66
68
  return result;
@@ -35,6 +35,24 @@ const formatExamples = ( tags, docs ) => {
35
35
  }
36
36
  };
37
37
 
38
+ const formatSince = ( tags, docs ) => {
39
+ if ( tags && tags.length > 0 ) {
40
+ docs.push( '\n' );
41
+ docs.push( '\n' );
42
+ docs.push( '*Changelog*' );
43
+ docs.push( '\n' );
44
+ docs.push( '\n' );
45
+ docs.push(
46
+ ...tags.map(
47
+ ( tag ) =>
48
+ `\n${ cleanSpaces(
49
+ `\`${ tag.name }\` ${ tag.description }`
50
+ ) }`
51
+ )
52
+ );
53
+ }
54
+ };
55
+
38
56
  const formatDeprecated = ( tags, docs ) => {
39
57
  if ( tags && tags.length > 0 ) {
40
58
  docs.push( '\n' );
@@ -187,6 +205,7 @@ module.exports = (
187
205
  },
188
206
  docs
189
207
  );
208
+ formatSince( getSymbolTagsByName( symbol, 'since' ), docs );
190
209
  docs.push( '\n' );
191
210
  docs.push( '\n' );
192
211
  } );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/docgen",
3
- "version": "1.24.0",
3
+ "version": "1.25.1-next.957ca95e4c.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",
@@ -29,7 +29,6 @@
29
29
  "dependencies": {
30
30
  "@babel/core": "^7.16.0",
31
31
  "comment-parser": "^1.1.1",
32
- "lodash": "^4.17.21",
33
32
  "mdast-util-inject": "1.1.0",
34
33
  "optionator": "0.8.2",
35
34
  "remark": "10.0.1",
@@ -39,5 +38,5 @@
39
38
  "publishConfig": {
40
39
  "access": "public"
41
40
  },
42
- "gitHead": "9d9d33bbdf317a4381b8ca1713e43bb50df653b3"
41
+ "gitHead": "272a74bbbaab10ee24424eafe9578e705fbfbbb4"
43
42
  }