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

Entry point is not parsed correctly when entryPointStrategy is packages #2043

Closed
Losses opened this issue Aug 28, 2022 · 3 comments
Closed
Labels
bug Functionality does not match expectation

Comments

@Losses
Copy link

Losses commented Aug 28, 2022

Search terms

entryPointStrategy, packages

Expected Behavior

The package.json should be parsed correctly

Actual Behavior

An error appeared:

error Unable to find any entry points. Make sure TypeDoc can find your tsconfig

Steps to reproduce the bug

  1. My document is placed in packages/documents;
  2. Other packages are placed in packages/a, packages/b, packages/c;
  3. Entry point is setted to:
{
  entryPoints: ['../a', '../b', '../c']
}
  1. The package parsing call stack is:
    a. getEntryPointsForPackages , With the following code:
    const expandedPackages = expandPackages(
        logger,
        ".",
        packageGlobPaths,
        exclude
    );

The second parameter packageJsonDir is ., this may assume that the package we want to generate documentation for is a subdirectory of the current directory, but in some cases this assumption does not hold, the following call stack proofed this:

b. expandPackages: It is to trying to parse a glob pattern:

        const globbedPackageJsonPaths = glob(
            resolve(packageJsonDir, workspace, "package.json"),
            resolve(packageJsonDir)
        );

The first parameter of this glob is:

ROOT_PATH_OF_THE_PROJECT\packages\a\package.json

The second parameter of this glob is:

ROOT_PATH_OF_THE_PROJECT\packages\documents

The home-made glob function simply won't return anything, and caused the parsing work failed.

Environment

  • Typedoc version: typedoc@npm:0.23.11
  • TypeScript version: typescript@npm:4.6.4
  • Node.js version: v16.15.0
  • OS: Windows 11
@Losses Losses added the bug Functionality does not match expectation label Aug 28, 2022
@Gerrit0
Copy link
Collaborator

Gerrit0 commented Aug 28, 2022

The second parameter packageJsonDir is ., this may assume that the package we want to generate documentation for is a subdirectory of the current directory, but in some cases this assumption does not hold

Knew this would come bite me at some point... yep, that was an assumption that was made.

@xenobytezero
Copy link

Hi there,

I just came across this issue and think I'm missing something about how its being used.

In my monorepo I have my docs generation in a package as well as the source I'm documenting, and feel like I have a setup similar to above

packages/docs/docs-build
packages/framework/common
packages/support/lib1
packages/support/lib2
{
  entryPointStrategy: 'packages',
  entryPoints: [
    '../../framework/common-internal',
    '../../libraries/support-react',
    '../../libraries/support-angular',
  ]
}

I'm getting the following error when trying to build ( using Docusaurus, but the issue seems to be in Typedoc, see below

[ERROR] Error: ENOENT: no such file or directory, scandir 'C:/Projects/Project1/packages/docs/docs-build/Projects/UHSA/Cockpit/packages'
    at Object.readdirSync (node:fs:1380:3)
    at glob (C:\Projects\Project1\node_modules\.pnpm\typedoc@0.23.12_typescript@4.7.4\node_modules\typedoc\dist\lib\utils\fs.js:140:32)
    at C:\Projects\Project1\node_modules\.pnpm\typedoc@0.23.12_typescript@4.7.4\node_modules\typedoc\dist\lib\utils\package-manifest.js:89:55
    at Array.flatMap (<anonymous>)
    at expandPackages (C:\Projects\Project1\node_modules\.pnpm\typedoc@0.23.12_typescript@4.7.4\node_modules\typedoc\dist\lib\utils\package-manifest.js:88:23)
    at getEntryPointsForPackages (C:\Projects\Project1\node_modules\.pnpm\typedoc@0.23.12_typescript@4.7.4\node_modules\typedoc\dist\lib\utils\entry-point.js:216:68)
    at getEntryPoints (C:\Projects\Project1\node_modules\.pnpm\typedoc@0.23.12_typescript@4.7.4\node_modules\typedoc\dist\lib\utils\entry-point.js:45:22)
    at Application.getEntryPoints (C:\Projects\Project1\node_modules\.pnpm\typedoc@0.23.12_typescript@4.7.4\node_modules\typedoc\dist\lib\application.js:118:49)
    at Application.convert (C:\Projects\Project1\node_modules\.pnpm\typedoc@0.23.12_typescript@4.7.4\node_modules\typedoc\dist\lib\application.js:134:34)
    at Object.loadContent (C:\Projects\Project1\node_modules\.pnpm\docusaurus-plugin-typedoc@0.17.5_hllrrslxckewhjmudyghxy3nxi\node_modules\docusaurus-plugin-typedoc\dist\plugin.js:49:37)

It seems like whats happening is the information passed to expandPackages in getEntryPointsForPackages seems wrong?

In the example above, deriveRootDir() returns Projects/Project1/packages (no drive letter) and passes in my packageGlobPattern which has been fully resolved by the Typedoc options parsing, which results in the glob function being called with an incorrect root

glob(
"'C:\\Projects\\Project1\\packages\\framework\\common-internal\\package.json", 
"'C:\\Projects\\Project1\\packages\\docs\\docs-build\\Projects\\Project1\\packages'
", undefined)

This causes the glob function to explode as the root doesnt exist.

Am I missing something here?

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Sep 1, 2022

Well... that certainly doesn't look right.

@Gerrit0 Gerrit0 reopened this Sep 1, 2022
@Gerrit0 Gerrit0 closed this as completed in eb65e65 Sep 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Functionality does not match expectation
Projects
None yet
Development

No branches or pull requests

3 participants