fsprojects / FSharp.Formatting

F# tools for generating documentation (Markdown processor and F# code formatter)
https://fsprojects.github.io/FSharp.Formatting/
Other
464 stars 155 forks source link

Use fssnip highlighter in API docs code examples. #780

Closed nhirschey closed 1 year ago

nhirschey commented 1 year ago

This adds syntax highlighting to API docs code examples. PR #762 from @yazeedobaid was solving the same problem, but it relied on external tools such as highlight.js to do the highlighting and required users to add that dependency. This PR uses FSharp.Formatting's baked-in highlighter to achieve the same goal.

For example, building the F# core docs Array.averageBy example using this PR:

image


In comparison, this is how it looks now:

image

nhirschey commented 1 year ago

@yazeedobaid are you happy with this version?

nhirschey commented 1 year ago

Now with the extra trailing blank line after the last line of code removed (adding back a prior dsyme fix). Should be ready for release.

image

yazeedobaid commented 1 year ago

@nhirschey tested the branch with the FAKE website and all is good. But I may add back that padding by a CSS rule for the code examples since it is more visually looking good with some padding: image

That is FAKE related. Thanks for the update.

dsyme commented 1 year ago

@nhirschey Fantastic work, thank you!