Skip to content

Commit 35aac3a

Browse files
committed
Update README
1 parent ad21252 commit 35aac3a

File tree

1 file changed

+59
-7
lines changed

1 file changed

+59
-7
lines changed

README.md

Lines changed: 59 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,31 @@
33
![Build and Test](https://github.com/dbrattli/Fable.Python/workflows/Build%20and%20Test/badge.svg)
44
[![Nuget](https://img.shields.io/nuget/vpre/Fable.Python)](https://www.nuget.org/packages/Fable.Python/)
55

6-
Python bindings for Fable. This library will eventually contain Python (stdlib)
7-
bindings for Fable based on Python
8-
[typeshed](https://github.com/python/typeshed).
6+
[Fable](https://github.com/fable-compiler/Fable/tree/beyond) is a compiler that
7+
translates F# source files to JavaScript and Python.
98

10-
It will also contain type binding for many other libraries as well such
11-
as Flask, MicroBit and many more
9+
This Fable Python repository contains the Python bindings for Fable. This
10+
library will eventually contain Python (stdlib) bindings for Fable based on
11+
Python [typeshed](https://github.com/python/typeshed). It will also contain
12+
type binding for many other libraries as well such as Flask, MicroBit and many
13+
more. Some bindings have already been added:
14+
15+
- Python Standard Libray
16+
- Jupyter
17+
- Flask
18+
- MicroBit
19+
- CogniteSdk
1220

1321
## Installation
1422

15-
Prerequisite to compile F# to Python using Fable:
23+
Prerequisite for compiling F# to Python using Fable:
1624

1725
```sh
1826
> dotnet tool install --global fable-py --version 4.0.0-alpha-004
1927
> dotnet add package Fable.Core.Experimental --version 4.0.0-alpha-005
2028
```
2129

22-
To use the `Fable.Python` library:
30+
To use the `Fable.Python` library in your Fable project:
2331

2432
```sh
2533
> dotnet package add Fable.Python
@@ -34,6 +42,50 @@ let object = {| A=10; B=20 |}
3442
let result = json.dumps object
3543
```
3644

45+
To compile an F# Fable project to Python run e.g:
46+
47+
```sh
48+
> dotnet fable-py MyProject.fsproj
49+
```
50+
51+
For more examples see the
52+
[examples](https://github.com/dbrattli/Fable.Python/tree/main/examples) folder.
53+
It contains example code for using Fable Python with:
54+
55+
- [Flask](https://github.com/dbrattli/Fable.Python/tree/main/examples/flask).
56+
References [Feliz.ViewEngine](https://github.com/dbrattli/Feliz.ViewEngine)
57+
as a nuget package.
58+
- [MicroBit](https://github.com/dbrattli/Fable.Python/tree/main/examples/microbit)
59+
- [Timeflies](https://github.com/dbrattli/Fable.Python/tree/main/examples/timeflies),
60+
Cool demo using Tkinter and references
61+
[FSharp.Control.AsyncRx](https://github.com/dbrattli/AsyncRx) as a nuget
62+
package.
63+
64+
65+
## Contributing
66+
67+
If the type binding you are looking for is currently missing (it probably is),
68+
then add it to the relavant files (or add new ones). Open a
69+
[PR](https://github.com/dbrattli/Fable.Python/pull/3/files) to get them
70+
included. There's not much Python specific documentation yet, but the process
71+
of adding type bindings for Python is similar to JS:
72+
73+
- https://fable.io/docs/communicate/js-from-fable.html
74+
- https://medium.com/@zaid.naom/f-interop-with-javascript-in-fable-the-complete-guide-ccc5b896a59f
75+
76+
77+
## Differences from JS
78+
79+
Note that import all is different from JS. E.g:
80+
81+
```fs
82+
[<ImportAll("flask")>]
83+
let flask: IExports = nativeOnly
84+
```
85+
86+
This will generate `import flask` and not a wildcard import `from flask import
87+
*`. The latter version is discoraged anyways.
88+
3789
## Auto-generation
3890

3991
Parts of this library could benefit from code-generation based on the type

0 commit comments

Comments
 (0)