diff --git a/src/FSharp.Formatting.CodeFormat/CommentFilter.fs b/src/FSharp.Formatting.CodeFormat/CommentFilter.fs index 171afd84..f71dcfa3 100644 --- a/src/FSharp.Formatting.CodeFormat/CommentFilter.fs +++ b/src/FSharp.Formatting.CodeFormat/CommentFilter.fs @@ -2,6 +2,9 @@ // F# CodeFormat (CommentProcessing.fs) // (c) Tomas Petricek, 2012, Available under Apache 2.0 license. // -------------------------------------------------------------------------------------- +/// Internal module for pre-processing F# source snippets: extracting named snippet regions +/// (// [snippet:Name] / // [/snippet]), shrinking omitted blocks +/// ((*[omit:...]*)..(*[/omit]*)), and surfacing FSI output markers (// [fsi:...]). module internal FSharp.Formatting.CodeFormat.CommentFilter open System.Text diff --git a/src/FSharp.Formatting.CodeFormat/LatexFormatting.fs b/src/FSharp.Formatting.CodeFormat/LatexFormatting.fs index 44c314d3..c760cdd8 100644 --- a/src/FSharp.Formatting.CodeFormat/LatexFormatting.fs +++ b/src/FSharp.Formatting.CodeFormat/LatexFormatting.fs @@ -3,6 +3,7 @@ // (c) Tomas Petricek, 2012, Available under Apache 2.0 license. // -------------------------------------------------------------------------------------- +/// Internal module for rendering F# code snippets as LaTeX using the lstlistings environment. module internal FSharp.Formatting.CodeFormat.Latex open System @@ -28,6 +29,8 @@ let specialChars = "~", @"{\textasciitilde}" "^", @"{\textasciicircum}" |] +/// Escape a string for safe inclusion in LaTeX source, +/// substituting all LaTeX special characters with their command equivalents. let latexEncode s = specialChars |> Array.fold (fun (acc: string) (k, v) -> acc.Replace(k, v)) (HttpUtility.HtmlDecode s) diff --git a/src/FSharp.Formatting.CodeFormat/SourceCode.fs b/src/FSharp.Formatting.CodeFormat/SourceCode.fs index d8522adf..7d6d6a5b 100644 --- a/src/FSharp.Formatting.CodeFormat/SourceCode.fs +++ b/src/FSharp.Formatting.CodeFormat/SourceCode.fs @@ -82,8 +82,10 @@ type SourceError = /// error kind and the message | SourceError of start: (int * int) * finish: (int * int) * errorKind: ErrorKind * message: string +/// Internal helpers for mapping TokenKind values to CSS class names. module internal CodeFormatHelper = + /// Map a TokenKind to the corresponding CSS class name string using the default CSS class map. let defaultTokenMap kind = match kind with | TokenKind.Comment -> CSS.Comment diff --git a/src/FSharp.Formatting.Literate/ParseScript.fs b/src/FSharp.Formatting.Literate/ParseScript.fs index 8873edd4..d5987ca1 100644 --- a/src/FSharp.Formatting.Literate/ParseScript.fs +++ b/src/FSharp.Formatting.Literate/ParseScript.fs @@ -36,6 +36,7 @@ module internal CodeBlockUtils = | _ -> false) |> List.ofSeq + /// Split a string into lines, normalising line endings. let splitLines (s: string) = s.Replace("\r\n", "\n").Split([| '\n' |]) @@ -149,15 +150,18 @@ open CodeBlockUtils /// as hide, define and include. type internal ParseScript(parseOptions, ctx: CompilerContext) = + /// Determine the visibility of a code block based on its commands dictionary. let getVisibility cmds = match cmds with | Command "hide" _ -> LiterateCodeVisibility.HiddenCode | Command "define" name -> LiterateCodeVisibility.NamedCode name | _ -> LiterateCodeVisibility.VisibleCode + /// Return true if a code block should be evaluated, based on global noEval flag and block commands. let getEvaluate noEval (cmds: IDictionary<_, _>) = not (noEval || cmds.ContainsKey("do-not-eval")) + /// Extract paragraph options (conditional defines) from block commands. let getParaOptions cmds = match cmds with | Command "condition" name when not (String.IsNullOrWhiteSpace name) -> { Condition = Some name } diff --git a/src/FSharp.Formatting.Literate/Transformations.fs b/src/FSharp.Formatting.Literate/Transformations.fs index 1546bbb2..cb998dc9 100644 --- a/src/FSharp.Formatting.Literate/Transformations.fs +++ b/src/FSharp.Formatting.Literate/Transformations.fs @@ -10,6 +10,9 @@ open FSharp.Formatting.CodeFormat open FSharp.Formatting.Literate.Evaluation open FSharp.Formatting.Markdown +/// Internal transformations applied to a LiterateDocument: +/// formatting F# code snippets, evaluating them with FSI, resolving references, +/// and replacing literate paragraphs with their final HTML/LaTeX/Fsx representations. module internal Transformations = // ---------------------------------------------------------------------------------------------- // Replace all code snippets (assume F#) with their nicely formatted versions @@ -460,7 +463,8 @@ module internal Transformations = | _ -> () ] - /// Replace all special 'LiterateParagraph' elements recursively using the given lookup dictionary + /// Format a non-F# language-tagged code block as an HTML table with optional line numbers, + /// using the CSharpFormat syntax highlighter for the given language. let replaceHtmlTaggedCode (ctx: LiterateProcessingContext) (lang: string) (code: string) = let sb = new System.Text.StringBuilder() let writer = new System.IO.StringWriter(sb)