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

mystmd #1178

Draft
wants to merge 17 commits into
base: main
Choose a base branch
from
Draft

mystmd #1178

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
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# GitHub syntax highlighting
pixi.lock linguist-language=YAML linguist-generated=true
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,6 @@ cypress/videos/
packages/core/typescript/itk-wasm/dist

CMakePresets.json
# pixi environments
.pixi
*.egg-info
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ ITK-Wasm
[![npm version](https://badge.fury.io/py/itkwasm.svg)](https://pypi.org/project/itkwasm/)
[![npm version](https://badge.fury.io/py/itk-webassemblyinterface.svg)](https://pypi.org/project/itk-webassemblyinterface/)

[![DOI](https://zenodo.org/badge/45812381.svg)](https://zenodo.org/badge/latestdoi/45812381)
[![DOI](https://zenodo.org/badge/45812381.svg)](https://zenodo.org/doi/10.5281/zenodo.3688880)

![License](https://img.shields.io/github/license/InsightSoftwareConsortium/ITK-Wasm) ![GitHub commit activity](https://img.shields.io/github/commit-activity/y/InsightSoftwareConsortium/ITK-Wasm)

Expand Down
Binary file removed docs/_static/packages/compare-images.png
Binary file not shown.
Binary file removed docs/_static/packages/compress-stringify.png
Binary file not shown.
Binary file removed docs/_static/packages/dicom.png
Binary file not shown.
Binary file removed docs/_static/packages/downsample.png
Binary file not shown.
Binary file removed docs/_static/packages/elastix.png
Binary file not shown.
Binary file removed docs/_static/packages/htj2k.png
Binary file not shown.
Binary file removed docs/_static/packages/image-io.png
Binary file not shown.
Binary file removed docs/_static/packages/mesh-io.png
Binary file not shown.
Binary file not shown.
6 changes: 3 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@
}

html_theme = 'furo'
html_static_path = ['_static']
html_logo = "_static/logo-white.svg"
html_favicon = "_static/icon/favicon.png"
htmlstatic_path = ['static']
html_logo = "static/logo-white.svg"
html_favicon = "static/icon/favicon.png"
html_title = f"{project} documentation"
html_baseurl = os.environ.get("SPHINX_BASE_URL", "")

Expand Down
5 changes: 2 additions & 3 deletions docs/cxx/interface_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,8 @@ int main(argc, char * argv[])
}
```

<dl>
<dt><b><code>itk::wasm::InputTextStream</code></b><dt><dd>A string. To reader this data type in C++, using the resulting <a href="https://www.cplusplus.com/reference/istream/istream/">std::istream</a>.</dd>
</dl>
`itk::wasm::InputTextStream`
: A string. To reader this data type in C++, using the resulting [`std::istream`](https://www.cplusplus.com/reference/istream/istream/).

*todo: document remaining CLI11 input and output classes.*

Expand Down
36 changes: 18 additions & 18 deletions docs/cxx/tutorial/debugging.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,29 +51,29 @@ add_executable(DebugMe DebugMe.cxx)

with standard CMake commands,

![Native build](/_static/tutorial/debugging/native-build.png)
![Native build](../../static/tutorial/debugging/native-build.png)

The native binary can then be debugged in the standard way. For example, with `gdb` on Linux:

![Native debug Linux](/_static/tutorial/debugging/native-debug-linux.png)
![Native debug Linux](../../static/tutorial/debugging/native-debug-linux.png)

## WASI

The most direct way to debug WebAssembly is through the [WebAssembly System Interface (WASI)](https://wasi.dev/). In itk-wasm we can build to WASI with the [WASI SDK](https://github.com/WebAssembly/wasi-sdk) by specifying the `itkwasm/wasi` toolchain image. A backtrace can quickly be obtained with the `itk-wasm` CLI. Or, a fully fledged debugger session can be started with LLDB.

First, build to WASI WebAssembly with debugging symbols available:

![WASI debug build](/_static/tutorial/debugging/wasi-build-debug.png)
![WASI debug build](../../static/tutorial/debugging/wasi-build-debug.png)

Then, the `itk-wasm` CLI can conveniently run the Wasm binary with the included WASI runtime:

![Run WASI debug](/_static/tutorial/debugging/run-wasi-debug.png)
![Run WASI debug](../../static/tutorial/debugging/run-wasi-debug.png)

We can see that `abort` is called in the `main` function at line 13 in `DebugMe.cxx`.

A full debugging session is also possible after [LLDB](https://lldb.llvm.org/) >= 13 and [Wasmtime](https://wasmtime.dev/) are installed.

![LLDB WASI debug](/_static/tutorial/debugging/lldb-wasi-debug.png)
![LLDB WASI debug](../../static/tutorial/debugging/lldb-wasi-debug.png)

**Note:** when calling `wasmtime` directly and passing local files into a pipeline, `--dir` arguments must be set. This gives `wasmtime` permission to access the directories containing the files. This is required due to WASI's [capability-based security](https://en.wikipedia.org/wiki/Capability-based_security) model. For example, if a file path starts with `./`, then add `--dir ./` arguments to the `wasmtime` invocation. `--dir` can be specified multiple times.

Expand All @@ -85,31 +85,31 @@ As with native builds, this builds debugging symbols, the human-readable names o

When built with the default `Release` build type:

![Emscripten build Release](/_static/tutorial/debugging/emscripten-build-release.png)
![Emscripten build Release](../../static/tutorial/debugging/emscripten-build-release.png)

the JavaScript support code is minified, and difficult to debug:

![Run Node Release](/_static/tutorial/debugging/run-node-release.png)
![Run Node Release](../../static/tutorial/debugging/run-node-release.png)

However, when built with the `Debug` build type:

![Emscripten build Debug](/_static/tutorial/debugging/emscripten-build-debug.png)
![Emscripten build Debug](../../static/tutorial/debugging/emscripten-build-debug.png)

a useful backtrace can be obtained:

![Run Node Debug](/_static/tutorial/debugging/run-node-debug.png)
![Run Node Debug](../../static/tutorial/debugging/run-node-debug.png)

In order to run a debugger with Node, add the `--inspect-brk` flag when invoking `node`:

![Node inspect](/_static/tutorial/debugging/node-inspect.png)
![Node inspect](../../static/tutorial/debugging/node-inspect.png)

This will pause execution on start a debugging remote interface. To connect to the remote interface with a Chromium browser, visit `chrome://inspect` and click the *inspect* link on the corresponding *Remote Target*:

![Node inspect Remote Target](/_static/tutorial/debugging/node-inspect-remote-target.png)
![Node inspect Remote Target](../../static/tutorial/debugging/node-inspect-remote-target.png)

This will open the Chrome Dev Tools debugger:

![Node inspect Chrome DevTools](/_static/tutorial/debugging/node-inspect-chrome-dev-tools.png)
![Node inspect Chrome DevTools](../../static/tutorial/debugging/node-inspect-chrome-dev-tools.png)

Other debugger interfaces [are also available](https://nodejs.org/en/docs/inspector), like a CLI debugger or the VSCode debugger.

Expand All @@ -127,21 +127,21 @@ Next, enable it in DevTools.

Open DevTools -> Click the *gear (⚙)* icon in the top right corner -> go to the *Experiments* panel -> and tick *WebAssembly Debugging: Enable DWARF support*.

![Enable Wasm Debugging](/_static/tutorial/debugging/enable-chrome-wasm-debugging.png)
![Enable Wasm Debugging](../../static/tutorial/debugging/enable-chrome-wasm-debugging.png)

After exitting Settings, you will be prompted to reload DevTools -- reload.

Next, open the options for Chrome WebAssembly Debugging extension:

![Wasm Debugging Options](/_static/tutorial/debugging/devtools-options.png)
![Wasm Debugging Options](../../static/tutorial/debugging/devtools-options.png)

Since itk-wasm performs builds in a clean Docker environment, the debugging source paths in the Docker environment are different than the paths on the host system. The debugging extension has a path substitution system that can account for these differences. In the Docker image, the directory where `itk-wasm` is invoked is mounted as `/work`. Substitute `/work` with the directory where the `itk-wasm` CLI is invoked. For example, if `itk-wasm` was invoked at `/home/matt/src/itk-wasm/examples/Debugging`, then:

![Path substitution](/_static/tutorial/debugging/path-substitution.png)
![Path substitution](../../static/tutorial/debugging/path-substitution.png)

Build the project with itk-wasm and the `Debug` `CMAKE_BUILD_TYPE` to include DWARF debugging information:

![Emscripten build Debug](/_static/tutorial/debugging/emscripten-build-debug.png)
![Emscripten build Debug](../../static/tutorial/debugging/emscripten-build-debug.png)

Here we load and run the WebAssembly with a simple HTML file and server:

Expand All @@ -167,8 +167,8 @@ Here we load and run the WebAssembly with a simple HTML file and server:
</html>
```

![HTTP Server](/_static/tutorial/debugging/http-server.png)
![HTTP Server](../../static/tutorial/debugging/http-server.png)

And we can debug the C++ code in Chrome's DevTools debugger along side the executing JavaScript!

![Debug C++ DevTools](/_static/tutorial/debugging/debug-cxx-devtools.png)
![Debug C++ DevTools](../../static/tutorial/debugging/debug-cxx-devtools.png)
2 changes: 1 addition & 1 deletion docs/cxx/tutorial/hello_pipeline.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ Check the generated help output:
npx itk-wasm run hello-pipeline.wasi.wasm -- -- --help
```

![Hello pipeline help](/_static/tutorial/hello_pipeline.png)
![Hello pipeline help](../../static/tutorial/hello_pipeline.png)

The two `--`'s are to separate arguments for the Wasm module from arguments to the `itk-wasm` CLI and the WebAssembly interpreter.

Expand Down
4 changes: 2 additions & 2 deletions docs/cxx/tutorial/hello_world.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,13 @@ Create an HTML file named `index.html` that will call the Wasm module through Ja

Serve the web page and Wasm module with an http server:

```sh
```shell
npm install http-server
http-server .
```

And point your browser to `http://127.0.0.1:8080/`.

![Hello Wasm World!](/_static/tutorial/hello_wasm_world.png)
![Hello Wasm World!](../../static/tutorial/hello_wasm_world.png)

Congratulations! You just executed a C++ program in your web browser. 🎉
10 changes: 0 additions & 10 deletions docs/cxx/tutorial/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,3 @@ This tutorial will walk you through the process of *creating WebAssembly scienti

This [Jupyter notebook
tutorial](https://github.com/InsightSoftwareConsortium/ScientificImageAnalysisVisualizationAndArtificialIntelligenceCourse/blob/master/10_Create_Scientific_WebAssembly_Pipelines.ipynb) also provides an interactive walkthrough.

```{toctree}
:maxdepth: 2
:caption: 📖 Tutorial Steps

hello_world.md
hello_pipeline.md
inputs_outputs.md
debugging.md
```
6 changes: 3 additions & 3 deletions docs/cxx/tutorial/inputs_outputs.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ Parse the command line arguments with the `ITK_WASM_PARSE` macro:

The `-h` and `--help` flags are automatically generated from pipeline arguments to print usage information.

![inputs-outputs help](/_static/tutorial/inputs_outputs_help.png)
![inputs-outputs help](../../static/tutorial/inputs_outputs_help.png)

Finally, process our data:
```cpp
Expand Down Expand Up @@ -157,11 +157,11 @@ npx itk-wasm -b wasi-build run inputs-outputs.wasi.wasm -- -- --radius 2 cthead1

The input image:

![input image](/_static/tutorial/cthead1.png)
![input image](../../static/tutorial/cthead1.png)

has been smoothed:

![smoothed](/_static/tutorial/smoothed.png)
![smoothed](../../static/tutorial/smoothed.png)

## Run in Node.js

Expand Down
57 changes: 3 additions & 54 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ ITK-Wasm

<div align="center">

![itk-wasm](_static/itk-webassembly.png)
![itk-wasm](static/itk-webassembly.png)

[![Examples](https://github.com/InsightSoftwareConsortium/ITK-Wasm/actions/workflows/examples.yml/badge.svg)](https://github.com/InsightSoftwareConsortium/ITK-Wasm/actions/workflows/examples.yml) [![Toolchains](https://github.com/InsightSoftwareConsortium/ITK-Wasm/actions/workflows/toolchains.yml/badge.svg)](https://github.com/InsightSoftwareConsortium/ITK-Wasm/actions/workflows/toolchains.yml) [![JavaScript, TypeScript](https://github.com/InsightSoftwareConsortium/ITK-Wasm/actions/workflows/javascript-typescript.yml/badge.svg)](https://github.com/InsightSoftwareConsortium/ITK-Wasm/actions/workflows/javascript-typescript.yml) [![Python WASM](https://github.com/InsightSoftwareConsortium/ITK-Wasm/actions/workflows/python-wasm.yml/badge.svg)](https://github.com/InsightSoftwareConsortium/ITK-Wasm/actions/workflows/python-wasm.yml) [![C++,Native Python](https://github.com/InsightSoftwareConsortium/ITK-Wasm/actions/workflows/cxx-python.yml/badge.svg)](https://github.com/InsightSoftwareConsortium/ITK-Wasm/actions/workflows/cxx-python.yml) [![WASI](https://github.com/InsightSoftwareConsortium/ITK-Wasm/actions/workflows/wasi.yml/badge.svg)](https://github.com/InsightSoftwareConsortium/ITK-Wasm/actions/workflows/wasi.yml) [![Documentation](https://github.com/InsightSoftwareConsortium/ITK-Wasm/actions/workflows/documentation.yml/badge.svg)](https://github.com/InsightSoftwareConsortium/ITK-Wasm/actions/workflows/documentation.yml)

[![npm version](https://badge.fury.io/js/itk-wasm.svg)](https://www.npmjs.com/package/itk-wasm)
[![itkwasm version](https://badge.fury.io/py/itkwasm.svg)](https://pypi.org/project/itkwasm/)

[![DOI](https://zenodo.org/badge/45812381.svg)](https://zenodo.org/badge/latestdoi/45812381)
[![DOI](https://zenodo.org/badge/45812381.svg)](https://zenodo.org/doi/10.5281/zenodo.3688880)

![License](https://img.shields.io/github/license/InsightSoftwareConsortium/ITK-Wasm) ![GitHub commit activity](https://img.shields.io/github/commit-activity/y/InsightSoftwareConsortium/ITK-Wasm)
</div>
Expand All @@ -26,55 +26,4 @@ The project provides tools to
- transfer data efficiently in and out of the WebAssembly runtime.
- perform asynchronous, parallel execution of processing pipelines in a worker pool.

*ITK-Wasm* can be used to execute [ITK](https://www.itk.org/) or arbitrary C++ codes in the browser, on the command line, and in languages like Python via [WASI](https://wasi.dev/) and [Emscripten](https://emscripten.org) runtimes.

```{toctree}
:hidden:
:maxdepth: 3
:caption: 👋 Introduction

introduction/packages.md
introduction/parts.md
model/index.md
introduction/file_formats/index.md
```

```{toctree}
:hidden:
:maxdepth: 3
:caption: 🌐 JavaScript/TypeScript

typescript/interface_types/index.md
typescript/index.md
typescript/distribution/index.md
```

```{toctree}
:hidden:
:maxdepth: 3
:caption: 🐍 Python

python/introduction.md
python/numpy.md
python/itk_python.md
apidocs/index.rst
```

```{toctree}
:hidden:
:maxdepth: 3
:caption: 📖 C++ Wasm Processing Pipelines

cxx/installation.md
cxx/tutorial/index.md
cxx/interface_types.md
```

```{toctree}
:hidden:
:maxdepth: 3
:caption: 🔨 ITK-Wasm Development

development/hacking_itk_wasm.md
development/itk_js_to_itk_wasm_migration_guide.md
```
*ITK-Wasm* can be used to execute [ITK](https://www.itk.org/) or arbitrary C++ codes in the browser, on the command line, and in languages like Python via [WASI](https://wasi.dev/) and [Emscripten](https://emscripten.org) runtimes.
17 changes: 4 additions & 13 deletions docs/introduction/file_formats/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,8 @@ ITK-Wasm formats can be output in a directory or bundled in a single `.cbor` fil

ITK-Wasm file formats are available in ITK-Wasm IO functions but also in C++ via the *WebAssemblyInterface* ITK module. This module can be enabled in an ITK build by setting the `-DModule_WebAssemblyInterface:BOOL=ON` flag in CMake. And, loading and conversion is also available native-binary Python bindings via the [*itk-webassemblyinterface* Python package](https://pypi.org/project/itk-webassemblyinterface/).

<dl>
<dt><b>ITK-Wasm Image (.iwi, .iwi.cbor, .iwi.cbor.zst)</b><dt><dd>Serialization of an <a href="../../typescript/interface_types/Image.html"><code>Image</code></a>.</dd>
<dt><b>ITK-Wasm Mesh (.iwm, .iwm.cbor, .iwm.cbor.zst)</b><dt><dd>Serialization of a <a href="../../typescript/interface_types/Mesh.html"><code>Mesh</code></a>, or <a href="../../typescript/interface_types/PolyData.html"><code>PolyData</code></a>.</dd>
</dl>
ITK-Wasm Image (.iwi, .iwi.cbor, .iwi.cbor.zst)
: Serialization of an [Image](../../model/Image).


```{toctree}
:hidden:
:maxdepth: 3

images.md
meshes.md
dicom.md
```
ITK-Wasm Mesh (.iwm, .iwm.cbor, .iwm.cbor.zst)
: Serialization of a [Mesh](../../model/Mesh) or [PolyData](../../model/PolyData).
Loading