$ show fsprojects/FSharp.Formatting
FSharp.Formatting is a mature, production-grade documentation generation toolchain for the F# ecosystem. It consists of several libraries (Markdown parsing, code syntax highlighting with F# Compiler Service integration, API documentation generation from XML doc comments, literate programming support for .fsx and .ipynb files) and a CLI tool (`fsdocs`) that builds static documentation websites with search, theme toggling, and a live-reload dev server. The system is primarily a developer tool used by F# projects to produce API reference sites and literate documentation. Its architecture is modular: the Markdown parser, code formatter, literate processor, and template engine are separate libraries that can be used independently. The CLI orchestrates these libraries, cracking MSBuild projects for metadata, evaluating code via F# Interactive, and generating output in HTML, LaTeX, Markdown, and Jupyter notebook formats. External dependencies include the F# Compiler Service, Newtonsoft.Json, and a bundled version of Yaaf.FSharp.Scripting. The codebase demonstrates deep integration with the F# compiler's type-checking and symbol resolution APIs, but also shows signs of organic growth: duplicated test data, a legacy C# MarkdownSharp project, and some conditionally compiled code for .NET Framework compatibility.
The LLM identified 6 files worth highlighting for reuse:
A discriminated-union-based HTML/SVG element tree that provides a type-safe, composable way to generate HTML fragments. It is used throughout the formatting libraries and can be extracted as a standalone HTML builder for any F# project needing programmatic HTML generation without string concatenation.
A collection of F# active patterns (e.g., `(|StartsWith|_|)`, `(|DelimitedWith|_|)`, `(|BracketDelimited|_|)`) that enable composable, declarative string and list parsing. These patterns are reusable across any project that needs lightweight parsing without a full parser combinator library.
Implements smart line-wrapping for F# type signatures by leveraging the F# Compiler Service's own parser. It produces human-readable, width-constrained signature output without sacrificing correctness. This component can be reused in any F# tooling (e.g., IDE plugins, documentation generators) that renders type signatures.
Defines a complete F# type model for Jupyter notebook files (nbformat v4), including cells, metadata, and output types. It can be extracted and used independently for reading, manipulating, or generating .ipynb files in any F# application.
A navigation menu builder that takes a list of page entries and generates a nested HTML menu using template substitution. The logic for constructing ancestors, grouping by directory, and generating active/inactive states is self-contained and reusable for any static site generator.
Defines the interface for a development server that watches source files, incrementally rebuilds only changed pages, and serves them from memory with a dependency graph for cache invalidation. The pattern of event-based file watching + dependency tracking + lazy in-memory serving is reusable for other build tools.