Skip to content

Commit

Permalink
feat(bindgen): Point from WASI README to dispatch package README
Browse files Browse the repository at this point in the history
  • Loading branch information
thewtex committed Apr 6, 2023
1 parent fdfc2c9 commit 97d4f77
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

Zstandard compression and decompression and base64 encoding and decoding in WebAssembly. WASI implementation.

This package provides the WASI WebAssembly implementation. It is usually not called directly. Please use the [`compress-stringify`](https://pypi.org/project/compress-stringify/) instead.


## Installation

```sh
Expand Down
41 changes: 38 additions & 3 deletions src/bindgen/python.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,42 @@ function snakeCase(kebabCase) {
return kebabCase.replaceAll('-', '_')
}

function packageReadme(packageName, packageDescription, packageDir) {
function wasiPackageReadme(packageName, packageDescription, packageDir) {
let readme = ''
readme += `# ${packageName}\n`
readme += `\n[![PyPI version](https://badge.fury.io/py/${packageName}.svg)](https://badge.fury.io/py/${packageName})\n`
readme += `\n${packageDescription}\n`

const dispatchPackage = packageName.replace(/-wasi$/, '')
readme += `\nThis package provides the WASI WebAssembly implementation. It is usually not called directly. Please use the [\`${dispatchPackage}\`](https://pypi.org/project/${dispatchPackage}/) instead.\n\n`
readme += `\n## Installation\n
\`\`\`sh
pip install ${packageName}
\`\`\`
`
const readmePath = path.join(packageDir, 'README.md')
if (!fs.existsSync(readmePath)) {
fs.writeFileSync(readmePath, readme)
}
}

function emscriptenPackageReadme(packageName, packageDescription, packageDir) {
let readme = ''
readme += `# ${packageName}\n`
readme += `\n[![PyPI version](https://badge.fury.io/py/${packageName}.svg)](https://badge.fury.io/py/${packageName})\n`
readme += `\n${packageDescription}\n`
readme += `\n## Installation\n
\`\`\`sh
pip install ${packageName}
\`\`\`
`
const readmePath = path.join(packageDir, 'README.md')
if (!fs.existsSync(readmePath)) {
fs.writeFileSync(readmePath, readme)
}
}

function dispatchPackageReadme(packageName, packageDescription, packageDir) {
let readme = ''
readme += `# ${packageName}\n`
readme += `\n[![PyPI version](https://badge.fury.io/py/${packageName}.svg)](https://badge.fury.io/py/${packageName})\n`
Expand Down Expand Up @@ -416,7 +451,7 @@ function wasiPackage(outputDir, buildDir, wasmBinaries, options) {
const bindgenPyPackage = pypackage
mkdirP(path.join(packageDir, pypackage))

packageReadme(packageName, packageDescription, packageDir)
wasiPackageReadme(packageName, packageDescription, packageDir)
packagePyProjectToml(packageName, packageDir, bindgenPyPackage, options)
packageVersion(packageDir, pypackage)
packageDunderInit(outputDir, buildDir, wasmBinaries, packageName, packageDescription, packageDir, pypackage)
Expand All @@ -443,7 +478,7 @@ function pythonBindings(outputDir, buildDir, wasmBinaries, options) {
const bindgenPyPackage = pypackage
mkdirP(path.join(packageDir, pypackage))

packageReadme(packageName, options.packageDescription, packageDir)
dispatchPackageReadme(packageName, options.packageDescription, packageDir)
packagePyProjectToml(packageName, packageDir, bindgenPyPackage, options)
packageVersion(packageDir, pypackage)
packageDunderInit(outputDir, buildDir, [], packageName, options.packageDescription, packageDir, pypackage)
Expand Down

0 comments on commit 97d4f77

Please sign in to comment.