Skip to content

Commit

Permalink
fixed js-sdk script
Browse files Browse the repository at this point in the history
  • Loading branch information
0div committed Sep 24, 2024
1 parent b65762a commit c6e2cb7
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 25 deletions.
1 change: 0 additions & 1 deletion .github/workflows/generate_api_ref.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git status
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add apps/web/src/app/\(docs\)/docs/api-reference
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -287,3 +287,6 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
.idea/

# API reference artifacts
api_ref/
41 changes: 22 additions & 19 deletions packages/js-sdk/scripts/generate_api_ref.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,28 @@ set -euo pipefail
npx typedoc

PKG_VERSION="v$(node -p "require('./package.json').version")"

ROUTES_DIR="../../apps/web/src/app/(docs)/docs/api-reference/js-sdk/${PKG_VERSION}"
# move to docs web app
mkdir -p ../../apps/web/src/app/\(docs\)/docs/api-reference/js-sdk/${PKG_VERSION}

mv api_ref/* ../../apps/web/src/app/\(docs\)/docs/api-reference/js-sdk/${PKG_VERSION}/

#mv api_ref/sandbox.md ../../apps/web/src/app/\(docs\)/docs/api-reference/js-sdk/sandbox/page.mdx
#
#mkdir -p ../../apps/web/src/app/\(docs\)/docs/api-reference/js-sdk/errors
#mv api_ref/errors.md ../../apps/web/src/app/\(docs\)/docs/api-reference/js-sdk/errors/page.mdx
#
#mkdir -p ../../apps/web/src/app/\(docs\)/docs/api-reference/js-sdk/filesystem
#mv api_ref/sandbox/filesystem.md ../../apps/web/src/app/\(docs\)/docs/api-reference/js-sdk/filesystem/page.mdx
#
#mkdir -p ../../apps/web/src/app/\(docs\)/docs/api-reference/js-sdk/process
#mv api_ref/sandbox/process.md ../../apps/web/src/app/\(docs\)/docs/api-reference/js-sdk/process/page.mdx
#
#mkdir -p ../../apps/web/src/app/\(docs\)/docs/api-reference/js-sdk/pty
#mv api_ref/sandbox/pty.md ../../apps/web/src/app/\(docs\)/docs/api-reference/js-sdk/pty/page.mdx
#
mkdir -p "${ROUTES_DIR}"

rm -rf api_ref/README.md

# Flatten the api_ref directory by moving all nested files to the root level and remove empty subdirectories
find api_ref -mindepth 2 -type f | while read -r file; do
mv "$file" api_ref/
done
find api_ref -type d -empty -delete

# Transfrom top level MD files into folders of the same name with page.mdx inside
find api_ref -maxdepth 1 -type f -name "*.md" | while read -r file; do
# Extract the filename without extension
filename=$(basename "$file" .md)
# Create the directory of the same name in api_ref
mkdir -p "api_ref/${filename}"
# Move the file inside the newly created directory
mv "$file" "api_ref/${filename}/page.mdx"
done

cp -r api_ref/* "${ROUTES_DIR}"

rm -rf api_ref
Empty file.
10 changes: 5 additions & 5 deletions packages/python-sdk/scripts/generate_api_ref.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ mkdir -p api_ref

for package in "${packages[@]}"; do
# generate raw api reference markdown file
pydoc-markdown -p e2b.${package} >api_ref/${package}.mdx
pydoc-markdown -p e2b."${package}" >api_ref/"${package}".mdx
# remove package path display
sed -i '/<a[^>]*>.*<\/a>/d' api_ref/${package}.mdx
sed -i '/<a[^>]*>.*<\/a>/d' api_ref/"${package}".mdx
# remove empty hyperlinks
sed -i '/^# /d' api_ref/${package}.mdx
sed -i '/^# /d' "api_ref/${package}.mdx"
# move to docs
mkdir -p ../../apps/web/src/app/\(docs\)/docs/api-reference/python-sdk/${PKG_VERSION}/${package}
mv api_ref/${package}.mdx ../../apps/web/src/app/\(docs\)/docs/api-reference/python-sdk/${PKG_VERSION}/${package}/page.mdx
mkdir -p "../../apps/web/src/app/(docs)/docs/api-reference/python-sdk/${PKG_VERSION}/${package}"
mv "api_ref/${package}.mdx" "../../apps/web/src/app/(docs)/docs/api-reference/python-sdk/${PKG_VERSION}/${package}/page.mdx"
done

rm -rf api_ref

0 comments on commit c6e2cb7

Please sign in to comment.