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

Error: unable to determine assembly since module does not have any types #1104

Open
dvonessen opened this issue Aug 13, 2023 · 6 comments
Open
Labels
bug This issue is a bug. needs-reproduction This issue needs reproduction. p2

Comments

@dvonessen
Copy link

Hi,
I have a problem with generating API documentation with jsii-docgen for the python library.
Given module layout:

src/
  core/several_files.ts
  addons/
    aws/
      index.ts
    index.ts
  index.ts

The following problem happens as soon as I add a named export on the second level of the library.

# This works!
src/index.ts
export * from "./core"
export * as addons from "./addons"
# As soon as adding follwoing to the src/addons/index.ts
export * as aws from "./aws"

Error message:

 npx projen && npx projen compile && npx projen package-all && rm -f docs/api/api.*.md && npx projen docs:api
👾 default | ts-node --project tsconfig.dev.json .projenrc.ts
👾 Installing dependencies...
👾 install | yarn install --check-files
yarn install v1.22.19
[1/5] 🔍  Validating package.json...
[2/5] 🔍  Resolving packages...
success Already up-to-date.
✨  Done in 2.77s.
👾 Installing dependencies...
👾 install | yarn install --check-files
yarn install v1.22.19
[1/5] 🔍  Validating package.json...
[2/5] 🔍  Resolving packages...
success Already up-to-date.
✨  Done in 3.45s.
👾 compile | jsii --silence-warnings=reserved-word
👾 package-all » package:js | jsii-pacmak -v --target js
[jsii-pacmak] [INFO] Found 1 modules to package
[jsii-pacmak] [INFO] Packaging NPM bundles
[jsii-pacmak] [INFO] Loading jsii assemblies and translations
[jsii-pacmak] [INFO] Packaging 'js' for @gcix/gcix
[jsii-pacmak] [INFO] js finished
[jsii-pacmak] [INFO] Packaged. npm pack (37.2s) | js (0.1s) | load jsii (0.0s) | cleanup (0.0s)
👾 package-all » package:python | jsii-pacmak -v --target python
[jsii-pacmak] [INFO] Found 1 modules to package
[jsii-pacmak] [INFO] Packaging NPM bundles
[jsii-pacmak] [INFO] Loading jsii assemblies and translations
[jsii-pacmak] [INFO] Packaging 'python' for @gcix/gcix
[jsii-pacmak] [INFO] python finished
[jsii-pacmak] [INFO] Packaged. npm pack (34.2s) | python (20.5s) | load jsii (0.0s) | cleanup (0.0s)
👾 docs:api » compile | jsii --silence-warnings=reserved-word
👾 docs:api | npx jsii-docgen -l typescript -l python --readme false --output ./docs/api/api
Error: unable to determine assembly since module does not have any types: @gcix/gcix.addons
    at PythonTranspile.getParentModule (/Users/danielvonessen/git/gitlab/dvonessen/gcix/node_modules/jsii-docgen/lib/docgen/transpile/transpile.js:393:19)
    at PythonTranspile.moduleLike (/Users/danielvonessen/git/gitlab/dvonessen/gcix/node_modules/jsii-docgen/lib/docgen/transpile/python.js:240:35)
    at PythonTranspile.type (/Users/danielvonessen/git/gitlab/dvonessen/gcix/node_modules/jsii-docgen/lib/docgen/transpile/python.js:219:33)
    at /Users/danielvonessen/git/gitlab/dvonessen/gcix/node_modules/jsii-docgen/lib/docgen/view/interface.js:16:81
    at Array.map (<anonymous>)
    at new Interface (/Users/danielvonessen/git/gitlab/dvonessen/gcix/node_modules/jsii-docgen/lib/docgen/view/interface.js:16:57)
    at /Users/danielvonessen/git/gitlab/dvonessen/gcix/node_modules/jsii-docgen/lib/docgen/view/interfaces.js:9:25
    at Array.map (<anonymous>)
    at new Interfaces (/Users/danielvonessen/git/gitlab/dvonessen/gcix/node_modules/jsii-docgen/lib/docgen/view/interfaces.js:9:14)
    at new ApiReference (/Users/danielvonessen/git/gitlab/dvonessen/gcix/node_modules/jsii-docgen/lib/docgen/view/api-reference.js:30:27)
👾 Task "docs:api" failed when executing "npx jsii-docgen -l typescript -l python --readme false --output ./docs/api/api" (cwd: /Users/USERNAME/git/gitlab/USERNAME/gcix)

The repo can be found at https://gitlab.com/gcix/gcix.

@mrgrain mrgrain added the bug This issue is a bug. label Jan 9, 2024
@antoniordz96
Copy link

One thing to note this only seems to be when generating api documentation for other languages other than typescript.

@mrgrain mrgrain added p2 needs-reproduction This issue needs reproduction. labels Jun 10, 2024
@mrgrain
Copy link
Contributor

mrgrain commented Jun 10, 2024

@gcix/gcix.addons needs to be a jsii library as well or it's identified wrongly as needing to be one.

@TimothyJones
Copy link
Contributor

I've also run into this, but with java.

The command:

npx jsii-docgen -f json -l java

in my publicly available jsii project @contract-case/case-definition-dsl, produces the following error:

Error: unable to determine assembly since module does not have any types: @contract-case/case-definition-dsl.mocks
    at JavaTranspile.getParentModule (/Users/home/office/contract-case/contract-case/node_modules/jsii-docgen/lib/docgen/transpile/transpile.js:394:19)
    at JavaTranspile.moduleLike (/Users/home/office/contract-case/contract-case/node_modules/jsii-docgen/lib/docgen/transpile/java.js:78:33)
    at JavaTranspile.type (/Users/home/office/contract-case/contract-case/node_modules/jsii-docgen/lib/docgen/transpile/java.js:96:33)

@contract-case/case-definition-dsl.mocks is a submodule of my jsii project. It only re-exports other types though - perhaps that's the problem?

@mrgrain
Copy link
Contributor

mrgrain commented Oct 8, 2024

in my publicly available jsii project @contract-case/case-definition-dsl, produces the following error:

This seems to be because the submodule @contract-case/case-definition-dsl.mocks doesn't define any types on it's own. It's just a wrapper around some other submodules. Definitely a bug.

@dverdonschot
Copy link

I am facing the same issue. jsii-docgen fails when creating python documentation because one of my index.ts files only exports submodules, and doesn't have any types.
I tried manually adding a type, but have not been successful so far.

jsii-docgen --split-by-submodule -l python -o ./docs/API_documentation/Python/API.md
Error: unable to determine assembly since module does not have any types: @library/custom-cdk-constructs.cloud_products
    at PythonTranspile.getParentModule (/usr/local/lib/node_modules/jsii-docgen/lib/docgen/transpile/transpile.js:394:19)
    at PythonTranspile.moduleLike (/usr/local/lib/node_modules/jsii-docgen/lib/docgen/transpile/python.js:244:35)
    at PythonTranspile.type (/usr/local/lib/node_modules/jsii-docgen/lib/docgen/transpile/python.js:223:33)
    at PythonTranspile.callable (/usr/local/lib/node_modules/jsii-docgen/lib/docgen/transpile/python.js:185:27)
    at new Initializer (/usr/local/lib/node_modules/jsii-docgen/lib/docgen/view/initializer.js:9:37)
    at new Class (/usr/local/lib/node_modules/jsii-docgen/lib/docgen/view/class.js:24:32)
    at new Construct (/usr/local/lib/node_modules/jsii-docgen/lib/docgen/view/construct.js:7:26)
    at /usr/local/lib/node_modules/jsii-docgen/lib/docgen/view/constructs.js:10:25
    at Array.map (<anonymous>)
    at new Constructs (/usr/local/lib/node_modules/jsii-docgen/lib/docgen/view/constructs.js:10:14)

@TimothyJones
Copy link
Contributor

I was able to generate java documentation with the following workaround type (note that you'll need to run jsii again before jsii-docgen, or it won't know you've changed anything)

/**
 * Empty class to make jsii-docgen happy with this module
 */
export class Empty {}

Unfortunately, if I annotate it @internal so that the documentation isn't generated, the error comes back - so it's not a great workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. needs-reproduction This issue needs reproduction. p2
Projects
None yet
Development

No branches or pull requests

5 participants