|
1 | | -# Website |
| 1 | +# React Native ExecuTorch Documentation |
2 | 2 |
|
3 | | -This website is built using [Docusaurus 2](https://docusaurus.io/), a modern static website generator. |
| 3 | +This directory contains the source code for the documentation website of React Native ExecuTorch, built with [Docusaurus](https://docusaurus.io/). |
4 | 4 |
|
5 | | -### Installation |
| 5 | +## Getting Started |
6 | 6 |
|
7 | | -``` |
8 | | -$ yarn |
9 | | -``` |
| 7 | +### Prerequisites |
10 | 8 |
|
11 | | -### Local Development |
| 9 | +- Node.js (v20+) |
| 10 | +- Yarn |
12 | 11 |
|
13 | | -``` |
14 | | -$ yarn start |
| 12 | +### Installation |
| 13 | + |
| 14 | +Navigate to the `docs` directory and install dependencies: |
| 15 | + |
| 16 | +```bash |
| 17 | +cd docs |
| 18 | +yarn install |
15 | 19 | ``` |
16 | 20 |
|
17 | | -This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server. |
| 21 | +### Running Locally |
18 | 22 |
|
19 | | -### Build |
| 23 | +Start the development server. **Note:** This command automatically generates the API reference from the TypeScript source before starting the site. |
20 | 24 |
|
| 25 | +```bash |
| 26 | +yarn start |
21 | 27 | ``` |
22 | | -$ yarn build |
23 | | -``` |
| 28 | +The site will open at `http://localhost:3000/react-native-executorch/`. |
24 | 29 |
|
25 | | -This command generates static content into the `build` directory and can be served using any static contents hosting service. |
| 30 | +## Building |
| 31 | +To build the static files for production: |
| 32 | + |
| 33 | +```bash |
| 34 | +yarn build |
| 35 | +``` |
| 36 | +The output will be generated in the `build/` directory. |
26 | 37 |
|
27 | | -### Deployment |
| 38 | +## Deployment |
28 | 39 |
|
29 | 40 | Using SSH: |
30 | 41 |
|
31 | | -``` |
| 42 | +```bash |
32 | 43 | $ USE_SSH=true yarn deploy |
33 | 44 | ``` |
34 | 45 |
|
35 | 46 | Not using SSH: |
36 | 47 |
|
37 | | -``` |
| 48 | +```bash |
38 | 49 | $ GIT_USER=<Your GitHub username> yarn deploy |
39 | 50 | ``` |
40 | 51 |
|
41 | 52 | If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch. |
| 53 | + |
| 54 | +## How API Reference Generation Works |
| 55 | + |
| 56 | +We use `docusaurus-plugin-typedoc` to automatically generate documentation from the TypeScript source code. |
| 57 | + |
| 58 | +1. **Source:** The plugin reads `../packages/react-native-executorch/src/index.ts`. |
| 59 | + |
| 60 | +2. **Generation:** On `yarn start` or `yarn build`, it generates Markdown files into `docs/06-api-reference`. |
| 61 | + |
| 62 | +3. **Sidebar Integration:** Docusaurus strips the number prefix (`06-`) from URLs but requires the folder name for configuration. We use a specific sidebar setup to ensure breadcrumbs work while keeping the UI clean. |
| 63 | + |
| 64 | +### Sidebar Configuration (`sidebars.js`) |
| 65 | +The "API Reference" section is configured with specific settings to handle breadcrumbs correctly: |
| 66 | + |
| 67 | +- `collapsed: true`: Keeps the huge list of API files closed by default. |
| 68 | + |
| 69 | +- **`link` property**: Points to `api-reference/index`. This ensures clicking the text "API Reference" redirects to the Overview page. |
| 70 | + |
| 71 | +- **`items` array**: We nest the autogenerated items inside. This is **critical** because it creates the parent-child relationship needed for breadcrumbs (e.g., `Home > API Reference > LLMType`). |
| 72 | + |
| 73 | +### Troubleshooting Sidebar: |
| 74 | + |
| 75 | +If you change the folder structure, ensure `dirName` matches the physical folder (`06-api-reference`), but `id` uses the Docusaurus ID (`api-reference/index`). |
| 76 | + |
| 77 | +## Releasing & Versioning |
| 78 | + |
| 79 | +We use Docusaurus versioning to "freeze" documentation for older releases. |
| 80 | + |
| 81 | +### Creating a New Version |
| 82 | + |
| 83 | +When you release a new npm version (e.g., `1.0.0`), you must snapshot the documentation. Run this command from the `docs/` folder: |
| 84 | + |
| 85 | +```bash |
| 86 | +yarn docusaurus docs:version 1.0.0 |
| 87 | +``` |
| 88 | +### Why is this important? |
| 89 | + |
| 90 | +1. It copies the current contents of `docs/` (including the **currently generated API reference**) into `versioned_docs/version-1.0.0`. |
| 91 | +2. This ensures that if the TypeScript API changes in the future, the docs for v1.0.0 remain accurate to that version. |
| 92 | + |
| 93 | +### Working on "Next" |
| 94 | + |
| 95 | +Edit files in `docs/` as usual. These changes appear in the "Next" version of the site (the default view), reflecting the current `main` branch. |
| 96 | + |
| 97 | +## Troubleshooting |
| 98 | + |
| 99 | +### "Duplicate ID" Errors |
| 100 | +If you see build errors about duplicate IDs, it usually means an old generation artifact is conflicting with a new one. Run: |
| 101 | + |
| 102 | +```bash |
| 103 | +yarn clear |
| 104 | +``` |
| 105 | +This deletes the `.docusaurus` cache and `build` folder. |
| 106 | + |
| 107 | +### API Docs Not Updating |
| 108 | + |
| 109 | +TypeDoc runs strictly at startup. If you modify comments in the TypeScript package: |
| 110 | + |
| 111 | +1. Stop the server. |
| 112 | +2. Run `yarn start` again to regenerate the Markdown files. |
0 commit comments