Overview of FSharp.Formatting
mainFSharp.Formatting package provides libraries and tools designed for processing F# script files, Markdown, and components used for documentation generation. Its primary command-line tool is fsdocs.repository·main·Indexed 19 days ago
https://github.com/fsprojects/fsharp.formattingA set of tools and libraries for processing F# scripts and Markdown, specifically tailored for documentation generation. It includes the fsdocs command-line tool for generating API documentation, supporting features such as literate F# script evaluation, polyglot notebook processing, and LaTeX rendering via MathJax.
FSharp.Formatting package provides libraries and tools designed for processing F# script files, Markdown, and components used for documentation generation. Its primary command-line tool is fsdocs.FSharp.Formatting is available on NuGet as a set of libraries for programmatic access to its core features. You can use it for:
When using fsdocs, you can customize your documentation at six different levels of complexity:
docs/index.md for a custom front page or docs/reference/Namespace.md to provide bespoke landing pages for specific namespaces (overriding generated content).FSharp.Formatting.ApiDocs API to generate a site using your own code.When running fsdocs, the tool automatically searches for projects/solutions in the working directory. To be included in the API documentation, a project must meet these criteria:
<OutputType> must be library.<IsTestProject> must not be true.<GenerateDocumentationFile> must be true.If you change these settings and the documentation doesn't update, try removing the .fsdocs/cache file.
.md and .fsx files located under the docs directory. These notebooks can then be executed in environments like MyBinder using the provided configuration files.To render a diagram, wrap your Mermaid syntax inside a <div> element that has the mermaid CSS class. The library will detect this class and render the text definition into a visual diagram.
<div class="mermaid">
graph LR
A[Input docs] --> B[fsdocs build]
B --> C[HTML output]
B --> D[API reference]
</div>It is recommended to install fsdocs-tool as a local dotnet tool to allow for independent version updates. First, create a dotnet tool manifest if one does not exist, then install the tool locally.
dotnet new tool-manifest
dotnet tool install --local fsdocs-toolYou can write Markdown documents containing embedded F# snippets and transform them into formatted HTML using the literate.fsx script provided by the FSharp.Formatting package. The document remains valid Markdown and supports standard features like unordered lists, bold, and emphasis.
# Example: Using Markdown Content
This file demonstrates how to write Markdown document with
embedded F# snippets that can be transformed into nice HTML
using the `literate.fsx` script from the [F# Formatting
package](http://fsprojects.github.io/FSharp.Formatting).Use the watch command to generate documentation and start a local web server. This is ideal for development as it handles the root path correctly for local HTTP serving.
Run the command:
dotnet fsdocs watch
By default, the server is available at http://localhost:8901.
dotnet fsdocs watchTo generate documentation for an F# project that includes project files, markdown, and script content (typically located in a docs directory), use the fsdocs command-line tool.
Follow these steps to install and run the tool:
dotnet tool install fsdocs-tool.dotnet fsdocs build.dotnet fsdocs watch to monitor changes and rebuild automatically.dotnet tool install fsdocs-tool
dotnet fsdocs build
dotnet fsdocs watchThe Markdown extensions support two modes for LaTeX:
$ delimiters (e.g., $ code $). You can also use $$ for inline mode.$$$ (do not include a closing $$$).When using inline mode, you must escape certain characters to prevent them from being interpreted as delimiters:
$ using $ \$ $ or $ \$var $.&, %, $, #, _, {, and }.x > 1, y < 1, x >= 1, or x <= 1.$ k_{n+1} = n^2 + k_n^2 - k_{n-1} $
$$$
A_{m,n} =
\begin{pmatrix}
a_{1,1} & a_{1,2} & \cdots & a_{1,n} \\
a_{2,1} & a_{2,2} & \cdots & a_{2,n} \\
\vdots & \vdots & \ddots & \vdots \\
a_{m,1} & a_{m,2} & \cdots & a_{m,n}
\end{pmatrix}Use dotnet fsdocs build to generate static files for a production environment (like GitHub Pages).
Local Preview Tip: If <PackageProjectUrl> is not set, opening the output files directly in a browser via file:// will result in broken links. To preview the build locally without a web server, pass a relative root:
dotnet fsdocs build --parameters root ./
dotnet fsdocs build --parameters root ./