Customization and Styling
When using fsdocs
, there are six levels of extra content development and styling.
-
Don't do any styling or documentation customization and simply write content. This is by far the simplest option to maintain.
-
Add content such as an
docs/index.md
to customize the front-page content for your generated docs. You can also add content such asdocs/reference/fslib.md
to give a bespoke landing page for one of your namespaces, e.g. here assumed to benamespace FsLib
. This will override any generated content. - Customize via Styling Parameters
- Customize via CSS
- Customize via a new template
- Customize by generating your own site using your own code
By default fsdocs
does no styling customization and uses the following defaults. These are the settings used to build
this site.
-
Uses the default template in docs/_template.html
-
Uses the default styles in docs/content/fsdocs-default.css.
-
Uses no custom styles in docs/content/fsdocs-custom.css.
- Uses no styling parameters except those extracted from the project files.
For your project, you don't need any of these files. However, you can add them if you wish, though if you adjust them there is no guarantee that your template will continue to work with future versions of F# Formatting.
Customizing via Styling Parameters
The following content parameters are particularly related to visual styling:
Substitution name |
Value (if not overriden by --parameters) |
---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
These basic entry-level styling parameters can be set in the project file or Directory.Build.props
.
For example:
|
As an example, here is a page with alternative styling.
Customizing via CSS
You can start styling by creating a file docs/content/fsdocs-theme.css
and adding entries to it.
It is loaded by the standard template.
CSS variables
The default template is heavily based
on CSS variables. These can easily be
override to customize the look and feel of the default theme.
A full list of the overrideable variables can be
found here.
|
Please be aware that the dark
mode in the default theme is using the same variables.
When you override a variable, it will also be used in dark
mode unless redefined in a [data-theme=dark]
CSS query.
CSS classes
The API documentation uses a set of fixed CSS classes:
CSS class |
Corresponding Content |
---|---|
|
generated tooltips |
|
generated xmldoc sections |
|
generated member lists (tables) |
|
usage in generated member lists |
|
tooltips in generated member lists |
|
documentation in generated member lists |
|
generated entity lists |
|
generated entity lists |
|
documentation in generated entity lists |
|
generated exception lists |
|
the 'summary' section of an XML doc |
|
the 'remarks' section of an XML doc |
|
the 'parameters' section of an XML doc |
|
a 'parameter' section of an XML doc |
|
a 'parameter' name of an XML doc |
|
the 'returns' section of an XML doc |
|
the 'example' section of an XML doc |
|
the 'notes' section of an XML doc |
|
a paragraph of an XML doc |
Some generated elements are given specific HTML ids:
HTML element selector |
Content |
---|---|
|
The navigation-bar |
|
The main menu on the left side |
|
The generated content |
|
The sub menu on the right side |
|
The search dialog |
|
The search box |
|
The logo |
If you write a new theme by CSS styling please contribute it back to FSharp.Formatting.
Customizing via a new template
You can do advanced styling by creating a new template. Add a file docs/_template.html
, likely starting
with the existing default template.
NOTE: To enable hot reload during development with
fsdocs watch
in a custom_template.html
file, make sure to add the single line{{fsdocs-watch-script}}
to your<head>
tag. NOTE: There is no guarantee that your template will continue to work with future versions of F# Formatting. If you do develop a good template please consider contributing it back to F# Formatting.
Customizing menu items by template
You can add advanced styling to the sidebar generated menu items by creating a new template for it.
fsdoc
will look for menu templates in the --input
folder, which defaults to the docs folder.
To customize the generated menu-item headers, use file _menu_template.html
with starting template:
|
Similarly, to customize the individual menu item list, use file _menu-item_template.html
with the starting template:
|
Do note that files must be added before running, or won't be generated.
In case you want to get a unique identifier for a header or menu item, you can use {{fsdocs-menu-header-id}}
and {{fsdocs-menu-item-id}}
, respectively.
Injecting additional html into the default template
Occasionally, you may find the need to make small customizations to the default template, such as adding a Google
Analytics snippet or including additional style or script tags. To address this scenario, you can create two
files: _head.html
and/or _body.html
.
The content within these files will serve as replacements for the {{fsdocs-head-extra}}
and {{fsdocs-body-extra}}
placeholders, which are utilized in the default template.
Customizing by generating your own site using your own code
The FSharp.Formatting.ApiDocs
namespace includes a GenerateModel
that captures
the results of documentation preparation in ApiDocsModel
and allows you to
generate your own site using your own code.
NOTE: The ApiDocsModel API is undergoing change and improvement, and there is no guarantee that your bespoke site generation will continue to work with future versions of F# Formatting. NOTE: The
ApiDocsModel
currently includes some generated HTML with some specific style tags. In the long term these may be removed from the design of that component.