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

docs: clean up types and add API docs site #320

Merged
merged 6 commits into from
Jun 21, 2024
Merged

docs: clean up types and add API docs site #320

merged 6 commits into from
Jun 21, 2024

Conversation

erickzhao
Copy link
Member

@erickzhao erickzhao commented May 31, 2024

This PR adds typedoc API documentation from our TypeScript types for the @electron/osx-sign package.

The module already had some pretty good API documentation available on the README.md, so the PR mostly moves the existing explanations around. This has the added bonus of providing better editor intellisense.

Goals:

  • Move API documentation from README.md to code.
  • Convert README.md examples from focusing on the legacy CLI to focusing on the JS API.
  • Leverage TSDoc directives whenever possible for better TypeScript intellisense experience.
  • Add missing information from the GitHub wiki into README.md (Closes Expand wiki #10)

Notes:

  • Our internal types are a bit messy, and typedoc works a lot better with TypeScript interfaces rather than types. For example, Omit<A, B> will not be expanded into its underlying properties and will show up as-is by default in typedoc.
  • To remedy the above problem, the @interface directive was added to a few types, and the core SignOptions and FlatOptions types were re-exported as interfaces that extends the underlying types.
  • This has the nice effect of hiding the mess of utility types for each set of options and makes the docs a lot more useable.

Preview from my fork of this repo: https://erickzhao.github.io/osx-sign/

@erickzhao erickzhao marked this pull request as ready for review June 4, 2024 19:53
@erickzhao erickzhao requested a review from a team as a code owner June 4, 2024 19:53
@erickzhao erickzhao changed the title docs: add typedoc API documentation website docs: clean up types and add API docs site Jun 4, 2024

/**
* @interface
* @internal
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@internal is a typedoc-specific directive used to hide this type from the generated documentation interface.

This is applied to most types in this file since end users don't need to know the implementation details of how we generate SignOptions and FlatOptions.

/**
* Options for codesigning a packaged `.app` bundle.
*/
export interface SignOptions extends _SignOptions {}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we prefer keeping this exported as a type, we can instead tag _SignOptions as an @interface.

The tradeoff here is that TypeDoc doesn't detect @interface properly for function signatures, so the doc output for signAsync() will not expand the parameters properly.

image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm in favor of exporting it as an interface if it means signAsync() will have correct params

@erickzhao
Copy link
Member Author

Note that this PR doesn't actually set up any publishing for the website. I figured that could go into a follow-up PR where we set a GH Action similar to how electron/packager does it.

/**
* Options for codesigning a packaged `.app` bundle.
*/
export interface SignOptions extends _SignOptions {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm in favor of exporting it as an interface if it means signAsync() will have correct params

@erickzhao erickzhao merged commit 47da049 into main Jun 21, 2024
4 checks passed
@erickzhao erickzhao deleted the docs/api-docs branch June 21, 2024 19:11
Copy link

🎉 This PR is included in version 1.3.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expand wiki
2 participants