Skip to content

Update documentation folder and readme. #1108

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
merged 3 commits into from
Jul 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
92 changes: 12 additions & 80 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,99 +105,31 @@ There also are some unit tests, you can run those with cargo:
$ cargo test --all
```

# Using another standard library
# Using a standard library

As of now the standard library is under construction.

You can play around
with other standard libraries for python. For example,
the [ouroboros library](https://github.com/pybee/ouroboros).
As of now the standard library is under construction. You can
use a standard library by setting the RUSTPYTHONPATH environment
variable.

To do this, follow this method:

```shell
$ cd ~/GIT
$ git clone git@github.com:pybee/ouroboros.git
$ export RUSTPYTHONPATH=~/GIT/ouroboros/ouroboros
$ cd RustPython
$ cargo run -- -c 'import statistics'
```

# Compiling to WebAssembly

At this stage RustPython only has preliminary support for web assembly. The instructions here are intended for developers or those wishing to run a toy example.

## Setup

To get started, install [wasm-pack](https://rustwasm.github.io/wasm-pack/installer/) and `npm`. ([wasm-bindgen](https://rustwasm.github.io/wasm-bindgen/whirlwind-tour/basic-usage.html) should be installed by `wasm-pack`. if not, install it yourself)

<!-- Using `rustup` add the compile target `wasm32-unknown-emscripten`. To do so you will need to have [rustup](https://rustup.rs/) installed.

```bash
rustup target add wasm32-unknown-emscripten
```

Next, install `emsdk`:

```bash
curl https://s3.amazonaws.com/mozilla-games/emscripten/releases/emsdk-portable.tar.gz | tar -zxv
cd emsdk-portable/
./emsdk update
./emsdk install sdk-incoming-64bit
./emsdk activate sdk-incoming-64bit
``` -->

## Build

Move into the `wasm` directory. This directory contains a library crate for interop
with python to rust to js and back in `wasm/lib`, the demo website found at
https://rustpython.github.io/demo in `wasm/demo`, and an example of how to use
the crate as a library in one's own JS app in `wasm/example`.

```sh
cd wasm
```

Go to the demo directory. This is the best way of seeing the changes made to either
the library or the JS demo, as the `rustpython_wasm` module is set to the global
JS variable `rp` on the website.

```sh
cd demo
$ export RUSTPYTHONPATH=~/GIT/RustPython/Lib
$ cargo run -- -c 'import xdrlib'
```

Now, start the webpack development server. It'll compile the crate and then
the demo app. This will likely take a long time, both the wasm-pack portion and
the webpack portion (from after it says "Your crate has been correctly compiled"),
so be patient.

```sh
npm run dev
```
You can play around
with other standard libraries for python. For example,
the [ouroboros library](https://github.com/pybee/ouroboros).

You can now open the webpage on https://localhost:8080 and Python code in either
the text box or browser devtools with:

```js
rp.pyEval(
`
print(js_vars['a'] * 9)
`,
{
vars: {
a: 9
}
}
);
```
# Compiling to WebAssembly

Alternatively, you can run `npm run build` to build the app once, without watching
for changes, or `npm run dist` to build the app in release mode, both for the
crate and webpack.
[See this doc](wasm/README.md)

# Code style

The code style used is the default [rustfmt](https://github.com/rust-lang/rustfmt) codestyle. Please format your code accordingly.
We also use [clippy](https://github.com/rust-lang/rust-clippy) to detect rust code issues.

# Community

Expand Down
30 changes: 0 additions & 30 deletions docs/builtins.md

This file was deleted.

17 changes: 0 additions & 17 deletions docs/compat-test.md

This file was deleted.

13 changes: 0 additions & 13 deletions docs/frameTODO.txt

This file was deleted.

Binary file not shown.
13 changes: 0 additions & 13 deletions docs/notes.md

This file was deleted.

5 changes: 0 additions & 5 deletions docs/reference.md

This file was deleted.

43 changes: 0 additions & 43 deletions docs/sharing.md

This file was deleted.

Loading