@wordpress/docgen 1.22.0 → 1.24.1-next.d6164808d3.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
@@ -11,6 +10,7 @@ const { last } = require( 'lodash' );
11
10
  const engine = require( './engine' );
12
11
  const defaultMarkdownFormatter = require( './markdown' );
13
12
  const isSymbolPrivate = require( './is-symbol-private' );
13
+ const isSymbolIgnore = require( './is-symbol-ignore' );
14
14
 
15
15
  /**
16
16
  * Helpers functions.
@@ -59,7 +59,10 @@ const processFile = ( rootDir, inputFile ) => {
59
59
  const result = engine(
60
60
  relativePath,
61
61
  data,
62
- getIRFromRelativePath( rootDir, last( currentFileStack ) )
62
+ getIRFromRelativePath(
63
+ rootDir,
64
+ currentFileStack[ currentFileStack.length - 1 ]
65
+ )
63
66
  );
64
67
  currentFileStack.pop();
65
68
  return result;
@@ -119,7 +122,7 @@ module.exports = ( sourceFile, options ) => {
119
122
  // Process.
120
123
  const result = processFile( processDir, sourceFile );
121
124
  const filteredIR = result.ir.filter( ( symbol ) => {
122
- if ( isSymbolPrivate( symbol ) ) {
125
+ if ( isSymbolPrivate( symbol ) || isSymbolIgnore( symbol ) ) {
123
126
  return false;
124
127
  }
125
128
 
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Internal dependencies
3
+ */
4
+ const getSymbolTagsByName = require( './get-symbol-tags-by-name' );
5
+
6
+ /**
7
+ * Returns true if, given a symbol object, it contains a @ignore tag, or false
8
+ * otherwise.
9
+ *
10
+ * @param {Object} symbol Symbol object.
11
+ *
12
+ * @return {boolean} Whether symbol is private.
13
+ */
14
+ const isSymbolIgnore = ( symbol ) =>
15
+ getSymbolTagsByName( symbol, 'ignore' ).length > 0;
16
+
17
+ module.exports = isSymbolIgnore;
@@ -1,14 +1,8 @@
1
- /**
2
- * External dependencies
3
- */
4
- const { findLast } = require( 'lodash' );
5
-
6
1
  const getHeadingIndex = ( ast, index ) => {
7
2
  const astBeforeIndex = ast.children.slice( 0, index );
8
- const lastHeading = findLast(
9
- astBeforeIndex,
10
- ( node ) => node.type === 'heading'
11
- );
3
+ const lastHeading = astBeforeIndex
4
+ .reverse()
5
+ .find( ( node ) => node.type === 'heading' );
12
6
  return lastHeading ? lastHeading.depth : 1;
13
7
  };
14
8
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/docgen",
3
- "version": "1.22.0",
3
+ "version": "1.24.1-next.d6164808d3.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": "48d5f37dfb52d2e77c8eeb662f9874cf141b8c6b"
41
+ "gitHead": "ba8a396d2f418e53a6c4c50575582f3f3eb11ff7"
43
42
  }