Skip to content

Commit

Permalink
feat!: build/Actions improvements; Markup -> HTML (fsprojects#14)
Browse files Browse the repository at this point in the history
* Added referencing a nuget package
* Use GitHub Actions to generate HTML
* Updated README to reflect new home 

---------

Co-authored-by: ⚙︎ Greg <[email protected]>
Co-authored-by: Ruben Bartelink <[email protected]>
  • Loading branch information
3 people authored Oct 14, 2023
1 parent acff9a0 commit 3425c66
Show file tree
Hide file tree
Showing 14 changed files with 145 additions and 556 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Build
on: [push]
jobs:

# BUILD
build:
name: Convert to HTML
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ZacJW/[email protected]
with:
input_files: '[["docs/*.md"]]'
output_files: '["docs/index.html"]'
builtin_stylesheet: 'docs/fsharp-cheatsheet.css'
packages: 'pymdown-extensions'
extensions: '["pymdownx.extra"]'
- uses: actions/[email protected]
with:
path: 'docs/'

# DEPLOY
deploy:
needs: build

# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source

# Deploy to the github-pages environment
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}

# Specify runner + deployment step
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2 #
20 changes: 13 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
fsharp-cheatsheet
=================

A typesetted F# Cheatsheet in PDF and HTML formats using F# literate tools
An F# Cheatsheet in Markup and HTML formats

## Introduction

This is an attempt to replace the old and obsolete [F# Cheat Sheet](http://www.samskivert.com/code/fsharp/fsharp-cheat-sheet.pdf).

The raw content of this cheatsheet can be edited at [fsharp-cheatsheet.md](docs/fsharp-cheatsheet.md).

In order to build PDF and HTML documentation, please run the build script in [build.cmd](tools/build.cmd). We assume that `pdflatex.exe` is in PATH variable to be able generate PDF files.
HTML version is online at https://spiraloss.github.io/fsharp-cheatsheet

## Contributing

This resource was, is and should remain a community effort. If you're learning F# and something important you didn't learn about isn't covered, you're the very best person to point that out and phrase it in a way that someone new can get running with. If someone posts a PR, the more diversity of reviewers we get, the better. That said, the best PRs are small ones that touch one piece at a time and can hence be reviewed and merged rapidly.

PDF version can be downloaded [here](https://github.com/dungpa/fsharp-cheatsheet/raw/gh-pages/fsharp-cheatsheet.pdf).
HTML version is online at http://dungpa.github.io/fsharp-cheatsheet/.
Primary maintainer: @SpiralOSS (backup: @bartelink)

**Comments, suggestions and corrections are always welcome.**
## Acknowledgements

Anh-Dung Phan (@dungpa) created and maintained the repo for many years before donating it to community ownership under fsprojects

The original inspiration was the (now obsolete) http://www.samskivert.com/code/fsharp/fsharp-cheat-sheet.pdf

## License

The documents are available under Apache 2.0 license.
For more information see the [License file](LICENSE.md).
77 changes: 77 additions & 0 deletions docs/fsharp-cheatsheet.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
body {
font-family: 'Arial', sans-serif;
margin: 40px auto;
max-width: 800px;
line-height: 1.6;
color: #333;
background-color: #f7f7f7;
}

h1, h2, h3, h4, h5, h6 {
margin-top: 1.2em;
}

h1 {
font-size: 2em;
border-bottom: 2px solid #ddd;
}

h2 {
font-size: 1.5em;
}

h3 {
font-size: 1.3em;
}

p {
margin-bottom: 1.2em;
}

a {
color: #0077cc;
text-decoration: none;
}

a:hover {
text-decoration: underline;
}

strong {
font-weight: bold;
}

em {
font-style: italic;
}

ul, ol {
margin: 20px 0;
padding-left: 40px;
}

li {
margin-bottom: 10px;
}

blockquote {
border-left: 4px solid #ddd;
padding-left: 15px;
margin: 20px 0;
font-style: italic;
}

code {
font-family: 'Courier New', monospace;
background-color: #eee;
padding: 2px 5px;
border-radius: 3px;
}

pre {
font-family: 'Courier New', monospace;
background-color: #eee;
padding: 10px;
border-radius: 3px;
overflow-x: auto;
}
22 changes: 14 additions & 8 deletions docs/fsharp-cheatsheet.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
This cheatsheet glances over some of the common syntax of [F# 3.0](http://research.microsoft.com/en-us/um/cambridge/projects/fsharp/manual/spec.html).
If you have any comments, corrections, or suggested additions, please open an issue or send a pull request to [https://github.com/dungpa/fsharp-cheatsheet](https://github.com/dungpa/fsharp-cheatsheet).
This cheatsheet aims to succinctly cover the most important aspects of [F# 6.0](http://research.microsoft.com/en-us/um/cambridge/projects/fsharp/manual/spec.html).

The Microsoft [F# Documentation](https://learn.microsoft.com/en-us/dotnet/fsharp/) is complete and authoritative and has received a lot of love in recent years; it's well worth the time investment to read. Only after you've got the lowdown here of course ;)

If you have any comments, corrections, or suggested additions, please open an issue or send a pull request to [https://github.com/fsprojects/fsharp-cheatsheet](https://github.com/fsprojects/fsharp-cheatsheet). Questions are best addressed via the [F# slack](https://fsharp.org/guides/slack) or the [F# discord](https://discord.me/fsharp).

Contents
--------
Expand Down Expand Up @@ -72,7 +75,7 @@ Other common examples are `F` or `f` for 32-bit floating-point numbers, `M` or `
// [fsi:val d : decimal = 0.7833M]
// [fsi:val bi : System.Numerics.BigInteger = 9999]

See [Literals (MSDN)](http://msdn.microsoft.com/en-us/library/dd233193.aspx) for complete reference.
See [Literals (MS Learn)](https://learn.microsoft.com/en-us/dotnet/fsharp/language-reference/literals) for complete reference.

<a name="Functions"></a>Functions
---------
Expand Down Expand Up @@ -150,7 +153,7 @@ or implicitly via `function` keyword:
| 1 -> 1
| n -> fib' (n - 1) + fib' (n - 2)

For more complete reference visit [Pattern Matching (MSDN)](http://msdn.microsoft.com/en-us/library/dd547125.aspx).
For more complete reference visit [Pattern Matching (MS Learn)](https://learn.microsoft.com/en-us/dotnet/fsharp/language-reference/pattern-matching).

<a name="Collections"></a>Collections
-----------
Expand Down Expand Up @@ -294,7 +297,7 @@ Records are essentially sealed classes with extra topping: default immutability,
| Node(l, _, r) -> 1 + max (depth l) (depth r)
| Leaf -> 0

F# Core has a few built-in discriminated unions for error handling, e.g., [Option](http://msdn.microsoft.com/en-us/library/dd233245.aspx) and [Choice](http://msdn.microsoft.com/en-us/library/ee353439.aspx).
F# Core has built-in discriminated unions for error handling, e.g., [`option`](https://learn.microsoft.com/en-us/dotnet/fsharp/language-reference/options) and [`Result`](https://learn.microsoft.com/en-us/dotnet/fsharp/language-reference/results).

let optionPatternMatch input =
match input with
Expand Down Expand Up @@ -466,12 +469,15 @@ Load another F# source file into FSI.
#load "../lib/StringParsing.fs"

Reference a .NET assembly (`/` symbol is recommended for Mono compatibility).

#r "../lib/FSharp.Markdown.dll"
Reference a .NET assembly:

#r "../lib/FSharp.Markdown.dll"

Reference a nuget package

#r "nuget: FSharp.Data, 6.3.0"
#r "nuget:Serilog.Sinks.Console" // latest production release
#r "nuget: FSharp.Data, 6.3.0" // specific version
#r "nuget:Equinox, *-*" // latest version, including `-alpha`, `-rc` version etc

Include a directory in assembly search paths.

Expand Down
Binary file removed lib/FSharp.Markdown.dll
Binary file not shown.
184 changes: 0 additions & 184 deletions templates/template-cheatsheet.tex

This file was deleted.

Loading

0 comments on commit 3425c66

Please sign in to comment.