Skip to content

Commit cf0c371

Browse files
formanb-yogesh
andauthored
Initial docs (#31)
* Initial docs * Update chartlets.js/README.md Co-authored-by: b-yogesh <[email protected]> * Update chartlets.py/README.md Co-authored-by: b-yogesh <[email protected]> * Update docs/components.md Co-authored-by: b-yogesh <[email protected]> * Update docs/index.md Co-authored-by: b-yogesh <[email protected]> * Update docs/demo.md Co-authored-by: b-yogesh <[email protected]> * Update docs/usage.md Co-authored-by: b-yogesh <[email protected]> * Update docs/index.md Co-authored-by: b-yogesh <[email protected]> --------- Co-authored-by: b-yogesh <[email protected]>
1 parent ae90607 commit cf0c371

File tree

12 files changed

+212
-105
lines changed

12 files changed

+212
-105
lines changed

.gitignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
# Logs
2+
*.log
3+
4+
# Artifacts
5+
build
6+
dist
7+
# npm
8+
node_modules
9+
# pip
10+
*.egg-info
11+
# mkdocs
12+
site
13+
114
# Editor directories and files
215
.vscode/*
316
!.vscode/extensions.json
@@ -8,3 +21,4 @@
821
*.njsproj
922
*.sln
1023
*.sw?
24+
.idea/

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44

55
It comprises a [Python backend package](chartlets.py/README.md)
66
and a [JavaScript/React frontend package](chartlets.js/README.md).
7+

chartlets.js/README.md

Lines changed: 7 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,16 @@
11
# chartlets
22

3-
Chartlets is a JavaScript library that allows configuring server-side widgets
4-
and plugging them into existing web frontends.
3+
Chartlets is a software framework that allows websites developed with
4+
React to be extended by server-side widgets programmed in Python or other
5+
programming languages.
56

6-
_Note, this library is experimental and under development still._
7+
This is the JavaScript/React library of the framework.
78

8-
## How it is supposed to work
9+
For details refer to the [documentation](https://bcdev.github.io/chartlets/).
910

10-
Users write the widgets in, e.g. Python, and a REST server implements three
11-
endpoints to publish the widgets:
11+
## Run the demo UI
1212

13-
- `GET /contributions`: Called once after application UI starts up.
14-
Returns an object whose keys are contribution points (e.g., "panels")
15-
and whose values are arrays of contribution objects.
16-
- `POST /layout/{contribPoint}/{contribIndex}`:
17-
Called once for every contribution when it becomes visible in the UI.
18-
Returns the contribution's initial component tree
19-
- `POST /callback`:
20-
Called when users interact with the component tree or on application
21-
state changes. Returns an array of contribution changes where each
22-
contribution change contains an array of actions to be applied to the
23-
component tree.
24-
25-
The following sequence diagram depicts how the library is supposed to
26-
work. The top shows the JavaScript frontend that uses this library.
27-
The bottom shows the lifeline of the backend REST server.
28-
29-
![docs/sequence.png](docs/sequence.png)
30-
31-
## How to run the demo
32-
33-
```bash
34-
git clone https://github.com/bcdev/chartlets.git
35-
```
36-
37-
### Run the server
38-
39-
```bash
40-
cd chartlets/chartlets.py
41-
conda env create
42-
conda activate chartlets
43-
pip install -ve .
44-
python -m chartlets.demo.server
45-
```
46-
47-
### Run the UI
48-
49-
```bash
50-
cd ../chartlets.js
13+
``` bash
5114
npm install
5215
npm run dev
5316
```
54-

chartlets.py/README.md

Lines changed: 7 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
# chartlets
22

3-
`chartlets` is a Python framework for server-configured web-UI contributions.
3+
Chartlets is a software framework that allows websites developed with
4+
React to be extended by server-side widgets programmed in Python or other
5+
programming languages.
6+
7+
This is the Python backend library of the framework.
8+
9+
For details refer to the [documentation](https://bcdev.github.io/chartlets/).
410

511
## Run demo server
612

@@ -9,62 +15,3 @@ mamba env create
915
conda activate chartlets
1016
python -m chartlets.demo.server
1117
```
12-
13-
## How to use the framework
14-
15-
### 1. Implement the possible contributions
16-
17-
Implement the application-specific contributions that users
18-
can add to their extensions.
19-
20-
As an example, see [`panel.py` of the demo](chartlets/demo/contribs/panel.py):
21-
22-
```python
23-
from chartlets import Contribution
24-
25-
26-
class Panel(Contribution):
27-
"""Panel contribution"""
28-
29-
def __init__(self, name: str, title: str | None = None):
30-
super().__init__(name, title=title)
31-
```
32-
33-
### 2. Define the contributions points
34-
35-
Define the possible contribution points in your application.
36-
37-
As an example, see [`server.py` of the demo](chartlets/demo/server.py):
38-
39-
```python
40-
from chartlets import Extension
41-
from chartlets.demo.contribs import Panel
42-
43-
Extension.add_contrib_point("panels", Panel)
44-
```
45-
46-
### 3. Load the extensions
47-
48-
Load the extensions that augment your application.
49-
50-
As an example, see [`server.py` of the demo](chartlets/demo/server.py):
51-
52-
```python
53-
from chartlets import ExtensionContext
54-
55-
ext_ctx = ExtensionContext.load(app_ctx, extension_refs)
56-
```
57-
58-
### 4. Publish the extensions
59-
60-
Implement the Chartlets API in your application-specific webserver using
61-
the controller implementations in `chartlets.controllers`.
62-
63-
As an example, see [`server.py` of the demo](chartlets/demo/server.py).
64-
65-
### 5. Consume the extensions
66-
67-
Use JavaScript package `chartlets` in your frontend to implement the
68-
contribution lifecycle in your React application.
69-
70-
As an example, see [the demo application](../chartlets/src/demo).

chartlets.py/pyproject.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,13 @@ dev = [
5454
"pytest",
5555
"pytest-cov",
5656
"requests-mock",
57+
"twine",
58+
"build",
59+
"hatch"
60+
]
61+
doc = [
62+
"mkdocs",
63+
"mkdocs-material"
5764
]
5865
demo = [
5966
"pyaml",

docs/about.md

Whitespace-only changes.

docs/components.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Given here is a list of the components supported by chartlets.
2+
3+
Using the Python package, they can be imported from the `chartlets.components`
4+
module, e.g.
5+
6+
```python
7+
from chartlets.components import Checkbox
8+
```
9+
10+
- Box
11+
- Button
12+
- Checkbox
13+
- Dropdown
14+
- Plot
15+
- Typography

docs/demo.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Chartlets provides a simple demo that serves as a
2+
reference for the framework usage and testbed for its features.
3+
4+
```bash
5+
git clone https://github.com/bcdev/chartlets.git
6+
```
7+
8+
### Run the server
9+
10+
```bash
11+
cd chartlets/chartlets.py
12+
conda env create
13+
conda activate chartlets
14+
pip install -ve .
15+
python -m chartlets.demo.server
16+
```
17+
18+
### Run the UI
19+
20+
```bash
21+
cd ../chartlets.js
22+
npm install
23+
npm run dev
24+
```

docs/index.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Welcome to Chartlets
2+
3+
Chartlets is a software framework that allows websites developed with
4+
React to be extended by server-side widgets programmed in Python or other
5+
programming languages.
6+
7+
## How it works
8+
9+
Users write the widgets in, e.g. Python, and a REST server implements three
10+
endpoints to publish the widgets:
11+
12+
- `GET /contributions`: Called once after application UI starts up.
13+
Returns an object whose keys are contribution points (e.g., "panels")
14+
and whose values are arrays of contribution objects.
15+
- `POST /layout/{contribPoint}/{contribIndex}`:
16+
Called once for every contribution when it becomes visible in the UI.
17+
Returns the contribution's initial component tree.
18+
- `POST /callback`:
19+
Called when users interact with the component tree or on application
20+
state changes. Returns an array of contribution changes where each
21+
contribution change contains an array of actions to be applied to the
22+
component tree.
23+
24+
The following sequence diagram depicts how the library is supposed to
25+
work. The top shows the JavaScript frontend that uses this library.
26+
The bottom shows the lifeline of the backend REST server.
27+
28+
![images/sequence.png](images/sequence.png)

0 commit comments

Comments
 (0)