-
Notifications
You must be signed in to change notification settings - Fork 0
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
WIP Add readme on API #33
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 | ||||
---|---|---|---|---|---|---|
|
@@ -2,9 +2,89 @@ | |||||
|
||||||
Utility for generating Astro pages from `TypeDoc`. | ||||||
|
||||||
## Usage | ||||||
|
||||||
### Basic example | ||||||
|
||||||
Minimal config: | ||||||
|
||||||
```js | ||||||
// astro.config.mjs | ||||||
|
||||||
import { defineConfig } from 'astro/config' | ||||||
import { dirname, resolve } from 'node:path' | ||||||
import { fileURLToPath } from 'node:url' | ||||||
|
||||||
import initAstroTypedoc from 'astro-typedoc' | ||||||
|
||||||
const __dirname = dirname(fileURLToPath(import.meta.url)) | ||||||
|
||||||
const astroTypedoc = await initAstroTypedoc({ | ||||||
baseUrl: '/docs/', | ||||||
entryPoints: [resolve(__dirname, 'path/to/entry/point.ts')], | ||||||
tsconfig: resolve(__dirname, 'path/to/tsconfig.json') | ||||||
}) | ||||||
|
||||||
const typedocProject = await astroTypedoc.getReflections() | ||||||
|
||||||
await astroTypedoc.generateDocs(typedocProject, 'src/pages/docs') | ||||||
await astroTypedoc.generateNavigationJSON( | ||||||
reflections, | ||||||
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 can’t find this variable definition |
||||||
resolve(__dirname, './src/') | ||||||
) | ||||||
|
||||||
// https://astro.build/config | ||||||
export default defineConfig({}) | ||||||
``` | ||||||
|
||||||
## API | ||||||
|
||||||
### `initAstroTypedoc({ baseUrl, entryPoints, tsconfig })` | ||||||
|
||||||
Creates `astroTypedoc` instance. Accepts config object as a parameter. | ||||||
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. It is not clear what is Something like this could be better:
|
||||||
|
||||||
#### `baseUrl` | ||||||
|
||||||
Defines the root path for generated documentation. | ||||||
`/docs/` means that documentation root is accessible on | ||||||
`example.com/docs/` | ||||||
|
||||||
#### `entryPoints` | ||||||
|
||||||
An array of paths to entry points of the project. | ||||||
|
||||||
#### `tsconfig` | ||||||
|
||||||
Path to `tsconfig.json` of the project, which code will be documented. | ||||||
|
||||||
### `astroTypedoc.getReflections` | ||||||
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. It is not clear how I can use this method. |
||||||
|
||||||
Returns [TypeDoc project reflection](https://typedoc.org/api/classes/Models.ProjectReflection.html) | ||||||
|
||||||
Project reflection contains information about types and serves as the basis for creating documentation. | ||||||
|
||||||
### `astroTypedoc.generateDocs(typedocProject, outputFolder)` | ||||||
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.
Suggested change
|
||||||
|
||||||
Generates documentation. | ||||||
|
||||||
### `astroTypedoc.generateNavigationJSON(typedocProject, outputFolder)` | ||||||
|
||||||
Generates JSON file which contains navigation tree for generated documentation. | ||||||
|
||||||
Sample: | ||||||
|
||||||
```json | ||||||
[ | ||||||
{ | ||||||
"title": "Atom", | ||||||
"url": "/docs/interfaces/interface.Atom" | ||||||
} | ||||||
] | ||||||
``` | ||||||
|
||||||
## Testing | ||||||
|
||||||
There are 3 subfolders is `test/` folder. | ||||||
There are 3 subfolders in `test/` folder. | ||||||
|
||||||
1. `types` - this is a stub TypeScript project, contains types, which are used for generating docs | ||||||
2. `website-types` - a sample site which is generated from `types/` publicly exported types | ||||||
|
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.
path/to/entry/
→my-library/index.ts
Maybe we should add
// Add path to your library here