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 runtime and runtime-async packages #200

Merged
merged 20 commits into from
Jun 11, 2022
Merged
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
a9dbcce
feat: add dependencies, config, and package.json for new runtime and …
chrispcampbell Jun 9, 2022
1d22c83
feat: add runtime package sources
chrispcampbell Jun 9, 2022
59f7366
feat: add runtime-async package sources
chrispcampbell Jun 9, 2022
a0a50d6
build: add typedoc and a gen-docs script
chrispcampbell Jun 9, 2022
4009690
build: fail the build if there are any untracked/modified files
chrispcampbell Jun 9, 2022
b647696
docs: add typedoc-generated API docs for runtime package
chrispcampbell Jun 9, 2022
1eda016
docs: unhide WasmModule but keep its properties hidden for now
chrispcampbell Jun 10, 2022
1c170d2
build: fix expansion of sed args in gen-docs script
chrispcampbell Jun 10, 2022
eed4468
build: don't remove docs directory in clean script
chrispcampbell Jun 10, 2022
b948019
docs: use index.md in the breadcrumb links
chrispcampbell Jun 10, 2022
b51c099
docs: hide private members and preserve ordering of members from sour…
chrispcampbell Jun 10, 2022
779f0b7
build: convert gen-docs to a Node script that can apply custom substi…
chrispcampbell Jun 10, 2022
fbd6b66
docs: add API docs for runtime-async package
chrispcampbell Jun 10, 2022
50f3df2
fix: ignore ./docs directory so that only children are deleted
chrispcampbell Jun 10, 2022
9429dcb
fix: remove unnecessary InitWasmModel type alias
chrispcampbell Jun 10, 2022
37e348b
feat: add terminate function to ModelRunner interface
chrispcampbell Jun 10, 2022
7b342a3
test: add integration test for runtime-async package
chrispcampbell Jun 10, 2022
7134f11
test: add test for createWasmModelRunner
chrispcampbell Jun 10, 2022
eb046f2
test: add tests for ModelScheduler
chrispcampbell Jun 11, 2022
a8a9362
docs: link to the API docs from the README
chrispcampbell Jun 11, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
build: convert gen-docs to a Node script that can apply custom substi…
…tutions
  • Loading branch information
chrispcampbell committed Jun 10, 2022
commit 779f0b77c6c98134ba73989054244f3aa6a267f8
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -25,6 +25,7 @@
"eslint": "^8.14.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-eslint-comments": "^3.2.0",
"glob": "^8.0.3",
"npm-run-all": "^4.1.5",
"prettier": "^2.6.2",
"tsup": "^6.1.0",
2 changes: 1 addition & 1 deletion packages/runtime/package.json
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@
"test:watch": "vitest",
"test:ci": "vitest run",
"build": "tsup",
"docs": "../../scripts/gen-docs",
"docs": "../../scripts/gen-docs.js",
"ci:build": "run-s clean lint prettier:check test:ci build docs"
},
"dependencies": {
2 changes: 2 additions & 0 deletions pnpm-lock.yaml

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

35 changes: 0 additions & 35 deletions scripts/gen-docs

This file was deleted.

75 changes: 75 additions & 0 deletions scripts/gen-docs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#!/usr/bin/env node

//
// This script runs `typedoc` for the package in the current working directory and
// makes some text substitutions, for example to insert links to API docs for types
// that are defined in a separate package.
//

import { execSync } from 'child_process'
import { existsSync, readFileSync, writeFileSync } from 'fs'
import { resolve as resolvePath } from 'path'
import glob from 'glob'

// By default, replace all links to the typedoc-generated `entry.md` with a link to our
// own customized `index.md`. More replacements can be defined on a per-project basis
// by including a `.typedoc/replacements.json` file.
const replacements = [['entry.md', 'index.md']]

function applyReplacements(filePath) {
// Read the source file
const src = readFileSync(filePath).toString()

// Replace all occurrences of each listed type with a link to the docs for that type
let edited = src
for (const r of replacements) {
edited = edited.replaceAll(r[0], r[1])
}

// Write the edited content back to the same location
writeFileSync(filePath, edited)
}

function main() {
// Remove the existing generated docs
execSync(`find ./docs ! -name 'index.md' -delete`)

// Load more project-specific replacements from the `.typedoc/replacements.json` file
const replacementsFile = resolvePath('.typedoc', 'replacements.json')
if (existsSync(replacementsFile)) {
const json = readFileSync(replacementsFile)
const projReplacements = JSON.parse(json)
for (const r of projReplacements) {
replacements.push(r)
}
}

// Generate the docs for the current package
const typedocCmd = `typedoc \
--tsconfig ./tsconfig-build.json \
--sort source-order \
--excludeExternals \
--excludePrivate \
--disableSources \
--readme none \
--githubPages false \
--plugin typedoc-plugin-markdown \
--entryDocument entry.md \
--hideInPageTOC \
--hideMembersSymbol \
--allReflectionsHaveOwnDocument \
--out docs \
--cleanOutputDir false \
src/index.ts`
execSync(typedocCmd)

// List all files in the docs directory
glob('docs/**/*.md', {}, (_, files) => {
// Edit each file to apply the replacements
for (const f of files) {
applyReplacements(f)
}
})
}

main()