Skip to content

Commit 3cb0332

Browse files
authored
Update docs (#75)
* Start fixing * Update docs
1 parent e80caa3 commit 3cb0332

File tree

123 files changed

+14844
-6876
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

123 files changed

+14844
-6876
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ instance/
7070

7171
# Sphinx documentation
7272
docs/_build/
73+
docs/_sources/
7374
docs-src/_build
7475

7576
# PyBuilder

Build.fs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ Target.create "Build" (fun _ ->
2222
run dotnet $"fable --exclude Fable.Core --lang Python --outDir {buildPath}" srcPath
2323
)
2424

25+
Target.create "Docs" (fun _ ->
26+
run poetry "run jb build docs-src --path-output docs" "."
27+
)
28+
2529
Target.create "Run" (fun _ ->
2630
run dotnet "build" srcPath
2731
)
@@ -56,6 +60,9 @@ let dependencies = [
5660
"Build"
5761
==> "Test"
5862

63+
"Build"
64+
==> "Docs"
65+
5966
"Build"
6067
==> "Pack"
6168
]

Helpers.fs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ let dotnet = createProcess "dotnet"
7676

7777
let pytest = createProcess "pytest"
7878
let poetry = createProcess "poetry"
79+
let jupyterBook = createProcess "jb"
7980

8081
let npm =
8182
let npmPath =

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,10 @@ It contains example code for using Fable Python with:
7171
- [Femoto](https://github.com/Zaid-Ajaj/Femto)
7272
- [AsyncRx](https://github.com/dbrattli/AsyncRx)
7373
- [Fable.Aether](https://xyncro.tech/aether/)
74-
- [Fable.Giraffe](https://github.com/dbrattli/Fable.Giraffe)
75-
- [Fable.Logging](https://github.com/dbrattli/Fable.logging)
74+
- [Fable.Giraffe](https://github.com/dbrattli/Fable.Giraffe), port of Giraffe to Fable.Python
75+
- [Fable.Logging](https://github.com/dbrattli/Fable.logging), logging for Fable.Python
7676
- [Fable.Requests](https://github.com/Zaid-Ajaj/Fable.Requests)
77+
- [Fable.Jupyter](https://github.com/fable-compiler/Fable.Jupyter), Jupyter Notebook using Fable.Python
7778
- [Fable.SimpleJson.Python](https://github.com/Zaid-Ajaj/Fable.SimpleJson.Python)
7879
- [Fable.Sedlex](https://github.com/thautwarm/Fable.Sedlex)
7980
- [Feliz.ViewEngine](https://github.com/dbrattli/Feliz.ViewEngine)

docs-src/index.md

Lines changed: 61 additions & 364 deletions
Large diffs are not rendered by default.

docs-src/intro.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ F# is already used on the server for web and cloud apps, and it's also used quit
3232

3333
F# is a great choice to build beautiful apps that run in the browser. F# is:
3434

35-
* Succinct with lightweight syntax
36-
* Robust with a great type system and pattern matching
37-
* Safe with immutability baked into the language
38-
* Supported by large companies (such as Microsoft and Jetbrains) and comes with commercial tooling support
35+
- Succinct with lightweight syntax
36+
- Robust with a great type system and pattern matching
37+
- Safe with immutability baked into the language
38+
- Supported by large companies (such as Microsoft and Jetbrains) and comes with commercial tooling support
3939

4040
When compared with Python, F# is safer, more robust, and more pleasant to read and write.
4141

docs-src/introduction/py-users-read-this.md

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,24 @@
44

55
Hi!
66

7-
We're happy you decided to try Fable. Since F# is a language originally created for the .NET environment, Fable uses some tools that come from there.
7+
We're happy you decided to try Fable. Since F# is a language originally created for the .NET environment, Fable uses
8+
some tools that come from there.
89

9-
Don't panic! There is enough documentation to explain how the .NET tools integrate in your environment. And there are basically only two things you need to know:
10+
Don't panic! There is enough documentation to explain how the .NET tools integrate in your environment. And there are
11+
basically only two things you need to know:
1012

1113
1. Fable uses F# project files (`.fsproj`) to list your F# code files and libraries.
12-
2. Fable uses NuGet to load F# libraries, which is the equivalent of NPM for the .NET environment
14+
2. Fable uses NuGet to load F# libraries, which is the equivalent of PyPI for the .NET environment
1315

14-
Voilà. Nothing else. We'll come to explanations later in the docs. But we promise, there's nothing you won't understand right away. Apart from these facts, it's all JavaScript!
16+
Voilà. Nothing else. We'll come to explanations later in the docs. But we promise, there's nothing you won't understand
17+
right away. Apart from these facts, it's all JavaScript!
1518

1619
**Welcome home!**
1720

18-
- Fable transpiles F# to ES2015 JavaScript, Fable uses the great [Babel](https://babeljs.io/) tool for that.
19-
- Fable integrates with the popular [Webpack](https://webpack.js.org/). And it's not hard to use another bundler.
20-
- JS Dependencies are listed in your common `package.json` file.
21-
- Unit testing is available through [Fable.Mocha](https://github.com/Zaid-Ajaj/Fable.Mocha) (but you can use another test runner if you wish).
22-
- In most cases, building and running a Fable project only requires to call `npm install` and `npm start`.
21+
- Fable transpiles F# to Python 3.9.
22+
% - Fable integrates with the popular [Webpack](https://webpack.js.org/). And it's not hard to use another bundler.
23+
- Python Dependencies are listed in your common `pyproject.toml` file.
24+
- Unit testing is available through [pytest](https://docs.pytest.org) (but you can use another test runner if you wish).
25+
- In most cases, building and running a Fable project only requires to call `dotnet fable --lang py` and `poetry run python`.
2326

24-
So since we're mainly using JavaScript tools, you won't be lost with Fable!
27+
So since we're using many of the well known Python tools, you won't be lost with Fable!

docs-src/new-to-fsharp/learning-the-language.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# Learning the language
22

3-
There are many resources available to learn F#. This section is only intended as a general guide targeted to JS developers, but is mainly contribution-driven and is still a work in progress. If you already know the basics of the language you can skip to [the next section](../2-steps/setup.html) or you can also check other sites and books about F# like:
3+
There are many resources available to learn F#. This section is only intended as a
4+
general guide targeted to Python developers, but is mainly contribution-driven and is still
5+
a work in progress. If you already know the basics of the language you can skip to [the
6+
next section](../2-steps/setup.html) or you can also check other sites and books about
7+
F# like:
48

59
- [Tour of F#](https://docs.microsoft.com/en-us/dotnet/fsharp/tour)
610
- [F# for Fun and Profit](https://fsharpforfunandprofit.com/)

docs-src/new-to-fsharp/let-keyword.md

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
# The let keyword
22

3-
`let` is the F# keyword used to bind any value to a name, it's used to bind the so called primitive types such as a `string` or an `integer`, to bind to a function or more complex structures such as arrays or records.
3+
`let` is the F# keyword used to bind any value to a name, it's used to bind the so called primitive types such as a
4+
`string` or an `integer`, to bind to a function or more complex structures such as arrays or records.
45

56
Here's how you can bind a string to an identifier named `x`:
67

78
```fsharp
89
let x = "some text"
910
```
1011

11-
The above snippet would be considered a constant in some other languages such as JavaScript. In F# there's no `var` or `const` there's only `let` and since in F# every value is immutable by default, that snippet is the equivalent of a constant.
12+
The above snippet would be considered a variable in some other languages such as Python. In F# there's no `var` or
13+
`const` there's only `let` and since in F# every value is immutable by default, that snippet is the equivalent of a
14+
constant.
1215

13-
Note that `let` in F# is different than `let` in JavaScript and this will be mentioned later on this page.
16+
Note that `let` in F# is different than assignment in Python and this will be mentioned later on this page.
1417

1518
We're going to see more on functions later but here's how you can bind a function to an identifier named `add`:
1619

@@ -19,11 +22,13 @@ let add x y =
1922
x + y
2023
```
2124

22-
In the above snippet a function that adds two integers is being bound to an identifier named `add` and then two values are being bound to the identifiers `x` and `y`.
25+
In the above snippet a function that adds two integers is being bound to an identifier named `add` and then two values
26+
are being bound to the identifiers `x` and `y`.
2327

2428
## Shadowing
2529

26-
In F#, bindings are immutable by default which means that normally one _can't_ reassign a value to a named binding, rather, if you try to do so using `let` what will happen is that you'll shadow an existing binding.
30+
In F#, bindings are immutable by default which means that normally one _can't_ reassign a value to a named binding,
31+
rather, if you try to do so using `let` what will happen is that you'll shadow an existing binding.
2732

2833
For instance, in the following example:
2934

@@ -32,7 +37,9 @@ let x = "the answer"
3237
let x = 42
3338
```
3439

35-
In this case `x` is not being redefined nor its type is being changed from a `string` to an `int`, instead there are two different bindings with the same name `x` to different values. Of course, this example is not very useful because one binding is happening right after the other, but consider the following:
40+
In this case `x` is not being redefined nor its type is being changed from a `string` to an `int`, instead there are two
41+
different bindings with the same name `x` to different values. Of course, this example is not very useful because one
42+
binding is happening right after the other, but consider the following:
3643

3744
```fsharp
3845
let printName name =
@@ -47,14 +54,20 @@ let printName name =
4754
printName "John Doe"
4855
```
4956

50-
Don't worry too much if you don't fully grasp the above code, the main goal of that snippet is to demonstrate that the function `printName` expects an argument named `name` and in its body it defines another function `stripLastName` that also expects an argument `name`. Inside the scope of `stripLastName` the `name` argument is creating a new binding and thus shadowing the `name` argument received on the `printName` function. And that can be asserted by the two prints at the end of the `printName` function.
57+
Don't worry too much if you don't fully grasp the above code, the main goal of that snippet is to demonstrate that the
58+
function `printName` expects an argument named `name` and in its body it defines another function `stripLastName` that
59+
also expects an argument `name`. Inside the scope of `stripLastName` the `name` argument is creating a new binding and
60+
thus shadowing the `name` argument received on the `printName` function. And that can be asserted by the two prints at
61+
the end of the `printName` function.
5162

5263
## Comparing with Python
5364

5465
The main differences that the `let` keyword in F# has from assignments in Python are:
5566

56-
- In Python one would use an assignment to define a named variable, and its value can be reassigned which is not the case in F#.
57-
- In Python assignments are scope bound, so one can declare a new variable with an already used name as long as it is in a different scope, in F# that can be done within the same scope.
67+
- In Python one would use an assignment to define a named variable, and its value can be reassigned which is not the
68+
case in F#.
69+
- In Python assignments are scope bound, so one can declare a new variable with an already used name as long as it is in
70+
a different scope, in F# that can be done within the same scope.
5871

5972
### References
6073

docs-src/your-fable-project/author-a-fable-library.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,13 @@ The last point may sound complicated but it's only a matter of adding a couple o
1818
</ItemGroup>
1919
```
2020

21-
That's all it takes to make your library compatible with Fable! In order to publish the package to Nuget check [the Microsoft documentation](https://docs.microsoft.com/en-us/nuget/quickstart/create-and-publish-a-package-using-the-dotnet-cli) or alternatively you can also [use Fake](https://fake.build/dotnet-nuget.html#Creating-NuGet-packages).
21+
That's all it takes to make your library compatible with Fable! In order to publish the package to Nuget check [the
22+
Microsoft
23+
documentation](https://docs.microsoft.com/en-us/nuget/quickstart/create-and-publish-a-package-using-the-dotnet-cli) or
24+
alternatively you can also [use Fake](https://fake.build/dotnet-nuget.html#Creating-NuGet-packages).
2225

2326
## Testing
2427

25-
It's a good idea to write unit tests for your library to make sure everything works as expected before publishing. The simplest way for that is to use a JS test runner like [Mocha](https://mochajs.org/), as in [this sample](https://github.com/fable-compiler/fable2-samples/tree/master/mocha). Or you can also use a library like [Fable.Mocha](https://github.com/Zaid-Ajaj/Fable.Mocha) containing more tools for Fable projects.
28+
It's a good idea to write unit tests for your library to make sure everything works as expected before publishing. The
29+
simplest way for that is to use a Python test runner like [pytest](https://pytest.org/), as in [this
30+
project](https://github.com/dbrattli/Fable.Giraffe).

0 commit comments

Comments
 (0)