Skip to content
This repository has been archived by the owner on Oct 30, 2023. It is now read-only.

Commit

Permalink
feat(docs): Reenable typedoc for aztec-rpc and aztec.js (#2452)
Browse files Browse the repository at this point in the history
Attempts another shot at
AztecProtocol/aztec-packages#2255, but this time
including a build script specific to Netlify. Includes aztec.js contract
and account modules, and expands some inline docs.


![image](https://github.com/AztecProtocol/aztec-packages/assets/429604/9bc9af0b-9d4c-44e3-ab9f-69b491a687c8)

Fixes #2044 
Fixes #2045
Fixes #2046 
Fixes #2415
  • Loading branch information
spalladino authored and ludamad committed Sep 26, 2023
1 parent 8f4201c commit cce49ce
Show file tree
Hide file tree
Showing 8 changed files with 209 additions and 11 deletions.
10 changes: 7 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
FROM node:18-alpine
RUN apk update
FROM 278380418400.dkr.ecr.eu-west-2.amazonaws.com/yarn-project-base AS builder

WORKDIR /usr/src

COPY . .

WORKDIR /usr/src/yarn-project

RUN yarn build

WORKDIR /usr/src/docs

RUN yarn && yarn build
RUN yarn && yarn build

1 change: 1 addition & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/apis
26 changes: 26 additions & 0 deletions docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,32 @@ const config = {
disableInDev: false,
},
],
[
"@spalladino/docusaurus-plugin-typedoc",
{
id: "apis/aztec-rpc",
entryPoints: ["../yarn-project/types/src/interfaces/aztec_rpc.ts"],
tsconfig: "../yarn-project/types/tsconfig.json",
entryPointStrategy: "expand",
out: "apis/aztec-rpc",
disableSources: true,
frontmatter: { sidebar_label: "Aztec RPC Server" },
},
],
[
"@spalladino/docusaurus-plugin-typedoc",
{
id: "apis/aztec-js",
entryPoints: [
"../yarn-project/aztec.js/src/contract/index.ts",
"../yarn-project/aztec.js/src/account/index.ts",
],
tsconfig: "../yarn-project/aztec.js/tsconfig.json",
entryPointStrategy: "resolve",
out: "apis/aztec-js",
disableSources: true,
},
],
// ["./src/plugins/plugin-embed-code", {}],
],
themeConfig:
Expand Down
18 changes: 11 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,20 @@
"private": true,
"scripts": {
"docusaurus": "docusaurus",
"start": "docusaurus start",
"start:dev": "concurrently \"yarn preprocess:dev\" \"docusaurus start --host 0.0.0.0\"",
"start:dev:local": "concurrently \"yarn preprocess:dev\" \"docusaurus start\"",
"build": "yarn preprocess && docusaurus build",
"start": "yarn preprocess && yarn typedoc && docusaurus start",
"start:dev": "concurrently \"yarn preprocess:dev\" \"yarn typedoc:dev\" \"sleep 2 && docusaurus start --host 0.0.0.0\"",
"start:dev:local": "concurrently \"yarn preprocess:dev\" \"yarn typedoc:dev\" \"sleep 2 && docusaurus start\"",
"build": "./scripts/build.sh",
"swizzle": "docusaurus swizzle",
"deploy": "docusaurus deploy",
"clear": "rm -rf 'processed-docs' 'processed-docs-cache' && docusaurus clear",
"clear": "rm -rf 'processed-docs' 'processed-docs-cache' docs/apis && docusaurus clear",
"serve": "docusaurus serve",
"preprocess": "yarn node ./src/preprocess/index.js",
"preprocess:dev": "nodemon --config nodemon.json ./src/preprocess/index.js",
"typedoc": "rm -rf docs/apis && docusaurus generate-typedoc && cp -a docs/apis processed-docs/",
"typedoc:dev": "nodemon -w ../yarn-project -e '*.js,*.ts,*.nr,*.md' --exec \"rm -rf docs/apis && yarn docusaurus generate-typedoc && cp -a docs/apis processed-docs/\"",
"write-translations": "docusaurus write-translations",
"write-heading-ids": "docusaurus write-heading-ids",
"update-specs": "./scripts/update_specs.sh"
"write-heading-ids": "docusaurus write-heading-ids"
},
"dependencies": {
"@docusaurus/core": "^2.4.1",
Expand All @@ -36,9 +37,12 @@
},
"devDependencies": {
"@docusaurus/module-type-aliases": "^2.4.1",
"@spalladino/docusaurus-plugin-typedoc": "^0.20.3",
"@tsconfig/docusaurus": "^1.0.5",
"concurrently": "^8.0.1",
"nodemon": "^3.0.1",
"typedoc": "^0.25.1",
"typedoc-plugin-markdown": "^3.16.0",
"typescript": "^4.7.2"
},
"browserslist": {
Expand Down
48 changes: 48 additions & 0 deletions scripts/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash
set -eo pipefail

# Helper function for building packages in yarn project
build_package() {
local package_name="$1"
local build_command="${2:-yarn build}"

echo "Building $package_name..."
(cd "yarn-project/$package_name" && $build_command)
}

# Build script. If run on Netlify, first it needs to compile all yarn-projects
# that are involved in typedoc in order to generate their type information.
if [ -n "$NETLIFY" ]; then
# Move to project root
cd ..
echo Working dir $(pwd)

# Make sure the latest tag is available for loading code snippets from it
LAST_TAG="aztec-packages-v$(jq -r '.["."]' .release-please-manifest.json)"
echo Fetching latest released tag $LAST_TAG...
git fetch origin refs/tags/$LAST_TAG:refs/tags/$LAST_TAG

# Tweak global tsconfig so we skip tests in all projects
echo Removing test files from tsconfig...
jq '. + { "exclude": ["**/*test.ts"] }' yarn-project/tsconfig.json > yarn-project/tsconfig.tmp.json
mv yarn-project/tsconfig.tmp.json yarn-project/tsconfig.json

# Install deps (maybe we can have netlify download these automatically so they get cached..?)
echo Installing yarn-project dependencies...
(cd yarn-project && yarn)

# Build the required projects for typedoc
build_package "aztec-rpc"
build_package "aztec.js" "yarn build:ts"

# Back to docs site
cd docs

# Install deps
echo Install docs deps...
yarn
fi

# Now build the docsite
echo Building docsite...
yarn preprocess && yarn typedoc && yarn docusaurus build
17 changes: 17 additions & 0 deletions sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,23 @@ const sidebars = {
"dev_docs/privacy/main",
"dev_docs/limitations/main",

{
label: "API Reference",
type: "category",
items: [
{
label: "Aztec RPC Server",
type: "doc",
id: "apis/aztec-rpc/interfaces/AztecRPC",
},
{
label: "Aztec.js",
type: "category",
items: [{ dirName: "apis/aztec-js", type: "autogenerated" }],
},
],
},

{
type: "html",
value: '<span class="sidebar-divider" />',
Expand Down
2 changes: 1 addition & 1 deletion src/preprocess/include_code.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ function readFile(filePath, tag) {
return childProcess.execSync(`git show ${tag}:${relPath}`).toString();
} catch (err) {
console.error(
`Error reading file ${relPath} from latest version. Falling back to current content.`
`Error reading file ${filePath} from latest version. Falling back to current content.`
);
}
}
Expand Down
98 changes: 98 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1875,6 +1875,11 @@
p-map "^4.0.0"
webpack-sources "^3.2.2"

"@spalladino/docusaurus-plugin-typedoc@^0.20.3":
version "0.20.3"
resolved "https://registry.yarnpkg.com/@spalladino/docusaurus-plugin-typedoc/-/docusaurus-plugin-typedoc-0.20.3.tgz#04e0f8db61b8328ab0b8d6d4bd43a59fb0cdbbdd"
integrity sha512-LufWGbOUbyztOgJY42UDeQ0bnpTqZBtdIL1duTaIMpNj1MM2N9F3QqQhmQY3J9SnqCnkMjZu13RnK/ninWbLLg==

"@svgr/babel-plugin-add-jsx-attribute@^6.5.1":
version "6.5.1"
resolved "https://registry.yarnpkg.com/@svgr/babel-plugin-add-jsx-attribute/-/babel-plugin-add-jsx-attribute-6.5.1.tgz#74a5d648bd0347bda99d82409d87b8ca80b9a1ba"
Expand Down Expand Up @@ -2531,6 +2536,11 @@ ansi-regex@^6.0.1:
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-6.0.1.tgz#3183e38fae9a65d7cb5e53945cd5897d0260a06a"
integrity sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==

ansi-sequence-parser@^1.1.0:
version "1.1.1"
resolved "https://registry.yarnpkg.com/ansi-sequence-parser/-/ansi-sequence-parser-1.1.1.tgz#e0aa1cdcbc8f8bb0b5bca625aac41f5f056973cf"
integrity sha512-vJXt3yiaUL4UU546s3rPXlsry/RnM730G1+HkpKE012AN0sx1eOrxSu95oKDIonskeLTijMgqWZ3uDEe3NFvyg==

ansi-styles@^3.2.1:
version "3.2.1"
resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d"
Expand Down Expand Up @@ -2802,6 +2812,13 @@ brace-expansion@^1.1.7:
balanced-match "^1.0.0"
concat-map "0.0.1"

brace-expansion@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-2.0.1.tgz#1edc459e0f0c548486ecf9fc99f2221364b9a0ae"
integrity sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==
dependencies:
balanced-match "^1.0.0"

braces@^3.0.2, braces@~3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107"
Expand Down Expand Up @@ -4693,6 +4710,18 @@ handle-thing@^2.0.0:
resolved "https://registry.yarnpkg.com/handle-thing/-/handle-thing-2.0.1.tgz#857f79ce359580c340d43081cc648970d0bb234e"
integrity sha512-9Qn4yBxelxoh2Ow62nP+Ka/kMnOXRi8BXnRaUwezLNhqelnN49xKz4F/dPP8OYLxLxq6JDtZb2i9XznUQbNPTg==

handlebars@^4.7.7:
version "4.7.8"
resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.7.8.tgz#41c42c18b1be2365439188c77c6afae71c0cd9e9"
integrity sha512-vafaFqs8MZkRrSX7sFVUdo3ap/eNiLnb4IakshzvP56X5Nr1iGKAIqdX6tMlm6HcNRIkr6AxO5jFEoJzzpT8aQ==
dependencies:
minimist "^1.2.5"
neo-async "^2.6.2"
source-map "^0.6.1"
wordwrap "^1.0.0"
optionalDependencies:
uglify-js "^3.1.4"

has-flag@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd"
Expand Down Expand Up @@ -5402,6 +5431,11 @@ json5@^2.1.2, json5@^2.2.2:
resolved "https://registry.yarnpkg.com/json5/-/json5-2.2.3.tgz#78cd6f1a19bdc12b73db5ad0c61efd66c1e29283"
integrity sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==

jsonc-parser@^3.2.0:
version "3.2.0"
resolved "https://registry.yarnpkg.com/jsonc-parser/-/jsonc-parser-3.2.0.tgz#31ff3f4c2b9793f89c67212627c51c6394f88e76"
integrity sha512-gfFQZrcTc8CnKXp6Y4/CBT3fTc0OVuDofpre4aEeEpSBPV5X5v4+Vmx+8snU7RLPrNHPKSgLxGo9YuQzz20o+w==

jsonfile@^6.0.1:
version "6.1.0"
resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-6.1.0.tgz#bc55b2634793c679ec6403094eb13698a6ec0aae"
Expand Down Expand Up @@ -5596,6 +5630,11 @@ lru-cache@^6.0.0:
dependencies:
yallist "^4.0.0"

lunr@^2.3.9:
version "2.3.9"
resolved "https://registry.yarnpkg.com/lunr/-/lunr-2.3.9.tgz#18b123142832337dd6e964df1a5a7707b25d35e1"
integrity sha512-zTU3DaZaF3Rt9rhN3uBMGQD3dD2/vFQqnvZCDv4dl5iOzq2IZQqTxu90r4E5J+nP70J3ilqVCrbho2eWaeW8Ow==

make-dir@^3.0.0, make-dir@^3.0.2, make-dir@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-3.1.0.tgz#415e967046b3a7f1d185277d84aa58203726a13f"
Expand All @@ -5608,6 +5647,11 @@ markdown-escapes@^1.0.0:
resolved "https://registry.yarnpkg.com/markdown-escapes/-/markdown-escapes-1.0.4.tgz#c95415ef451499d7602b91095f3c8e8975f78535"
integrity sha512-8z4efJYk43E0upd0NbVXwgSTQs6cT3T06etieCMEg7dRbzCbxUCK/GHlX8mhHRDcp+OLlHkPKsvqQTCvsRl2cg==

marked@^4.3.0:
version "4.3.0"
resolved "https://registry.yarnpkg.com/marked/-/marked-4.3.0.tgz#796362821b019f734054582038b116481b456cf3"
integrity sha512-PRsaiG84bK+AMvxziE/lCFss8juXjNaWzVbN5tXAm4XjeaS9NAHhop+PjQxz2A9h8Q4M/xGmzP8vqNwy6JeK0A==

mdast-squeeze-paragraphs@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/mdast-squeeze-paragraphs/-/mdast-squeeze-paragraphs-4.0.0.tgz#7c4c114679c3bee27ef10b58e2e015be79f1ef97"
Expand Down Expand Up @@ -5781,6 +5825,13 @@ [email protected], minimatch@^3.0.4, minimatch@^3.0.5, minimatch@^3.1.1, minimatch
dependencies:
brace-expansion "^1.1.7"

minimatch@^9.0.3:
version "9.0.3"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-9.0.3.tgz#a6e00c3de44c3a542bfaae70abfc22420a6da825"
integrity sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==
dependencies:
brace-expansion "^2.0.1"

minimist@^1.2.0, minimist@^1.2.5:
version "1.2.8"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.8.tgz#c1a464e7693302e082a075cee0c057741ac4772c"
Expand Down Expand Up @@ -7474,6 +7525,16 @@ shelljs@^0.8.5:
interpret "^1.0.0"
rechoir "^0.6.2"

shiki@^0.14.1:
version "0.14.4"
resolved "https://registry.yarnpkg.com/shiki/-/shiki-0.14.4.tgz#2454969b466a5f75067d0f2fa0d7426d32881b20"
integrity sha512-IXCRip2IQzKwxArNNq1S+On4KPML3Yyn8Zzs/xRgcgOWIr8ntIK3IKzjFPfjy/7kt9ZMjc+FItfqHRBg8b6tNQ==
dependencies:
ansi-sequence-parser "^1.1.0"
jsonc-parser "^3.2.0"
vscode-oniguruma "^1.7.0"
vscode-textmate "^8.0.0"

side-channel@^1.0.4:
version "1.0.4"
resolved "https://registry.yarnpkg.com/side-channel/-/side-channel-1.0.4.tgz#efce5c8fdc104ee751b25c58d4290011fa5ea2cf"
Expand Down Expand Up @@ -7962,6 +8023,23 @@ typedarray-to-buffer@^3.1.5:
dependencies:
is-typedarray "^1.0.0"

typedoc-plugin-markdown@^3.16.0:
version "3.16.0"
resolved "https://registry.yarnpkg.com/typedoc-plugin-markdown/-/typedoc-plugin-markdown-3.16.0.tgz#98da250271aafade8b6740a8116a97cd3941abcd"
integrity sha512-eeiC78fDNGFwemPIHiwRC+mEC7W5jwt3fceUev2gJ2nFnXpVHo8eRrpC9BLWZDee6ehnz/sPmNjizbXwpfaTBw==
dependencies:
handlebars "^4.7.7"

typedoc@^0.25.1:
version "0.25.1"
resolved "https://registry.yarnpkg.com/typedoc/-/typedoc-0.25.1.tgz#50de2d8fb93623fbfb59e2fa6407ff40e3d3f438"
integrity sha512-c2ye3YUtGIadxN2O6YwPEXgrZcvhlZ6HlhWZ8jQRNzwLPn2ylhdGqdR8HbyDRyALP8J6lmSANILCkkIdNPFxqA==
dependencies:
lunr "^2.3.9"
marked "^4.3.0"
minimatch "^9.0.3"
shiki "^0.14.1"

typescript@^4.7.2:
version "4.9.4"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.9.4.tgz#a2a3d2756c079abda241d75f149df9d561091e78"
Expand All @@ -7972,6 +8050,11 @@ ua-parser-js@^0.7.30:
resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.32.tgz#cd8c639cdca949e30fa68c44b7813ef13e36d211"
integrity sha512-f9BESNVhzlhEFf2CHMSj40NWOjYPl1YKYbrvIr/hFTDEmLq7SRbWvm7FcdcpCYT95zrOhC7gZSxjdnnTpBcwVw==

uglify-js@^3.1.4:
version "3.17.4"
resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.17.4.tgz#61678cf5fa3f5b7eb789bb345df29afb8257c22c"
integrity sha512-T9q82TJI9e/C1TAxYvfb16xO120tMVFZrGA3f9/P4424DNu6ypK103y0GPFVa17yotwSyZW5iYXgjYHkGrJW/g==

undefsafe@^2.0.5:
version "2.0.5"
resolved "https://registry.yarnpkg.com/undefsafe/-/undefsafe-2.0.5.tgz#38733b9327bdcd226db889fb723a6efd162e6e2c"
Expand Down Expand Up @@ -8250,6 +8333,16 @@ vfile@^4.0.0:
unist-util-stringify-position "^2.0.0"
vfile-message "^2.0.0"

vscode-oniguruma@^1.7.0:
version "1.7.0"
resolved "https://registry.yarnpkg.com/vscode-oniguruma/-/vscode-oniguruma-1.7.0.tgz#439bfad8fe71abd7798338d1cd3dc53a8beea94b"
integrity sha512-L9WMGRfrjOhgHSdOYgCt/yRMsXzLDJSL7BPrOZt73gU0iWO4mpqzqQzOz5srxqTvMBaR0XZTSrVWo4j55Rc6cA==

vscode-textmate@^8.0.0:
version "8.0.0"
resolved "https://registry.yarnpkg.com/vscode-textmate/-/vscode-textmate-8.0.0.tgz#2c7a3b1163ef0441097e0b5d6389cd5504b59e5d"
integrity sha512-AFbieoL7a5LMqcnOF04ji+rpXadgOXnZsxQr//r83kLPr7biP7am3g9zbaZIaBGwBRWeSvoMD4mgPdX3e4NWBg==

wait-on@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/wait-on/-/wait-on-6.0.1.tgz#16bbc4d1e4ebdd41c5b4e63a2e16dbd1f4e5601e"
Expand Down Expand Up @@ -8461,6 +8554,11 @@ wildcard@^2.0.0:
resolved "https://registry.yarnpkg.com/wildcard/-/wildcard-2.0.0.tgz#a77d20e5200c6faaac979e4b3aadc7b3dd7f8fec"
integrity sha512-JcKqAHLPxcdb9KM49dufGXn2x3ssnfjbcaQdLlfZsL9rH9wgDQjUtDxbo8NE0F6SFvydeu1VhZe7hZuHsB2/pw==

wordwrap@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb"
integrity sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q==

wrap-ansi@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
Expand Down

0 comments on commit cce49ce

Please sign in to comment.