Skip to content

Commit c9faf18

Browse files
committed
Update docs
1 parent c469a98 commit c9faf18

File tree

7 files changed

+42
-39
lines changed

7 files changed

+42
-39
lines changed

docs-src/communicate/fable-from-py.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ containing actual members and is not nested by any other.
2727
// counting when it finds actual code
2828
module A.Long.Namespace.RootModule
2929
30-
// The name of this function will be the same in JS
30+
// The name of this function will be the same in Python
3131
let add (x: int) (y: int) = x + y
3232
3333
module Nested =
34-
// This will be prefixed with the name of the module in JS
34+
// This will be prefixed with the name of the module in Python
3535
let add (x: int) (y: int) = x * y
3636
```
3737

@@ -79,7 +79,7 @@ exchanging data between F# and Python. The most important common types are:
7979
- Mutable **hashsets** (not F# sets) compile to a custom HashSet type.
8080

8181
> If the dictionary or hashset requires custom or structural equality, Fable will generate a custom type, but it will
82-
> share the same properties as JS maps and sets.
82+
> share the same properties as Python maps and sets.
8383
8484
- **Objects**: As seen above, only record fields and interface members will be attached to objects without name
8585
mangling. Take this into account when sending to or receiving an object from Python.
@@ -158,7 +158,7 @@ let myEffect() =
158158
printfn "Effect!"
159159
fun () -> printfn "Cleaning up"
160160
161-
// Method from a JS module, expects a function
161+
// Method from a Python module, expects a function
162162
// that returns another function for disposing
163163
let useEffect (effect: unit -> (unit -> unit)): unit =
164164
importMember "my-js-module"

docs-src/communicate/py-from-fable.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ MyDataManager(myConfig) |> test myData
117117
```
118118

119119
:::{note}
120-
If you have a Python type declaration for the Python code you want to import, you can use
120+
If you have a Python type declaration for the Python code you want to import, you can use
121121
[ts2fable](https://github.com/fable-compiler/ts2fable) to help you write the F# bindings.
122122
:::
123123

@@ -189,7 +189,7 @@ def draw_bubble(id):
189189
we could use the same method we used with `alert.py`:
190190

191191
```fsharp
192-
open Fable.Core.JsInterop // needed to call interop tools
192+
open Fable.Core.PyInterop // needed to call interop tools
193193
194194
type ICanvas =
195195
abstract drawSmiley: (id:string) -> unit
@@ -204,7 +204,7 @@ mylib.drawSmiley "smiley" // etc..
204204
or we could use the `importMember` helper function to directly map the Python function to the F# function.
205205

206206
```fsharp
207-
open Fable.Core.JsInterop // needed to call interop tools
207+
open Fable.Core.PyInterop // needed to call interop tools
208208
209209
module Canvas =
210210
// here we just import a member function from canvas.js called drawSmiley.
@@ -235,7 +235,7 @@ let aDifferentName: string = import "myString" "my-lib"
235235
// Py: from my_lib import my_string
236236
```
237237

238-
Occasionally, you may need to import Python purely for its side-effects.
238+
Occasionally, you may need to import Python purely for its side-effects.
239239

240240
For this, use `importSideEffects`.
241241

@@ -285,33 +285,33 @@ The content of `Emit` will not be checked by the F# compiler so it's not advised
285285
Now let's work with Emit and look at a new example with the following `my_class.py`:
286286

287287
```py
288-
import math
288+
import math
289289

290290
class MyClass:
291291
# Note the constructor accepts an object
292292
# with the `value` and `awesomeness` fields
293293
def __init__(self, value, awesomeness):
294294
self._value = value
295295
self._awesomeness = awesomeness
296-
296+
297297
@property
298298
def value()
299299
return this._value
300-
300+
301301

302302
@value.setter
303303
def set_value(self, new_alue)
304304
self._value = new_value
305-
305+
306306

307307
def is_awesome(self):
308308
return this._value == this._awesomeness
309-
309+
310310

311311
@staticmethod
312312
def getPI():
313313
return math.pi
314-
314+
315315

316316
```
317317

@@ -436,7 +436,7 @@ myMethod(U3.Case3 testValue)
436436
When passing arguments to a method accepting `U2`, `U3`... you can use the `!^` as syntax sugar so you don't need to type the exact case (the argument will still be type checked):
437437

438438
```fsharp
439-
open Fable.Core.JsInterop
439+
open Fable.Core.PyInterop
440440
441441
myMethod !^5 // Equivalent to: myMethod(U3.Case2 5)
442442
myMethod !^testValue
@@ -496,7 +496,7 @@ myLib.myMethod("vertical", "Horizontal");
496496
To create a plain JS object (aka POJO), use `createObj`:
497497

498498
```fsharp
499-
open Fable.Core.JsInterop
499+
open Fable.Core.PyInterop
500500
501501
let data =
502502
createObj [
@@ -573,7 +573,7 @@ sendToPy [
573573
```
574574

575575
:::{note}
576-
Fable can make the transformation at compile time when applying the list literal directly to `keyValueList`. That's why
576+
Fable can make the transformation at compile time when applying the list literal directly to `keyValueList`. That's why
577577
it's usually a good idea to inline the function containing the helper.
578578
:::
579579

docs/.buildinfo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Sphinx build info version 1
22
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
3-
config: c6e0a32b1ffc4227edef3400a2591539
3+
config: 65a62f5c8786decb6b98d7000b454921
44
tags: 645f666f9bcd5a90fca523b33c5a78b7

docs/communicate/fable-from-py.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -474,11 +474,11 @@ <h2>Name mangling<a class="headerlink" href="#name-mangling" title="Permalink to
474474
<span class="c1">// counting when it finds actual code</span><span class="w"></span>
475475
<span class="k">module</span><span class="w"> </span><span class="nn">A.Long.Namespace.RootModule</span><span class="w"></span>
476476

477-
<span class="c1">// The name of this function will be the same in JS</span><span class="w"></span>
477+
<span class="c1">// The name of this function will be the same in Python</span><span class="w"></span>
478478
<span class="k">let</span><span class="w"> </span><span class="nv">add</span><span class="w"> </span><span class="o">(</span><span class="n">x</span><span class="o">:</span><span class="w"> </span><span class="n">int</span><span class="o">)</span><span class="w"> </span><span class="o">(</span><span class="n">y</span><span class="o">:</span><span class="w"> </span><span class="n">int</span><span class="o">)</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">y</span><span class="w"></span>
479479

480480
<span class="k">module</span><span class="w"> </span><span class="nn">Nested</span><span class="w"> </span><span class="o">=</span><span class="w"></span>
481-
<span class="w"> </span><span class="c1">// This will be prefixed with the name of the module in JS</span><span class="w"></span>
481+
<span class="w"> </span><span class="c1">// This will be prefixed with the name of the module in Python</span><span class="w"></span>
482482
<span class="w"> </span><span class="k">let</span><span class="w"> </span><span class="nv">add</span><span class="w"> </span><span class="o">(</span><span class="n">x</span><span class="o">:</span><span class="w"> </span><span class="n">int</span><span class="o">)</span><span class="w"> </span><span class="o">(</span><span class="n">y</span><span class="o">:</span><span class="w"> </span><span class="n">int</span><span class="o">)</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="n">y</span><span class="w"></span>
483483
</pre></div>
484484
</div>
@@ -527,7 +527,7 @@ <h2>Common types and objects<a class="headerlink" href="#common-types-and-object
527527
</ul>
528528
<blockquote>
529529
<div><p>If the dictionary or hashset requires custom or structural equality, Fable will generate a custom type, but it will
530-
share the same properties as JS maps and sets.</p>
530+
share the same properties as Python maps and sets.</p>
531531
</div></blockquote>
532532
<ul class="simple">
533533
<li><p><strong>Objects</strong>: As seen above, only record fields and interface members will be attached to objects without name
@@ -602,7 +602,7 @@ <h3>Using delegates for disambiguation<a class="headerlink" href="#using-delegat
602602
<span class="w"> </span><span class="n">printfn</span><span class="w"> </span><span class="s">&quot;Effect!&quot;</span><span class="w"></span>
603603
<span class="w"> </span><span class="k">fun</span><span class="w"> </span><span class="bp">()</span><span class="w"> </span><span class="o">-&gt;</span><span class="w"> </span><span class="n">printfn</span><span class="w"> </span><span class="s">&quot;Cleaning up&quot;</span><span class="w"></span>
604604

605-
<span class="c1">// Method from a JS module, expects a function</span><span class="w"></span>
605+
<span class="c1">// Method from a Python module, expects a function</span><span class="w"></span>
606606
<span class="c1">// that returns another function for disposing</span><span class="w"></span>
607607
<span class="k">let</span><span class="w"> </span><span class="nv">useEffect</span><span class="w"> </span><span class="o">(</span><span class="n">effect</span><span class="o">:</span><span class="w"> </span><span class="kt">unit</span><span class="w"> </span><span class="o">-&gt;</span><span class="w"> </span><span class="o">(</span><span class="kt">unit</span><span class="w"> </span><span class="o">-&gt;</span><span class="w"> </span><span class="kt">unit</span><span class="o">)):</span><span class="w"> </span><span class="kt">unit</span><span class="w"> </span><span class="o">=</span><span class="w"></span>
608608
<span class="w"> </span><span class="n">importMember</span><span class="w"> </span><span class="s">&quot;my-js-module&quot;</span><span class="w"></span>

docs/communicate/py-from-fable.html

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,7 @@ <h3>Let’s practice! 2nd try!<a class="headerlink" href="#let-s-practice-2nd-tr
733733
</pre></div>
734734
</div>
735735
<p>we could use the same method we used with <code class="docutils literal notranslate"><span class="pre">alert.py</span></code>:</p>
736-
<div class="highlight-fsharp notranslate"><div class="highlight"><pre><span></span><span class="k">open</span><span class="w"> </span><span class="nn">Fable.Core.JsInterop</span><span class="w"> </span><span class="c1">// needed to call interop tools</span><span class="w"></span>
736+
<div class="highlight-fsharp notranslate"><div class="highlight"><pre><span></span><span class="k">open</span><span class="w"> </span><span class="nn">Fable.Core.PyInterop</span><span class="w"> </span><span class="c1">// needed to call interop tools</span><span class="w"></span>
737737

738738
<span class="k">type</span><span class="w"> </span><span class="nc">ICanvas</span><span class="w"> </span><span class="o">=</span><span class="w"></span>
739739
<span class="w"> </span><span class="k">abstract</span><span class="w"> </span><span class="n">drawSmiley</span><span class="o">:</span><span class="w"> </span><span class="o">(</span><span class="n">id</span><span class="o">:</span><span class="kt">string</span><span class="o">)</span><span class="w"> </span><span class="o">-&gt;</span><span class="w"> </span><span class="kt">unit</span><span class="w"></span>
@@ -746,7 +746,7 @@ <h3>Let’s practice! 2nd try!<a class="headerlink" href="#let-s-practice-2nd-tr
746746
</pre></div>
747747
</div>
748748
<p>or we could use the <code class="docutils literal notranslate"><span class="pre">importMember</span></code> helper function to directly map the Python function to the F# function.</p>
749-
<div class="highlight-fsharp notranslate"><div class="highlight"><pre><span></span><span class="k">open</span><span class="w"> </span><span class="nn">Fable.Core.JsInterop</span><span class="w"> </span><span class="c1">// needed to call interop tools</span><span class="w"></span>
749+
<div class="highlight-fsharp notranslate"><div class="highlight"><pre><span></span><span class="k">open</span><span class="w"> </span><span class="nn">Fable.Core.PyInterop</span><span class="w"> </span><span class="c1">// needed to call interop tools</span><span class="w"></span>
750750

751751
<span class="k">module</span><span class="w"> </span><span class="nn">Canvas</span><span class="w"> </span><span class="o">=</span><span class="w"></span>
752752
<span class="w"> </span><span class="c1">// here we just import a member function from canvas.js called drawSmiley.</span><span class="w"></span>
@@ -815,33 +815,33 @@ <h2>Emit, when F# is not enough<a class="headerlink" href="#emit-when-f-is-not-e
815815
<section id="let-s-do-it-use-emit">
816816
<h3>Let’s do it! Use Emit<a class="headerlink" href="#let-s-do-it-use-emit" title="Permalink to this headline">#</a></h3>
817817
<p>Now let’s work with Emit and look at a new example with the following <code class="docutils literal notranslate"><span class="pre">my_class.py</span></code>:</p>
818-
<div class="highlight-py notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">math</span>
818+
<div class="highlight-py notranslate"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">math</span>
819819

820820
<span class="k">class</span> <span class="nc">MyClass</span><span class="p">:</span>
821821
<span class="c1"># Note the constructor accepts an object</span>
822822
<span class="c1"># with the `value` and `awesomeness` fields</span>
823823
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">,</span> <span class="n">awesomeness</span><span class="p">):</span>
824824
<span class="bp">self</span><span class="o">.</span><span class="n">_value</span> <span class="o">=</span> <span class="n">value</span>
825825
<span class="bp">self</span><span class="o">.</span><span class="n">_awesomeness</span> <span class="o">=</span> <span class="n">awesomeness</span>
826-
826+
827827
<span class="nd">@property</span>
828828
<span class="k">def</span> <span class="nf">value</span><span class="p">()</span>
829829
<span class="k">return</span> <span class="n">this</span><span class="o">.</span><span class="n">_value</span>
830-
830+
831831

832832
<span class="nd">@value</span><span class="o">.</span><span class="n">setter</span>
833833
<span class="k">def</span> <span class="nf">set_value</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">new_alue</span><span class="p">)</span>
834834
<span class="bp">self</span><span class="o">.</span><span class="n">_value</span> <span class="o">=</span> <span class="n">new_value</span>
835-
835+
836836

837837
<span class="k">def</span> <span class="nf">is_awesome</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
838838
<span class="k">return</span> <span class="n">this</span><span class="o">.</span><span class="n">_value</span> <span class="o">==</span> <span class="n">this</span><span class="o">.</span><span class="n">_awesomeness</span>
839-
839+
840840

841841
<span class="nd">@staticmethod</span>
842842
<span class="k">def</span> <span class="nf">getPI</span><span class="p">():</span>
843843
<span class="k">return</span> <span class="n">math</span><span class="o">.</span><span class="n">pi</span>
844-
844+
845845

846846
</pre></div>
847847
</div>
@@ -949,7 +949,7 @@ <h3>Erase attribute<a class="headerlink" href="#erase-attribute" title="Permalin
949949
</pre></div>
950950
</div>
951951
<p>When passing arguments to a method accepting <code class="docutils literal notranslate"><span class="pre">U2</span></code>, <code class="docutils literal notranslate"><span class="pre">U3</span></code>… you can use the <code class="docutils literal notranslate"><span class="pre">!^</span></code> as syntax sugar so you don’t need to type the exact case (the argument will still be type checked):</p>
952-
<div class="highlight-fsharp notranslate"><div class="highlight"><pre><span></span><span class="k">open</span><span class="w"> </span><span class="nn">Fable.Core.JsInterop</span><span class="w"></span>
952+
<div class="highlight-fsharp notranslate"><div class="highlight"><pre><span></span><span class="k">open</span><span class="w"> </span><span class="nn">Fable.Core.PyInterop</span><span class="w"></span>
953953

954954
<span class="n">myMethod</span><span class="w"> </span><span class="o">!^</span><span class="mi">5</span><span class="w"> </span><span class="c1">// Equivalent to: myMethod(U3.Case2 5)</span><span class="w"></span>
955955
<span class="n">myMethod</span><span class="w"> </span><span class="o">!^</span><span class="n">testValue</span><span class="w"></span>
@@ -1005,7 +1005,7 @@ <h3>StringEnum<a class="headerlink" href="#stringenum" title="Permalink to this
10051005
<section id="plain-old-javascript-objects">
10061006
<h2>Plain Old JavaScript Objects<a class="headerlink" href="#plain-old-javascript-objects" title="Permalink to this headline">#</a></h2>
10071007
<p>To create a plain JS object (aka POJO), use <code class="docutils literal notranslate"><span class="pre">createObj</span></code>:</p>
1008-
<div class="highlight-fsharp notranslate"><div class="highlight"><pre><span></span><span class="k">open</span><span class="w"> </span><span class="nn">Fable.Core.JsInterop</span><span class="w"></span>
1008+
<div class="highlight-fsharp notranslate"><div class="highlight"><pre><span></span><span class="k">open</span><span class="w"> </span><span class="nn">Fable.Core.PyInterop</span><span class="w"></span>
10091009

10101010
<span class="k">let</span><span class="w"> </span><span class="nv">data</span><span class="w"> </span><span class="o">=</span><span class="w"></span>
10111011
<span class="w"> </span><span class="n">createObj</span><span class="w"> </span><span class="o">[</span><span class="w"></span>

docs/searchindex.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

poetry.lock

Lines changed: 9 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)