Skip to content

Commit 79797d6

Browse files
Cameron Manaviandigorithm
andauthored
feat: doc about docs (#676)
* add cs * add doc meta guide for local dev * Update docs/_guide/local-docs.md Co-authored-by: Rodrigo Araújo <[email protected]> Co-authored-by: Rodrigo Araújo <[email protected]>
1 parent 0c85537 commit 79797d6

File tree

3 files changed

+104
-0
lines changed

3 files changed

+104
-0
lines changed

.changeset/red-rockets-glare.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"fuels": patch
3+
---
4+
5+
update docs

docs/_guide/local-docs.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
There are two parts to the fuels-ts repository documentation
2+
3+
## Part One: Typedoc
4+
[typedoc](https://typedoc.org/) gathers all types, functions, classes, etc., from our source code. It will read through the `packages` folder, collect all that information, and convert it into a markdown file, modifying the contents of [`docs/packages`](https://github.com/FuelLabs/fuels-ts/tree/master/docs/packages).
5+
6+
7+
Furthermore, I've enhanced typedoc to also build out the [Guide documentation](https://fuellabs.github.io/fuels-ts/guide/) with a custom plugin called `typedoc-plugin-guide-builder` that's in our [repo here](https://github.com/FuelLabs/fuels-ts/tree/master/scripts/typedoc-plugin-guide-builder) (We should move this to a standalone plugin later on). This portion of the typedoc process takes source files from [`docs/_guide`](https://github.com/FuelLabs/fuels-ts/tree/master/docs/_guide), runs them through the plugins and renders code snippets pulled from source code.
8+
9+
#### How does the `typedoc-plugin-guide-builder` plugin work?
10+
See how this markdown document refers to [Sway](https://github.com/FuelLabs/fuels-ts/blob/master/docs/_guide/testing/testing-with-jest.md?plain=1#L6) and [TypeScript](https://github.com/FuelLabs/fuels-ts/blob/master/docs/_guide/testing/testing-with-jest.md?plain=1#L9) code (also note the language hints like `[@code:rust]`, and then see how [reference in the TypeScript code](https://github.com/FuelLabs/fuels-ts/blob/master/packages/example-contract/src/example-contract.test.ts#L1) is written
11+
12+
It writes the final results to [`docs/guide`](https://github.com/FuelLabs/fuels-ts/tree/master/docs/guide).
13+
14+
### Intermission: Repo
15+
Once typedoc is done generating the markdown docs, the data inside `docs/packages` and `docs/guide` are highly useful. These are complete docs that are checked into the repo and can be found alongside the code for TS-SDK consumers. **One could view and use them just fine inside GitHub file browser or locally within their own filesystem.**
16+
17+
## Part Two: Jekyll
18+
[jekyll](https://jekyllrb.com/) does the work of rendering the docs in markdown into something the browser understands: HTML. There are currently some [open issues to possibly switch off Jekyll](https://github.com/FuelLabs/fuels-ts/issues/457). We shall see, but [GitHub pages uses Jekyll](https://docs.github.com/en/pages/setting-up-a-github-pages-site-with-jekyll) so its the easy choice for now.
19+
20+
Anyways, Jekyll is configured with the [just the docs](https://github.com/just-the-docs/just-the-docs) theme (actually a modified version of it [found here within Fuels org](https://github.com/FuelLabs/typedoc-just-the-docs-theme)). The only interesting thing to point out here is also that we [update this file _data/versions.yml](https://github.com/FuelLabs/fuels-ts/blob/master/docs/_data/versions.yml) on each successful build to master, so that the versions rendered in the docs are accurate relative to the repo's versions.
21+
22+
## Finale: CI
23+
Our build tools in CI automatically update the docs inside the repo after a successful new build hits the `master` branch. This is accomplished by the [GitHub action](https://github.com/FuelLabs/fuels-ts/blob/master/.github/workflows/release.yaml#L48) that calls `pnpm changeset:version-with-docs` which runs [this script to rebuild docs and commit](https://github.com/FuelLabs/fuels-ts/blob/master/scripts/changeset-version-with-docs.ts) them into the repo (see[ sample commit here](https://github.com/FuelLabs/fuels-ts/pull/669/commits/8fc3bb1eea57e73139965cf32f36b24537df4906)) as part of the [final update PR](https://github.com/FuelLabs/fuels-ts/pull/669).
24+
25+
## TLDR: Local docs development
26+
#### 1. The one-time local setup for the custom plugin `typedoc-plugin-guide-builder` is to compile the Typescript, do
27+
```bash
28+
# start in root of project
29+
cd ./scripts/typedoc-plugin-guide-builder
30+
tsc
31+
```
32+
33+
#### 2. Next, you'll want to rebuild the generated typedoc files (see Part One above to understand why)
34+
```bash
35+
# start in root of project
36+
pnpm typedoc
37+
38+
# if you plan to make a lot of updates, use `watch`
39+
pnpm typedoc --watch
40+
```
41+
42+
#### 3. Finally, if you want to see how the docs will appear fully rendered as they do [on the docs website](https://fuellabs.github.io/fuels-ts/), you will need to run Jekyll (see Part Two above to understand why). [Setup Jekyll here](https://jekyllrb.com/docs/) if you haven't already.
43+
```bash
44+
# start in root of project
45+
cd docs
46+
47+
# this will automatically `watch`, note that the initial build and "updates" can take several seconds/minutes
48+
bundle exec jekyll serve
49+
```

docs/guide/local-docs.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Local Docs
2+
3+
There are two parts to the fuels-ts repository documentation
4+
5+
## Part One: Typedoc
6+
[typedoc](https://typedoc.org/) does the work of gathering all types, functions, classes, etc. from all of our source code. It will read through the `packages` folder and collect all that information and convert it into a markdown file, modifying the contents of [`docs/packages`](https://github.com/FuelLabs/fuels-ts/tree/master/docs/packages).
7+
8+
Furthermore, I've enhanced typedoc to also build out the [Guide documentation](https://fuellabs.github.io/fuels-ts/guide/) with a custom plugin called `typedoc-plugin-guide-builder` that's in our [repo here](https://github.com/FuelLabs/fuels-ts/tree/master/scripts/typedoc-plugin-guide-builder) (We should move this to a standalone plugin later on). This portion of the typedoc process takes source files from [`docs/_guide`](https://github.com/FuelLabs/fuels-ts/tree/master/docs/_guide), runs them through the plugins and renders code snippets pulled from source code.
9+
10+
#### How does the `typedoc-plugin-guide-builder` plugin work?
11+
See how this markdown document refers to [Sway](https://github.com/FuelLabs/fuels-ts/blob/master/docs/_guide/testing/testing-with-jest.md?plain=1#L6) and [TypeScript](https://github.com/FuelLabs/fuels-ts/blob/master/docs/_guide/testing/testing-with-jest.md?plain=1#L9) code (also note the language hints like `[@code:rust]`, and then see how [reference in the TypeScript code](https://github.com/FuelLabs/fuels-ts/blob/master/packages/example-contract/src/example-contract.test.ts#L1) is written
12+
13+
It writes the final results to [`docs/guide`](https://github.com/FuelLabs/fuels-ts/tree/master/docs/guide).
14+
15+
### Intermission: Repo
16+
Once typedoc is done generating the markdown docs, the data inside `docs/packages` and `docs/guide` are highly useful. These are complete docs that are checked into the repo and can be found alongside the code for TS-SDK consumers. **One could view and use them just fine inside GitHub file browser or locally within their own filesystem.**
17+
18+
## Part Two: Jekyll
19+
[jekyll](https://jekyllrb.com/) does the work of rendering the docs in markdown into something the browser understands: HTML. There are currently some [open issues to possibly switch off Jekyll](https://github.com/FuelLabs/fuels-ts/issues/457). We shall see, but [GitHub pages uses Jekyll](https://docs.github.com/en/pages/setting-up-a-github-pages-site-with-jekyll) so its the easy choice for now.
20+
21+
Anyways, Jekyll is configured with the [just the docs](https://github.com/just-the-docs/just-the-docs) theme (actually a modified version of it [found here within Fuels org](https://github.com/FuelLabs/typedoc-just-the-docs-theme)). The only interesting thing to point out here is also that we [update this file _data/versions.yml](https://github.com/FuelLabs/fuels-ts/blob/master/docs/_data/versions.yml) on each successful build to master, so that the versions rendered in the docs are accurate relative to the repo's versions.
22+
23+
## Finale: CI
24+
Our build tools in CI automatically update the docs inside the repo after a successful new build hits the `master` branch. This is accomplished by the [GitHub action](https://github.com/FuelLabs/fuels-ts/blob/master/.github/workflows/release.yaml#L48) that calls `pnpm changeset:version-with-docs` which runs [this script to rebuild docs and commit](https://github.com/FuelLabs/fuels-ts/blob/master/scripts/changeset-version-with-docs.ts) them into the repo (see[ sample commit here](https://github.com/FuelLabs/fuels-ts/pull/669/commits/8fc3bb1eea57e73139965cf32f36b24537df4906)) as part of the [final update PR](https://github.com/FuelLabs/fuels-ts/pull/669).
25+
26+
## TLDR: Local docs development
27+
#### 1. The one-time local setup for the custom plugin `typedoc-plugin-guide-builder` is to compile the Typescript, do
28+
```bash
29+
# start in root of project
30+
cd ./scripts/typedoc-plugin-guide-builder
31+
tsc
32+
```
33+
34+
#### 2. Next, you'll want to rebuild the generated typedoc files (see Part One above to understand why)
35+
```bash
36+
# start in root of project
37+
pnpm typedoc
38+
39+
# if you plan to make a lot of updates, use `watch`
40+
pnpm typedoc --watch
41+
```
42+
43+
#### 3. Finally, if you want to see how the docs will appear fully rendered as they do [on the docs website](https://fuellabs.github.io/fuels-ts/), you will need to run Jekyll (see Part Two above to understand why). [Setup Jekyll here](https://jekyllrb.com/docs/) if you haven't already.
44+
```bash
45+
# start in root of project
46+
cd docs
47+
48+
# this will automatically `watch`, note that the initial build and "updates" can take several seconds/minutes
49+
bundle exec jekyll serve
50+
```

0 commit comments

Comments
 (0)