fsprojects / fantomas

FSharp source code formatter
https://fsprojects.github.io/fantomas
Other
760 stars 190 forks source link

Add doc comments in SyntaxNode.fs giving an example of what each node looks like #2991

Open josh-degraw opened 7 months ago

josh-degraw commented 7 months ago

As a contributor who hasn't spent a ton of time in the F# compiler interacting with the AST, I often find myself unsure of what a given node looks like in practice, and I have to do a lot of trial & error (usually in fantomas-tools) checking things to see what node matches what text. I feel like it would be super helpful to new and existing contributors to have a minimal example for each non-trivial node.

For example:

/// Example:
/// `fun x -> x`
type ExprLambdaNode(funNode: SingleTextNode, parameters: Pattern list, arrow: SingleTextNode, expr: Expr, range) =
    inherit NodeBase(range)

This could be especially useful for some more complex or less intuitive nodes and those with compiler-centered abbreviations (e.g. PatIsInstNode, ExprAppNode).

I believe this could help encourage newer contributors and also help current contributors understand the codebase and patterns better.