-
Notifications
You must be signed in to change notification settings - Fork 1.3k
chore: improve API docs structure with dedicated index.md files #10472
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -178,17 +178,20 @@ export default withPwa( | |
| { | ||
| text: 'API Docs', | ||
| collapsed: true, | ||
| // link: '/api/', | ||
| // Ensures that this sidebar item is active when you load /api/ or any of its sub-pages | ||
| link: '/api/', | ||
| items: [ | ||
| { text: 'Universal' }, | ||
| { text: 'Universal Packages' }, | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A bit more clear, plus a closer match to what shows up on |
||
| ...TypeDocSidebar.corePackages.items, | ||
| { text: 'Frameworks' }, | ||
| { text: 'Framework Packages' }, | ||
| ...TypeDocSidebar.frameworkPackages.items, | ||
| ], | ||
| }, | ||
| { | ||
| text: 'Legacy Packages', | ||
| text: 'Legacy API Docs', | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I toyed w/ moving this under
|
||
| collapsed: true, | ||
| // If you uncomment this, it makes the Legacy API Docs sidebar state mirror the API Docs sidebar state, | ||
| // which feels super weird. | ||
| // link: '/api/', | ||
| items: TypeDocSidebar.oldPackages, | ||
| }, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,7 @@ html:not(.dark) .dark-only { | |
| display: none !important; | ||
| } | ||
|
|
||
| .VPSidebarItem .level-1 > .item > p.text { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This selector wasn't working before. The |
||
| .VPSidebarItem.level-1 > .item > p.text { | ||
| font-weight: 600; | ||
| color: var(--vp-c-text-1); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -435,7 +435,7 @@ export async function postProcessApiDocs() { | |
| } | ||
|
|
||
| // generate the API documentation | ||
| const apiDocumentation = `${ApiDocumentation}\n\n## Main Packages\n\n${MainPackages.join('\n')}\n\n## Framework Packages\n\n${FrameworkPackages.join('\n')}\n\n## Legacy Packages\n\n${OldPackages.join('\n')}\n\n`; | ||
| const apiDocumentation = `${ApiDocumentation}\n\n## Universal Packages\n\n${MainPackages.join('\n')}\n\n## Framework Packages\n\n${FrameworkPackages.join('\n')}\n\n## Legacy Packages\n\n${OldPackages.join('\n')}\n\n`; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Making it match sidebar. |
||
|
|
||
| // copy the rest of the files | ||
| const files = globSync('**/*.md', { cwd: dir, nodir: true }); | ||
|
|
@@ -451,8 +451,9 @@ export async function postProcessApiDocs() { | |
|
|
||
| let newContent = content; | ||
|
|
||
| // if the file is in @warp-drive/legacy add the legacy badge | ||
| if (file.includes('@warp-drive/legacy')) { | ||
| // if the file is in a legacy package add the legacy badge | ||
| const isLegacyPackage = OLD_PACKAGES.some((pkg) => file.includes(pkg)) || file.includes('@warp-drive/legacy'); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. More little red badges for stuff you should avoid using in new projects. |
||
| if (isLegacyPackage) { | ||
| newContent = `<Badge type="danger" text="@legacy" /><br><br>` + content; | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,33 +3,27 @@ title: Documenting APIs | |
| order: 1 | ||
| --- | ||
|
|
||
| # Writing Documentation | ||
|
|
||
| There are two sources of documentation in this repository: | ||
|
|
||
| - [Guides](../../index.md) - markdown files that are compiled into the manual for the website | ||
| - inline code comments and types - from which the API Docs are compiled | ||
|
|
||
| Both are previewable by following the instructions in the [Docs Viewer](https://github.com/warp-drive-data/warp-drive/blob/main/docs-viewer/README.md) | ||
|
|
||
| Great documentation requires both guides and docs. We encourage updating any associated guides affected by code changes as you make them, and writing new guides when appropriate. | ||
| # Writing API Documentation | ||
|
|
||
| Our [API Docs](../../../api/) are compiled from inline code comments and types as well as `src/index.md` files. | ||
|
|
||
| ## API Documentation Infra Overview | ||
|
|
||
| API Documentation is generated from [TSDoc](https://tsdoc.org/) comments in the source code | ||
| compiled with [TypeDoc](https://typedoc.org/) and transformed for [Vitepress](https://vitepress.dev/) using [typedoc-plugin-markdown](https://www.typedoc-plugin-markdown.org/plugins/vitepress) | ||
|
|
||
| TSDoc syntax is similar to YUIDoc and JSDoc but there are occassional nuances where it becomes best to know the underlying grammar is TSDoc | ||
| TSDoc syntax is similar to YUIDoc and JSDoc but there are occasional nuances where it becomes best to know that the underlying grammar is TSDoc | ||
| and parser is TypeDoc. | ||
|
|
||
| TypeDoc is configured to follow our public package entrypoints to | ||
| auto-discover documentation. It documents everything reachable, public or private including properties and methods that have no associated | ||
| code docs. It uses typescript to understand the source-code and builds documentation from the combination of Type signatures and TSDoc comments. | ||
| code docs. It uses typescript to understand the source-code and builds documentation from the combination of Type signatures and TSDoc comments. This is great, but it means that its very easy to leak private APIs | ||
| into the docs. | ||
|
|
||
| This is great, but it means that its very easy to leak private APIs | ||
| into the docs. Use `/** @internal */` on things that should not be | ||
| ::: warning Avoid leaking private APIs into the public docs! | ||
| Use `/** @internal */` on things that should not be | ||
| put into the public docs. | ||
| ::: | ||
|
|
||
| While API Documentation lives with the source-code, the code itself plays no part in the documentation | ||
| that is generated: everything is compiled from comments alone. | ||
|
|
@@ -39,10 +33,6 @@ nuances and syntaxes to know, as well as how to test and preview the doc comment | |
|
|
||
| <br> | ||
|
|
||
| --- | ||
|
|
||
| <br> | ||
|
|
||
| ## Documentation Syntax | ||
|
|
||
| <br> | ||
|
|
@@ -129,7 +119,7 @@ for fellow developers that shouldn't be exposed to end consumers. | |
| /** | ||
| * This is a private utility for updating the state | ||
| * of a relationship. | ||
| * | ||
| * | ||
| * @internal | ||
| */ | ||
| function somethingInside() {} | ||
|
|
@@ -158,15 +148,15 @@ For instance | |
| ```ts | ||
| /** | ||
| * ## Overview | ||
| * | ||
| * | ||
| * Some details | ||
| * | ||
| * | ||
| * ### An Example | ||
| * | ||
| * | ||
| * ```ts | ||
| * new Store(); | ||
| * ``` | ||
| * | ||
| * | ||
| * @public | ||
| */ | ||
| ``` | ||
|
|
@@ -179,15 +169,15 @@ This means we can do code examples that toggle between files or formats. | |
| ```ts | ||
| /** | ||
| * ::: code-group | ||
| * | ||
| * | ||
| * ```ts [example.ts] | ||
| * export function numberFromStrong(str: string): number {} | ||
| * ``` | ||
| * | ||
| * | ||
| * ```js [example.js] | ||
| * export function numberFromStrong(str) {} | ||
| * ``` | ||
| * | ||
| * | ||
| * ::: | ||
| */ | ||
| ``` | ||
|
|
@@ -210,17 +200,17 @@ and some documentation may be unexpectedly truncated. | |
| ```ts | ||
| /** | ||
| * ## Overview | ||
| * | ||
| * | ||
| * Some details | ||
| * | ||
| * | ||
| * ### An Example | ||
| * | ||
| * | ||
| * ```ts | ||
| * class User extends Model { | ||
| * @attr name; | ||
| * } | ||
| * ``` | ||
| * | ||
| * | ||
| * @public | ||
| */ | ||
| ``` | ||
|
|
@@ -230,17 +220,17 @@ and some documentation may be unexpectedly truncated. | |
| ```ts | ||
| /** | ||
| ## Overview | ||
|
|
||
| Some details | ||
|
|
||
| ### An Example | ||
|
|
||
| \```ts | ||
| class User extends Model { | ||
| @attr name; | ||
| } | ||
| \``` | ||
|
|
||
| @public | ||
| */ | ||
| ``` | ||
|
|
@@ -256,16 +246,13 @@ we would do the following in `packages/core-types/src/index.ts` | |
| /** | ||
| * This package provides essential types and symbols used | ||
| * by all the other WarpDrive packages. | ||
| * | ||
| * | ||
| * @module | ||
| */ | ||
| ``` | ||
|
|
||
| <br> | ||
|
|
||
| ### Always specify `@since` on non-type public APIs | ||
|
|
||
|
|
||
| ```ts | ||
| /** | ||
| * @since 1.13.0 | ||
|
|
@@ -295,20 +282,14 @@ be used to give a meaningful description only. | |
| ```ts | ||
| /** | ||
| * Adds two numbers | ||
| * | ||
| * | ||
| * @param a - the first number to add | ||
| * @param b - the second number to add | ||
| * @return the sum of the two numbers | ||
| */ | ||
| function add(a: number, b: number): number {} | ||
| ``` | ||
|
|
||
| <br> | ||
|
|
||
| --- | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry. these gaps looked weird |
||
|
|
||
| <br> | ||
|
|
||
| ## Documentation Hygiene | ||
|
|
||
| <br> | ||
|
|
@@ -342,7 +323,7 @@ From inside the `docs-viewer` directory | |
| > migrate to tsdoc and typedoc. Once the migration is nearing | ||
| > completion we will create a transform to restore these docs. | ||
|
|
||
| Run `bun preview-api-docs` from the project root or the `docs-viewer` directory. | ||
| Run `bun preview-api-docs` from the project root or the `docs-viewer` directory. | ||
|
|
||
| This will build and run the (external) api-docs app with the current state of the api docs in the repo. | ||
|
|
||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ^ this is the secret sauce for not having the index ones show up |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,5 @@ | ||
| /** | ||
| * @module | ||
| * @mergeModuleWith <project> | ||
| */ | ||
| export { Adapter as default, BuildURLMixin } from '@warp-drive/legacy/adapter'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes it so that when you when you click the API Docs link (to
/api/) from the homepage, the API Docs section of the sidebar is active and expanded.