Skip to content

Commit

Permalink
feat: add TSDoc
Browse files Browse the repository at this point in the history
  • Loading branch information
giladgd committed Aug 16, 2023
1 parent 98bdfff commit e4b5a48
Show file tree
Hide file tree
Showing 8 changed files with 212 additions and 8 deletions.
7 changes: 7 additions & 0 deletions .config/typedoc.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.tsd-typography h4,
.tsd-typography .tsd-index-panel h3,
.tsd-index-panel .tsd-typography h3,
.tsd-typography h5,
.tsd-typography h6 {
margin: 1.2em 0 0.4em 0;
}
14 changes: 14 additions & 0 deletions .config/typedoc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"$schema": "https://typedoc.org/schema.json",
"entryPoints": ["../src/index.ts"],
"out": "../docs",
"tsconfig": "../tsconfig.json",
"customCss": "./typedoc.css",
"readme": "../README.md",
"excludeExternals": true,
"excludeInternal": true,
"excludePrivate": true,
"githubPages": true,
"hideGenerator": true,
"jsDocCompatibility": true
}
26 changes: 25 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,20 @@ jobs:
run: npm ci --ignore-scripts
- name: Build
run: npm run build
- name: Generate docs
run: npm run generate-docs
- name: Download latest llama.cpp release
run: node ./dist/cli/cli.js download --release latest --skipBuild
- name: Upload build artifact
uses: actions/upload-artifact@v3
with:
name: "build"
path: "dist"
- name: Upload build artifact
uses: actions/upload-artifact@v3
with:
name: "docs"
path: "docs"
- name: Upload llama.cpp artifact
uses: actions/upload-artifact@v3
with:
Expand Down Expand Up @@ -191,7 +198,12 @@ jobs:
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
concurrency: release-${{ github.ref }}
environment:
name: npm
url: ${{ steps.set-npm-url.outputs.npm-url }}
permissions:
pages: write
id-token: write
contents: write
issues: write
pull-requests: write
Expand All @@ -213,6 +225,7 @@ jobs:
mkdir -p llamaBins
mv artifacts/bins-*/* llamaBins/
mv artifacts/build dist/
mv artifacts/docs docs/
echo "Built binaries:"
ls llamaBins
Expand All @@ -221,4 +234,15 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npx semantic-release

- name: Set npm package url to GITHUB_OUTPUT
id: set-npm-url
run: echo "npm-url=https://www.npmjs.com/package/node-llama-cpp/v/$(cat .npmPackage.version.txt)" >> $GITHUB_OUTPUT
- name: Upload docs to GitHub Pages
uses: actions/upload-pages-artifact@v2
with:
name: pages-docs
path: docs
- name: Deploy docs to GitHub Pages
uses: actions/deploy-pages@v2
with:
artifact_name: pages-docs
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ node_modules
.DS_Store

/dist
/docs

/.env
/.eslintcache
Expand Down
5 changes: 4 additions & 1 deletion .releaserc.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
}],
"@semantic-release/release-notes-generator",
"@semantic-release/npm",
"@semantic-release/github"
"@semantic-release/github",
["@semantic-release/exec", {
"publishCmd": "echo \"${nextRelease.version}\" > .npmPackage.version.txt"
}]
]
}
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ console.log("AI: " + a1);
```

### CLI
```txt
```
Usage: node-llama-cpp <command> [options]
Commands:
Expand All @@ -140,11 +140,11 @@ Commands:
Options:
-h, --help Show help [boolean]
-v, --version Show version number [boolean] [boolean]
-v, --version Show version number [boolean]
```

#### `download` command
```txt
```
node-llama-cpp download
Download a release of llama.cpp and compile it
Expand All @@ -162,7 +162,7 @@ Options:
```

#### `build` command
```txt
```
node-llama-cpp build
Compile the currently downloaded llama.cpp
Expand All @@ -175,7 +175,7 @@ Options:
```

#### `clear` command
```txt
```
node-llama-cpp clear [type]
Clear files created by llama-cli
Expand All @@ -187,7 +187,7 @@ Options:
```

#### `chat` command
```txt
```
node-llama-cpp chat
Chat with a LLama model
Expand Down
152 changes: 152 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"prepare": "[ $CI = true ] || [ -d '.husky/_' ] || husky install",
"prebuild": "rm -rf ./dist ./tsconfig.tsbuildinfo",
"build": "tsc --build tsconfig.json --force",
"generate-docs": "typedoc",
"prewatch": "rm -rf ./dist ./tsconfig.tsbuildinfo",
"watch": "tsc --build tsconfig.json --watch --force",
"node-gyp-llama": "cd llama && node-gyp",
Expand Down Expand Up @@ -83,6 +84,7 @@
"devDependencies": {
"@commitlint/cli": "^17.7.1",
"@commitlint/config-conventional": "^17.7.0",
"@semantic-release/exec": "^6.0.3",
"@types/bytes": "^3.1.1",
"@types/cli-progress": "^3.11.0",
"@types/cross-spawn": "^6.0.2",
Expand All @@ -99,6 +101,7 @@
"semantic-release": "^21.0.7",
"ts-node": "^10.9.1",
"tslib": "^2.6.1",
"typedoc": "^0.24.8",
"typescript": "^5.1.6",
"zx": "^7.2.3"
},
Expand Down

0 comments on commit e4b5a48

Please sign in to comment.