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

incompatible with entryPointStrategy "packages"? #23

Closed
boneskull opened this issue Dec 28, 2023 · 6 comments
Closed

incompatible with entryPointStrategy "packages"? #23

boneskull opened this issue Dec 28, 2023 · 6 comments

Comments

@boneskull
Copy link

boneskull commented Dec 28, 2023

Describe the bug

...or possibly just incompatible with Typedoc v0.52.4.

This is two problems with likely a single root cause.

I have a monorepo with several workspaces, and I use the packages entryPointStrategy to create a single docs site from them. This works when typedoc is run from the command line (with or without typedoc-plugin-markdown@next).

However, this line will always throw an exception with this use case:

if (!reflections?.groups || reflections.groups.length === 0) {

This is likely due to a breaking change in how Typedoc creates ProjectReflection files, but I don't know if that's due to the breaking changes in how the packages entryPointStrategy works, or for some other reason. In this use case, groups will always be undefined. I think what you want to get at is deeper in the ProjectReflection.

Once this conditional has been commented out, the plugin proceeds to generate the documentation and place it in the desired output directory. However, the sidebar appears empty (I'm guessing because groups is undefined).

To Reproduce

My setup involves a root typedoc config with entryPointStrategy: 'packages', where the entryPoints are relative paths to workspace folders. Each workspace then has its own Typedoc config containing an entryPoint and any other specific configuration.

The configuration for this plugin I'm using is akin to this:

starlightTypeDoc({
  entryPoints: [
    '../workspace-a',
    '../workspace-b',
    '../workspace-c',
  ],
  typeDoc: {
    entryPointStrategy: 'packages'
  },
  tsconfig: '../../tsconfig.json',
})

These workspaces live in a packages/ folder, and my Astro config is in packages/docs/astro.config.mjs (thus the relative paths).

Expected behavior

I'm not sure what I'd expect, exactly. Certainly, I want the sidebar to display something. It might mean extra nesting in the sidebar? Ideally, I'd have some control over how I wanted to arrange things without the need to override a component. Maybe pass in some option to a sidebar configurator which tells it which project to display; I could repeat this for each project.

How often does this bug happen?

Every time

System Info

  • macOS v14.1.1
  • Node.js v20.10.0
  • Astro v4.0.6
  • @astrojs/starlight v0.15.1
  • starlight-typedoc v0.7.0

Additional Context

No response

@boneskull
Copy link
Author

boneskull commented Dec 28, 2023

tangentially related: it's unclear how my existing typedoc config files affect the behavior of this plugin. I can confirm they are being read.

@HiDeoo
Copy link
Owner

HiDeoo commented Jan 2, 2024

Finally got the time to start working on this. The changes require a bit of refactoring to get the proper fixtures in place for this setup but I've managed to reproduce the issue and I seem to have a working prototype adding support for this.

With the following project structure:

project
├── package.json
├── packages
│   ├── bar
│   │   ├── package.json
│   │   ├── src
│   │   │   ├── ...
│   │   │   └── ...
│   │   ├── tsconfig.json
│   │   └── typedoc.json
│   └── foo
│   │   ├── package.json
│   │   ├── src
│   │   │   ├── ...
│   │   │   └── ...
│   │   ├── tsconfig.json
│   │   └── typedoc.json
├── tsconfig.base.json
└── tsconfig.json

And a plugin configuration like this:

{
  "entryPoints": ["../fixtures/project/packages/*"],
  "tsconfig": "../fixtures/project/tsconfig.json",
  "typeDoc": {
    "entryPointStrategy": "packages"
  }
}

I would now get the proper sidebar generated and all links working as expected.

image

This still requires a bit of work (mostly adding new tests for this), but before going further, as this is not a setup I use myself, I was wondering if your project was available somewhere publicly so I could test this on a real world example?

@boneskull
Copy link
Author

I'll make a branch for you.

boneskull added a commit to boneskull/midnight-smoker that referenced this issue Jan 3, 2024
This is currently broken due to HiDeoo/starlight-typedoc#23

To run example:

1. Clone repo
2. Checkout this branch (`boneskull/starlight-typedoc`)
3. Run `npm install`
4. Run `npm run dev:docs`

This should fail without any obvious error; this is because of the check for `groups` in `starlight-typedoc`.

You can also run `npm exec typedoc` from the workspace root to see that the problem is unique to `starlight-typedoc`.
@boneskull
Copy link
Author

OK, see this PR.

Also, if you want to push your code somewhere, I can try it myself.

boneskull added a commit to boneskull/midnight-smoker that referenced this issue Jan 3, 2024
This is currently broken due to HiDeoo/starlight-typedoc#23

To run example:

1. Clone repo
2. Checkout this branch (`boneskull/starlight-typedoc`)
3. Run `npm install`
4. Run `npm run dev:docs`

This should fail without any obvious error; this is because of the check for `groups` in `starlight-typedoc`.

You can also run `npm exec typedoc` from the workspace root to see that the problem is unique to `starlight-typedoc`.
@HiDeoo
Copy link
Owner

HiDeoo commented Jan 3, 2024

Thanks a lot, that was super helpful 🙌

The sidebar is now properly generating with the new changes:

image

Also, if you want to push your code somewhere, I can try it myself.

Sure, I've pushed a draft PR in #24

boneskull added a commit to boneskull/midnight-smoker that referenced this issue Jan 3, 2024
This is currently broken due to HiDeoo/starlight-typedoc#23

To run example:

1. Clone repo
2. Checkout this branch (`boneskull/starlight-typedoc`)
3. Run `npm install`
4. Run `npm run dev:docs`

This should fail without any obvious error; this is because of the check for `groups` in `starlight-typedoc`.

You can also run `npm exec typedoc` from the workspace root to see that the problem is unique to `starlight-typedoc`.
@HiDeoo
Copy link
Owner

HiDeoo commented Jan 5, 2024

Fixed with #24 that should be released relatively soon.

@HiDeoo HiDeoo closed this as completed Jan 5, 2024
boneskull added a commit to boneskull/midnight-smoker that referenced this issue Jan 9, 2024
This is currently broken due to HiDeoo/starlight-typedoc#23

To run example:

1. Clone repo
2. Checkout this branch (`boneskull/starlight-typedoc`)
3. Run `npm install`
4. Run `npm run dev:docs`

This should fail without any obvious error; this is because of the check for `groups` in `starlight-typedoc`.

You can also run `npm exec typedoc` from the workspace root to see that the problem is unique to `starlight-typedoc`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants