Header menu logo FSharp.Formatting

Literate Notebooks

Content may be created using .NET interactive polyglot notebooks as the input file. Notebooks are processed by converting the notebook to a literate .fsx script and then passing the script through the script processing pipeline. Markdown notebook cells are passed through as comments surrounded by (** and *), F# code cells are passed through as code, and non-F# code is passed through as markdown fenced code blocks between (** and *) comment markers.

The fsdocs tool uses dotnet-repl to evaluate polyglot notebooks. You need this tool to evaluate notebooks using dotnet fsdocs [build|watch] --eval. It can be installed into your local tool manifest using the command dotnet tool install dotnet-repl.

F# Formatting tries to faithfully reproduce a notebook's native appearance when generating documents. Notebook cell outputs are passed through unchanged to preserve the notebook's html output. The below snippet demonstrates a notebook's html output for F# records, which differs from the output you would get with the same code inside a literate scripts.

type ContactCard =
    { Name: string
      Phone: string
      ZipCode: string }

// Create a new record
{ Name = "Alf"; Phone = "(555) 555-5555"; ZipCode = "90210" }

{ Name = "Alf"\n Phone = "(555) 555-5555"\n ZipCode = "90210" }
Name
"Alf"
Phone
"(555) 555-5555"
ZipCode
"90210"

type ContactCard = { Name: string Phone: string ZipCode: string }
Multiple items
val string: value: 'T -> string

--------------------
type string = System.String

Type something to start searching.