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

Improve support for --entryPointStrategy Packages #1977

Merged
merged 4 commits into from Jul 7, 2022

Conversation

akphi
Copy link
Contributor

@akphi akphi commented Jul 2, 2022

This PR provides some improvements for users of --entryPointStrategy Packages. These includes:

  • Improved support for --entryPointStrategy Packages. TypeDoc will now load package-specific configurations from package.json typedoc field. This configuration allows configuring a custom display name (typedoc.displayName) field, entry point (typedoc.entryPoint - this is equivalent and will override typedocMain), and path to a readme file to be rendered at the top of the package page (typedoc.readmeFile), fixes Show README of packages in monorepo #1658
  • The --includeVersion option will now be respected by --entryPointStrategy Packages. Also, for this combination, missing version field in the root package.json will not issue a warning - this fix would be useful for folks who want to turn on --includeVersion and yet don't really want to put a version in the main package.json because it's not always meaningful to do so in a monorepo

This is the shape of the typedoc config (in the child-packages' package.json):

export interface TypedocPackageManifestConfig {
    entryPoint?: string | undefined;
    displayName?: string | undefined;
    readmeFile?: string | undefined;
}

I feel that having per-package config allows more flexibility.

This is a screenshot of my change (the README per module and the version per child package)

Screen.Recording.2022-07-02.at.2.51.40.PM.mov

Let me know what you think about these features!


UPDATED

I notice that when I develop locally, converter tests will likely fail due to the hardcoded url in the specs.json file. I suppose you don't mind since you run locally and push directly to the repo, for us who work on the fork, these tests will likely fail.

^ Thanks @Gerrit0 ! Works like charms now 🙏

@akphi akphi changed the title more typedoc option in package.json allow getting README for each package in monorepo Jul 2, 2022
@Gerrit0
Copy link
Collaborator

Gerrit0 commented Jul 2, 2022

due to the hardcoded url in the specs.json

Shoot, didn't think about that when adding url to the serialized JSON... that's something I should fix.

Edit: Fixed! If you update your fork, shouldn't have that issue anymore.

Gerrit0 added a commit that referenced this pull request Jul 2, 2022
@akphi akphi changed the title allow getting README for each package in monorepo Improve support for --entryPointStrategy Packages Jul 2, 2022
@akphi akphi marked this pull request as ready for review July 2, 2022 18:55
@akphi
Copy link
Contributor Author

akphi commented Jul 2, 2022

Also, I'm not so sure, if this is accepted, what's the best way to document this on the website. Is it gonne be through https://typedoc.org/guides/options/#entrypointstrategy ?

@akphi
Copy link
Contributor Author

akphi commented Jul 4, 2022

@Gerrit0 Do you have any comments on the approach I took for this PR?

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Jul 4, 2022

This is big enough I need to wait until I'm on a computer to really take a look at it. I'm not entirely sure I like adding another property to declaration reflections, but it might be a good temporary workaround until 0.24 when adding support for arbitrary markdown documents.... should be able to look at it Wednesday at the latest

@akphi
Copy link
Contributor Author

akphi commented Jul 4, 2022

This is big enough I need to wait until I'm on a computer to really take a look at it. I'm not entirely sure I like adding another property to declaration reflections, but it might be a good temporary workaround until 0.24 when adding support for arbitrary markdown documents.... should be able to look at it Wednesday at the latest

Yep, that was my worry as well, since I copied it from ProjectReflection, but I don't think we have a separate thing like PackageReflection yet. Anyway, glad I'm not totally off 😄

@Dayday10
Copy link

Dayday10 commented Jul 5, 2022

I need to know more about this ?

@Dayday10
Copy link

Dayday10 commented Jul 5, 2022 via email

src/lib/converter/plugins/PackagePlugin.ts Show resolved Hide resolved
src/lib/output/themes/default/partials/index.tsx Outdated Show resolved Hide resolved
src/lib/utils/entry-point.ts Outdated Show resolved Hide resolved
src/lib/utils/entry-point.ts Show resolved Hide resolved
src/lib/utils/package-manifest.ts Outdated Show resolved Hide resolved
src/lib/utils/package-manifest.ts Show resolved Hide resolved
src/lib/utils/package-manifest.ts Outdated Show resolved Hide resolved
src/lib/models/reflections/declaration.ts Show resolved Hide resolved
@akphi
Copy link
Contributor Author

akphi commented Jul 6, 2022

@Gerrit0 I have addressed most of the PR comments, except for the ones related to displayName and version in entry-point.ts file, I want to hear your opinion about that approach so I could move forward.

@akphi
Copy link
Contributor Author

akphi commented Jul 6, 2022

To clear out the reviews comment while I work on them, I have taken the liberty to resolve some of them, I hope you're okay with this. I will unresolve them once I finish fixing the code 🙏

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Jul 7, 2022

I have taken the liberty to resolve some of them

Go right ahead :) I always do a full pass before approving anyways, so this won't result in missing anything.

@akphi
Copy link
Contributor Author

akphi commented Jul 7, 2022

Addressed most comments except for the one about readmeFile.

You can see in the following screenshot, version will now be picked up and will show in the HTML, but not affect the output reflection name (hence the URL does not contain version)

Screen Shot 2022-07-06 at 9 37 12 PM

@akphi
Copy link
Contributor Author

akphi commented Jul 7, 2022

I believe we have resolved all the review comments. Thank you so much for your help and patience @Gerrit0 🙏 !

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Jul 7, 2022

Thank you! Almost all of the monorepo support in TypeDoc has come from someone who uses them adding support, so it's great to get PRs from people that use them

@Gerrit0 Gerrit0 merged commit 83a2735 into TypeStrong:master Jul 7, 2022
@akphi akphi deleted the newish branch July 7, 2022 23:24
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

Successfully merging this pull request may close these issues.

Show README of packages in monorepo
3 participants