- 
                Notifications
    You must be signed in to change notification settings 
- Fork 175
Generate SDK reference #48
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
          
     Merged
      
      
            0div
  merged 24 commits into
  main
from
generate-api-reference-for-code-interpreter-sdk-e2b-1235
  
      
      
   
  Nov 27, 2024 
      
    
  
     Merged
                    Changes from all commits
      Commits
    
    
            Show all changes
          
          
            24 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      910e9cd
              
                boilerplate to generate api ref for js code interpreter
              
              
                0div b7cb651
              
                change python deps to allow pydoc-markdown to work
              
              
                0div ff36efe
              
                boilerplate to generate api ref for python code interpreter
              
              
                0div 9a7cecc
              
                rebrand to SDK Reference
              
              
                0div c46eba2
              
                fix typefoc config out folder
              
              
                0div 43fdc0d
              
                fix typos and better naming for python api ref
              
              
                0div 6994564
              
                Merge branch 'main' of https://github.com/e2b-dev/code-interpreter in…
              
              
                0div b1c2c3a
              
                add sdk autogen workflow and make it a part of the release workflow
              
              
                0div f3b08b6
              
                trigger workflow on feature branch push
              
              
                0div 7177fc4
              
                fix python path in install step
              
              
                0div 30a0335
              
                fix path in show docs step
              
              
                0div 9c6f448
              
                fix path in show docs step
              
              
                0div 1cc5b85
              
                [skip ci] Release new Code Interpreter Python and JS SDK references d…
              
              
                github-actions[bot] 4f8bb9e
              
                remove dredundant pkg diff step
              
              
                0div 6730cd2
              
                Merge branch 'generate-api-reference-for-code-interpreter-sdk-e2b-123…
              
              
                0div ccfcd33
              
                make black and pydoc-markdown dev-deps
              
              
                0div 6022f33
              
                include generate sdk workflow inside release workflow, make pnpm recu…
              
              
                0div cdb01f2
              
                remove sdk gen workflow call from release
              
              
                0div 1fcacd9
              
                fix python package.json generate ref command
              
              
                0div 7b172d8
              
                temporarily disable docker and template build for workflow testing pu…
              
              
                0div 494c5b4
              
                [skip ci] Release new versions
              
              
                github-actions[bot] 41b157d
              
                remove temp changes to test release workflow
              
              
                0div 1eb099a
              
                Merge branch 'generate-api-reference-for-code-interpreter-sdk-e2b-123…
              
              
                0div a154d0a
              
                Update .github/workflows/release.yml
              
              
                0div File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| #!/usr/bin/env bash | ||
|  | ||
| set -euo pipefail | ||
|  | ||
| # This script checks for diffs in the js/ and python/ directory. | ||
| # If there are diffs, it means we need to generate new SDK references. | ||
| if git diff --name-only HEAD^ | grep -q '^js/\|^python/'; then | ||
| echo "true" | ||
| else | ||
| echo "false" | ||
| fi | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| { | ||
| "name": "@e2b/code-interpreter", | ||
| "version": "1.0.4", | ||
| "packageManager": "[email protected]", | ||
| "description": "E2B Code Interpreter - Stateful code execution", | ||
| "homepage": "https://e2b.dev", | ||
| "license": "MIT", | ||
|  | @@ -32,7 +33,8 @@ | |
| "update-deps": "ncu -u && pnpm i", | ||
| "example": "npx tsx example.mts", | ||
| "test:bun": "bun test tests/runtimes/bun --env-file=.env", | ||
| "test:deno": "deno test tests/runtimes/deno/ --allow-net --allow-read --allow-env --unstable-sloppy-imports --trace-leaks" | ||
| "test:deno": "deno test tests/runtimes/deno/ --allow-net --allow-read --allow-env --unstable-sloppy-imports --trace-leaks", | ||
| "generate-ref": "./scripts/generate_sdk_ref.sh" | ||
| }, | ||
| "devDependencies": { | ||
| "@types/node": "^18.18.6", | ||
|  | @@ -41,6 +43,8 @@ | |
| "knip": "^5.25.1", | ||
| "npm-check-updates": "^16.14.20", | ||
| "tsup": "^8.1.0", | ||
| "typedoc": "^0.26.8", | ||
| "typedoc-plugin-markdown": "^4.2.7", | ||
| "typescript": "^5.5.3", | ||
| "vitest": "^2.0.1" | ||
| }, | ||
|  | ||
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| const { MarkdownTheme, MarkdownPageEvent } = require('typedoc-plugin-markdown') | ||
|  | ||
| function load(app) { | ||
| // Listen to the render event | ||
| app.renderer.on(MarkdownPageEvent.END, (page) => { | ||
| // Remove Markdown links from the document contents | ||
| page.contents = removeMarkdownLinks( | ||
| removeFirstNLines( | ||
| convertH5toH3(removeLinesWithConditions(page.contents)), | ||
| 6 | ||
| ) | ||
| ) | ||
| }) | ||
| } | ||
|  | ||
| // this is a hacky way to make methods in the js-sdk sdk reference look more prominent | ||
| function convertH5toH3(text) { | ||
| return text.replace(/^##### (.*)$/gm, '### $1') | ||
| } | ||
|  | ||
| // Function to remove Markdown-style links | ||
| function removeMarkdownLinks(text) { | ||
| // Regular expression to match Markdown links [text](url) | ||
| return text.replace(/\[([^\]]+)\]\(([^)]+)\)/g, '$1') // Replace with just the link text | ||
| } | ||
|  | ||
| function removeFirstNLines(text, n, condition) { | ||
| // Split the text into lines, then join back excluding the first four lines | ||
| return text.split('\n').slice(n).join('\n') | ||
| } | ||
|  | ||
| // Function to remove lines based on conditions | ||
| function removeLinesWithConditions(text) { | ||
| const lines = text.split('\n') | ||
| const filteredLines = [] | ||
|  | ||
| for (let i = 0; i < lines.length; i++) { | ||
| // Check if the current line starts with "#### Extends" or "###### Overrides" | ||
| if ( | ||
| lines[i].startsWith('#### Extends') || | ||
| lines[i].startsWith('###### Overrides') || | ||
| lines[i].startsWith('###### Inherited from') | ||
| ) { | ||
| // If it does, skip this line and the next three lines | ||
| i += 3 // Skip this line and the next three | ||
| continue | ||
| } | ||
|  | ||
| if (lines[i].startsWith('##### new')) { | ||
| // avoid promoting constructors | ||
| i += 1 | ||
| continue | ||
| } | ||
|  | ||
| // If not removed, add the line to filteredLines | ||
| filteredLines.push(convertH5toH3(lines[i])) | ||
| } | ||
|  | ||
| // Join the filtered lines back into a single string | ||
| return filteredLines.join('\n') | ||
| } | ||
|  | ||
| // Export the load function | ||
| module.exports = { load } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| #!/usr/bin/env bash | ||
|  | ||
| set -euo pipefail | ||
|  | ||
| # This script generates the Code Interpreter JS SDK reference markdown files | ||
| # Run it in the `js/` directory | ||
|  | ||
| # generate raw SDK reference markdown files | ||
| npx typedoc | ||
|  | ||
| PKG_VERSION="v$(node -p "require('./package.json').version")" | ||
| ROUTES_DIR="../sdk-reference/code-interpreter-js-sdk/${PKG_VERSION}" | ||
| mkdir -p "${ROUTES_DIR}" | ||
|  | ||
| rm -rf sdk_ref/README.md | ||
|  | ||
| # Flatten the sdk_ref directory by moving all nested files to the root level and remove empty subdirectories | ||
| find sdk_ref -mindepth 2 -type f | while read -r file; do | ||
| mv "$file" sdk_ref/ | ||
| done | ||
| find sdk_ref -type d -empty -delete | ||
|  | ||
| # Transfrom top level MD files into folders of the same name with page.mdx inside | ||
| find sdk_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 sdk_ref | ||
| mkdir -p "sdk_ref/${filename}" | ||
| # Move the file inside the newly created directory | ||
| mv "$file" "sdk_ref/${filename}/page.mdx" | ||
| done | ||
|  | ||
| cp -r sdk_ref/* "${ROUTES_DIR}" | ||
|  | ||
| rm -rf sdk_ref | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| { | ||
| "out": "sdk_ref", | ||
| "plugin": ["typedoc-plugin-markdown", "./scripts/CustomMarkdownTheme.js"], | ||
| "exclude": ["**/*.spec.ts"], | ||
| "entryPoints": [ | ||
| "src/index.ts", | ||
| "src/charts.ts", | ||
| "src/consts.ts", | ||
| "src/messaging.ts", | ||
| "src/sandbox.ts" | ||
| ], | ||
| "excludeExternals": true, | ||
| "excludePrivate": true, | ||
| "excludeProtected": true, | ||
| "navigation": { | ||
| "includeGroups": false, | ||
| "includeCategories": false | ||
| }, | ||
| "outputFileStrategy": "modules", | ||
| "readme": "none", | ||
| "disableSources": true, | ||
| // typedoc-plugin-markdown options | ||
| "classPropertiesFormat": "table", | ||
| "typeDeclarationFormat": "table", | ||
| "enumMembersFormat": "table", | ||
| "parametersFormat": "table", | ||
| "expandParameters": true, | ||
| "useCodeBlocks": true, | ||
| "hidePageTitle": true, | ||
| "hideBreadcrumbs": true | ||
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
|  | @@ -13,6 +13,6 @@ | |
| "changeset": "^0.2.6" | ||
| }, | ||
| "engines": { | ||
| "pnpm": ">=9.0.0 <10" | ||
| "pnpm": ">=9.0.0 <10" | ||
| } | ||
| } | ||
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.