This is a guide on how to create content for the blog post that marks the final submission for your project work.
Table of contents
! This document is WIP. Please finish your project before writing the blog post to prevent usage of outdated information. !
At this point you should have the .NET SDK installed, as it is a mandatory installation. Otherwise we strongly recommend to consider first writing some code and getting into the project before reading to deep into how to create a blog post about your results.
That said, follow these steps to set up the blogpost project:
cd replace/this/text/with/path/to/your/folder
)dotnet new tool-manifest
command to create a dotnet tool resgistry in the folder. This is basically a document that tracks what tools can be used in your project.dotnet new -i FsLab.DocumentationTemplate
. You can learn more about this template heredotnet new fslab-docs
. When asked for permission to install the fsdocs tool, type y
to continue.dotnet fsdocs watch --eval --clean
. Here is what this means in a bit more detail:
dotnet
command prefix always means "use the dotnet CLI(command line interface) to do the following:"fsdocs
means you will use the fsdocs
toolwatch
means that you will use fsdocs
in watch mode, an interactive mode where you will have the live output of your documents open in a local browser and can see the changes live.--eval
means that you want to evaluate (meaning execute) any F# script content. More on that later.--clean
means that you want to clean up any leftover stuff from the last run before starting.ctrl + c
in the terminal.Coming soonTM
Coming soonTM
If you followed the setup steps, you have a folder set up to create content in. You can always preview your content by running dotnet fsdocs watch --eval --clean
.
Content for fsdocs can be created in two kinds of files: markdown
(.md
) files and literate F# scripts
. The core difference is that you can only write styled text in markdown, while you can add real code in literate F# scripts.
Markdown is a set of easy to use formatting rules to create structured text. In fact, the very document you are reading is written in markdown.
for example, this is how to create a heading:
#Hi, i am a large heading
will become:
You may have realized that your initialized template contains a markdown cheatsheat. Use this cheatsheet for all your markdown needs. an online version is also available here.
You might also have realized that the styling of your markdown looks different than this page (see the screenshot below for reference as well). That is not a problem and depends on the styling that fsdocs uses. please use the default one that is coming with the template.
Literate F# scripts are a powerfull fusion of markdown with F# scripting and advanced formatting methods.
With literate F# scripts you can tell the full story from the problem to your solution and show of how it works and what kinds of results it produces.
To write markdown, just put it in these parentheses `(** ... *)
like this: (** # i am a heading! *)
. you can also do that across multiple lines.
(**
# Hi!
*markdown here :D*
*)
But the real awesome thing is that you can write normal F# code that will be rendered beautifully on your generated webpage.
It also contains hover tooltips! Try it by hovering over some of the code below with your mouse!
let a = 42
///try hovering over myFunction!
let myFunction someParameter = printfn $"i got some {someParameter}!"
there are multiple ways of including output of function calls or values of bindings.
To include the output of a function that returns unit (so for example a printfn
call), put (***include-output***)
below the call:
printfn "Hi"
(***include-output***)
which will be rendered as:
printfn "Hi"
|
To include the value of a binding, use (***include-value: yourBindingname***)
:
so this:
let x = 42
(***include-value:x***)
becomes:
let x = 42
|
Chart rendering is a special value inclusion. Because Plotly.NET charts create html already, the raw string value of them (created by Chart.toChartHTML
) has to be included via (***include-it-raw***)
like this:
#r "nuget: Plotly.NET, 2.0.0-preview.16"
open Plotly.NET
let myChart = Chart.Line([1,42; 2,69; 3,1337])
myChart
|> GenericChart.toChartHTML
(***include-it-raw***)
which will be rendered as:
#r "nuget: Plotly.NET, 2.0.0-preview.16"
open Plotly.NET
let myChart = Chart.Line([1,42; 2,69; 3,1337])
myChart
|> GenericChart.toChartHTML
You can also hide blocks via (***hide***)
, a good use case is the inclusion of charts:
let myChart2 = Chart.Spline([1,42; 2,69; 3,1337])
(***hide***)
myChart2
|> GenericChart.toChartHTML
(***include-it-raw***)
which will omit the part of the code block that is only there to display the chart:
let myChart2 = Chart.Spline([1,42; 2,69; 3,1337])