Skip to content

Commit

Permalink
Fix notebook meta (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
bollwyvl authored Jan 29, 2021
1 parent 541a2da commit 8e39be8
Show file tree
Hide file tree
Showing 32 changed files with 626 additions and 183 deletions.
25 changes: 23 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@

### Recommended: conda

- Get [Miniconda3](https://repo.anaconda.com/miniconda/)
- Get [Miniforge/Mambaforge](https://github.com/conda-forge/miniforge/releases)

```bash
conda env update --file environment.yml
mamba env update --file environment.yml
source activate ipydrawio
```

Expand All @@ -32,6 +32,27 @@ doit

## Prepare a Release

```bash
doit dist
```

## Do everything

```bash
doit all
```

## Updating drawio

- update the `version` in `packages/ipydrawio-webpack/package.json`
- update dependencies in other `package.json`

```bash
pushd packages/ipydrawio-webpack/drawio
git fetch
git checkout v<the new version>
popd
doit dist
```

- validate everything looks good!
105 changes: 67 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,42 +1,73 @@
# @deathbeds/ipydrawio
# IPyDrawio

[Drawio][] diagrams for [JupyterLab][]. Forked with ❤️ from
[QuantStack/jupyterlab-drawio][].

> **[Install](#installation)** &middot; > **[History](./CHANGELOG.md)** >
> &middot; > **[Roadmap](./docs/ROADMAP.dio.ipynb)** &middot; >
> **[Contribute](./CONTRIBUTING.md)** &middot; > **[Open Source](#open-source)**
---

**[Install](#installation)** &middot; **[History]** &middot; **[Roadmap]**
&middot; **[Contribute](./CONTRIBUTING.md)** &middot;
**[Open Source](#open-source)** &middot; [![build][workflow-badge]][workflow]

---

> > ![.github/workflows/ci.yml](https://github.com/deathbeds/ipydrawio/workflows/.github/workflows/ci.yml/badge.svg)
> >
> > This is ALPHA software. Native drawio files created with these tools
> > _should_ work with any other [drawio][] client, but any UI/API is liable to
> > change at any time.
[history]: https://github.com/deathbeds/ipydrawio/blob/master/CHANGELOG.md
[binder]:
http://mybinder.org/v2/gh/deathbeds/ipydrawio/master?urlpath=lab/tree/docs/Poster.dio.svg
[binder-badge]: https://mybinder.org/badge_logo.svg
[workflow-badge]:
https://github.com/deathbeds/ipydrawio/workflows/.github/workflows/ci.yml/badge.svg
[workflow]:
https://github.com/deathbeds/ipydrawio/actions?query=branch%3Amaster+workflow%3A.github%2Fworkflows%2Fci.yml
[roadmap]:
https://github.com/deathbeds/ipydrawio/blob/master/docs/ROADMAP.dio.ipynb

## Examples
## Installation

| Screenshot/Example | Note |
| ---------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------- |
| [![binder-badge][]][binder] | A Binder **demo** with a full [contributing](./CONTRIBUTING.md) environment |
| [<img width="100" src="./docs/_static/images/poster.png" />](./docs/_static/images/poster.png) | Screenshot of drawio "minimal" UI with export options |
| [<img width="100" src="./docs/Poster.dio.svg" />](./docs/Poster.dio.svg) | The beginning of an interactive computational **poster** |
| [~~Screenshot Needed~](./docs/ROADMAP.dio.ipynb) | A mixed computational/creative **roadmap** for this project |
```bash
pip install ipydrawio ipydrawio-export
# TBD: conda install -c conda-forge ipydrawio
```

## Features

- Edit multi-page diagrams
- with nearly the same UI and features as [diagrams.net][drawio]
- in many file formats
- Drawio/mxgraph XML, SVG, PNG
- or Jupyter Notebooks
- `ipydrawio`
- Edit multi-page [documents][]
- with nearly the same UI and features as [diagrams.net][drawio]
- in many file formats
- Drawio/mxgraph XML, SVG, PNG
- or Jupyter Notebooks
- Jupyter [rich display][] output
- Jupyter [Widgets][]
- `ipydrawio-export`
- Export print-quality PDF from diagrams
- > _BEWARE: some **heavy**, maybe fragile dependencies_
- include editable Drawio metadata

[documents]:
https://github.com/deathbeds/ipydrawio/blob/master/docs/Diagram%20Document.ipynb
[rich display]:
https://github.com/deathbeds/ipydrawio/blob/master/docs/Diagram%20Rich%20Display.ipynb
[widgets]:
https://github.com/deathbeds/ipydrawio/blob/master/docs/Diagram%20Widgets.ipynb

## Examples

| Note | Screenshot/Example |
| --------------------------------------------------------------------------: | :----------------------------------------------- |
| A Binder **demo** with a full [contributing](./CONTRIBUTING.md) environment | [![binder-badge][]][binder] |
| Screenshot of drawio "minimal" UI with export options | [![poster-min]][poster-min] |
| The beginning of an interactive computational **poster** | [![poster][]][poster] |
| A mixed computational/creative **roadmap** for this project | [~~Screenshot Needed~](./docs/ROADMAP.dio.ipynb) |

> - Experimental: Export print-quality PDF from diagrams (_beware: some
> **heavy** dependencies_)
> - include editable Drawio metadata
[poster-min]:
https://raw.githubusercontent.com/deathbeds/ipydrawio/master/docs/_static/images/poster.png
[poster]:
https://raw.githubusercontent.com/deathbeds/ipydrawio/master/docs/Poster.dio.svg

## Usage

Expand All @@ -56,42 +87,40 @@
https://jupyterlab.readthedocs.io/en/stable/user/files.html?highlight=Launcher#creating-files-and-activities
[file manager]: https://jupyterlab.readthedocs.io/en/stable/user/files.html

## Installation

```bash
pip install ipydrawio
# TBD: conda install -c conda-forge ipydrawio
```

### PDF: Lab and Server extensions

`@deathbeds/ipydrawio-pdf` and `jupyter-drawio-export` can generate
print-quality PDF. This approach relies on a headless browser, powered by
`jgraph/drawio-image-export2` and ultimately `puppeteer` and has a number of
heavy-weight dependencies. To enable all the bells and whistles get:
`ipydrawio-export` can generate print-quality PDF. This approach relies on a
headless browser, powered by [@jgraph/draw-image-export2] and ultimately
`puppeteer` which in turn requires `nodejs`.

- `pypdf2` and `requests_cache` from `pip` or `conda`
- **native dependencies** as required to appease `puppeteer`
- if running in `docker`, this can be a bit trial-and-error
- for more, see the [binder][apt-txt] and ~~CI~~.
- `nodejs>10,<14` from `conda` or your system package manager
- **NOTE**: this relies on being able to install `puppeteer` (and other
**arbitrary dependencies** with `jlpm` for now **when first used**
- _we'll figure out a better approach soon enough_
- **native dependencies** as required to appease `puppeteer`
- if running in `docker`, this can be a bit trial-and-error
- for more, see the [binder](./binder/apt.txt) and ~~CI~~.
- `pip install ipydrawio-export`

[puppeteer]: https://github.com/puppeteer/puppeteer
[@jgraph/draw-image-export2]: https://github.com/jgraph/draw-image-export2
[apt-txt]: https://github.com/deathbeds/ipydrawio/blob/master/binder/apt.txt

> For example:
>
> ```bash
> conda install -yc conda-forge nodejs=12
> pip install jupyter-drawio-export
> pip install ipydrawio-export
> ```
## Open Source
### License
All files herein, unless otherwise noted, are free software licensed under
[Apache 2.0](./LICENSE.txt).
[Apache 2.0].
[apache 2.0]: https://github.com/deathbeds/ipydrawio/blob/master/LICENSE.txt
### Copyright
Expand Down
2 changes: 1 addition & 1 deletion atest/__init__.robot
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
*** Settings ***
Documentation jupyterlab-drawio
Documentation IPyDrawio
Resource _Keywords.robot
Resource _Variables.robot
Suite Setup Setup Server and Browser
Expand Down
80 changes: 80 additions & 0 deletions docs/Diagram Document.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "eligible-lexington",
"metadata": {},
"source": [
"# Diagram Document\n",
"\n",
"Using a `.dio` file directly in the _Diagram Document_ is much simpler than the [Diagram Widget](./Diagram%20Widget.ipynb) or [Diagram Rich Display](./Diagram%20Rich%20Display.ipynb). \n",
"\n",
"You can download these from [diagrams.net](https://diagrams.net), or one of their many integrations. You might also be able to use these documents in [documentation](https://pypi.org/project/sphinxcontrib-drawio/)."
]
},
{
"cell_type": "markdown",
"id": "heard-adolescent",
"metadata": {},
"source": [
"## Making a Diagram Document\n",
"From the _JupyterLab Launcher_:\n",
"- click _Diagram_"
]
},
{
"cell_type": "markdown",
"id": "collectible-breeding",
"metadata": {},
"source": [
"## Opening a Diagram Document\n",
"- Find a <img src=\"../packages/ipydrawio/style/img/drawio.svg\" style=\"width:1.6em\"/> file in the JupyterLab _File Browser_ <kbd>Ctrl+Shift+F</kbd>\n",
"- Double click it"
]
},
{
"cell_type": "markdown",
"id": "forced-scheduling",
"metadata": {},
"source": [
"### Other Formats\n",
"\n",
"`drawio` XML can be embedded inside `png` and `svg` images and notebooks. If they have a compound suffix, like `.dio.png`, `.dio.ipynb`, the _Diagram Editor_ will be opened by default.\n",
"- right click on the file in the _File Browser_\n",
"- select _Open With_\n",
"- select one of the _Diagram_ options"
]
},
{
"cell_type": "markdown",
"id": "respected-plymouth",
"metadata": {},
"source": [
"## Configuration\n",
"\n",
"In the JupyterLab _Advanced Settings_ Panel <kbd>Ctrl+,</kbd>, the <img src=\"../packages/ipydrawio/style/img/drawio.svg\" style=\"width:1.6em\"/> _Diagrams Documents_ section offers many, many options."
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.6"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
117 changes: 117 additions & 0 deletions docs/Diagram Rich Display.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "addressed-population",
"metadata": {},
"source": [
"# Diagram Rich Display\n",
"\n",
"The _Rich Display_ is a good deal simpler than the [Diagram Widget](./Diagram%20Widget.ipynb), but offers more computability than the [Diagram Document](./Diagram%20Document.ipynb)."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "another-cricket",
"metadata": {},
"outputs": [],
"source": [
"from IPython.display import display, update_display"
]
},
{
"cell_type": "markdown",
"id": "secondary-lingerie",
"metadata": {},
"source": [
"If you just need to show a diagram (or want a _really_ temporary scratchpad), just send a display message to the frontend with the `application/x-drawio` mimetype."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "academic-injury",
"metadata": {},
"outputs": [],
"source": [
"MIMETYPE = \"application/x-drawio\""
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "oriented-poland",
"metadata": {},
"outputs": [],
"source": [
"def display_drawio(xml, **kwargs):\n",
" \"\"\" Send some xml to the frontend\n",
" \n",
" Get a handle to update later by calling `display_drawio` with `display_id=True` \n",
" \"\"\"\n",
" return display({MIMETYPE: xml}, raw=True, **kwargs)"
]
},
{
"cell_type": "markdown",
"id": "fiscal-decline",
"metadata": {},
"source": [
"Apparently, an empty string is valid."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "extensive-sharing",
"metadata": {},
"outputs": [],
"source": [
"handle = display_drawio(\"\")"
]
},
{
"cell_type": "markdown",
"id": "wrong-connecticut",
"metadata": {},
"source": [
"## Metadata\n",
"The `drawioUrlParams` and `drawioConfig` (as well as `width` and `height`) can change how the application works."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "empirical-scout",
"metadata": {},
"outputs": [],
"source": [
"handle = display_drawio(\"\", metadata={\n",
" MIMETYPE: dict(height=\"200px\", drawioUrlParams=dict(ui=\"dark\", chrome=0))\n",
"})"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.6"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
Loading

0 comments on commit 8e39be8

Please sign in to comment.