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

feat: add better documentation features and convert from Rust repo #612

Merged
merged 77 commits into from
Dec 1, 2022

Conversation

camsjams
Copy link
Contributor

Closes #548

How to view these updated docs

1. Basic Viev

Browse the repo on GitHub or local using the markdown files

2. Recommended View

Browse the docs using Jekyll (bundle exec jekyll serve) to see how they will appear on GitHub when deployed, which matches current docs here

Notable features

The docs will always report what versions of Fuels/Sway/Fuel Core they were built with:
image

New Guide section:
image

Embedded code using real code from library and unit tests:
image

Notes

Copy link
Member

@digorithm digorithm left a comment

Choose a reason for hiding this comment

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

Alright y'all, let's get this out.

It's looking pretty solid; lots to improve but we got most of it good enough for a first release.

@digorithm digorithm merged commit 03b060b into master Dec 1, 2022
@digorithm digorithm deleted the cm/issue-548 branch December 1, 2022 18:30
@camsjams
Copy link
Contributor Author

camsjams commented Dec 15, 2022

There are two parts to the fuels-ts repository documentation

Part One: Typedoc

typedoc 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.

Furthermore, I've enhanced typedoc to also build out the Guide documentation with a custom plugin called typedoc-plugin-guide-builder that's in our repo here (We should move this to a standalone plugin later on). This portion of the typedoc process takes source files from docs/_guide, runs them through the plugins and renders code snippets pulled from source code.

How does the typedoc-plugin-guide-builder plugin work?

See how this markdown document refers to Sway and TypeScript code (also note the language hints like [@code:rust], and then see how reference in the TypeScript code is written

It writes the final results to docs/guide.

Intermission: Repo

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.

Part Two: Jekyll

jekyll 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. We shall see, but GitHub pages uses Jekyll so its the easy choice for now.

Anyways, Jekyll is configured with the just the docs theme (actually a modified version of it found here within Fuels org). The only interesting thing to point out here is also that we update this file _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.

Finale: CI

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 that calls pnpm changeset:version-with-docs which runs this script to rebuild docs and commit them into the repo (see sample commit here) as part of the final update PR.

TLDR: Local docs development

1. The one-time local setup for the custom plugin typedoc-plugin-guide-builder is to compile the Typescript, do

# start in root of project
cd ./scripts/typedoc-plugin-guide-builder
tsc

2. Next, you'll want to rebuild the generated typedoc files (see Part One above to understand why)

# start in root of project
pnpm typedoc

# if you plan to make a lot of updates, use `watch`
pnpm typedoc --watch

3. Finally, if you want to see how the docs will appear fully rendered as they do on the docs website, you will need to run Jekyll (see Part Two above to understand why). Setup Jekyll here if you haven't already.

# start in root of project
cd docs

# this will automatically `watch`, note that the initial build and "updates" can take several seconds/minutes
bundle exec jekyll serve

@camsjams camsjams mentioned this pull request Dec 15, 2022
@danielbate danielbate mentioned this pull request Mar 4, 2024
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Requests pertinent to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make documentation more granular (similar to the Fuel Rust SDK book)
5 participants