Writers

Documenter.WritersModule

A module that provides several renderers for Document objects. The supported formats are currently:

  • :markdown – the default format.
  • :html – generates a complete HTML site with navigation and search included.
  • :latex – generates a PDF using LuaLaTeX.
source
Documenter.Writers.renderMethod

Writes a Documents.Document object to .user.build directory in the formats specified in the .user.format vector.

Adding additional formats requires adding new Selector definitions as follows:

abstract type CustomFormat <: FormatSelector end

Selectors.order(::Type{CustomFormat}) = 4.0 # or a higher number.
Selectors.matcher(::Type{CustomFormat}, fmt, _) = fmt === :custom
Selectors.runner(::Type{CustomFormat}, _, doc) = CustomWriter.render(doc)

# Definition of `CustomWriter` module below...
source
Documenter.Writers.HTMLWriterModule

A module for rendering Document objects to HTML.

Keywords

HTMLWriter uses the following additional keyword arguments that can be passed to Documenter.makedocs: authors, pages, sitename, version. The behavior of HTMLWriter can be further customized by setting the format keyword of Documenter.makedocs to a HTML, which accepts the following keyword arguments: analytics, assets, canonical, disable_git, edit_link, prettyurls, collapselevel, sidebar_sitename, highlights, mathengine and footer.

sitename is the site's title displayed in the title bar and at the top of the *navigation menu. This argument is mandatory for HTMLWriter.

pages defines the hierarchy of the navigation menu.

Experimental keywords

version specifies the version string of the current version which will be the selected option in the version selector. If this is left empty (default) the version selector will be hidden. The special value git-commit sets the value in the output to git:{commit}, where {commit} is the first few characters of the current commit hash.

HTML Plugin options

The HTML Documenter.Plugin provides additional customization options for the HTMLWriter. For more information, see the HTML documentation.

Page outline

The HTMLWriter makes use of the page outline that is determined by the headings. It is assumed that if the very first block of a page is a level 1 heading, then it is intended as the page title. This has two consequences:

  1. It is then used to automatically determine the page title in the navigation menu and in the <title> tag, unless specified in the .pages option.
  2. If the first heading is interpreted as being the page title, it is not displayed in the navigation sidebar.
source
Documenter.Writers.HTMLWriter.HTMLType
HTML(kwargs...)

Sets the behavior of HTMLWriter.

Keyword arguments

prettyurls (default true) – allows toggling the pretty URLs feature.

By default (i.e. when prettyurls is set to true), Documenter creates a directory structure that hides the .html suffixes from the URLs (e.g. by default src/foo.md becomes src/foo/index.html, but can be accessed with via src/foo/ in the browser). This structure is preferred when publishing the generate HTML files as a website (e.g. on GitHub Pages), which is Documenter's primary use case.

If prettyurls = false, then Documenter generates src/foo.html instead, suitable for local documentation builds, as browsers do not normally resolve foo/ to foo/index.html for local files.

To have pretty URLs disabled in local builds, but still have them enabled for the automatic CI deployment builds, you can set prettyurls = get(ENV, "CI", nothing) == "true" (the specific environment variable you will need to check may depend on the CI system you are using, but this will work on Travis CI).

disable_git can be used to disable calls to git when the document is not in a Git-controlled repository. Without setting this to true, Documenter will throw an error and exit if any of the Git commands fail. The calls to Git are mainly used to gather information about the current commit hash and file paths, necessary for constructing the links to the remote repository.

edit_link can be used to specify which branch, tag or commit (when passed a String) in the remote repository the "Edit on ..." links point to. If a special Symbol value :commit is passed, the current commit will be used instead. If set to nothing, the link edit link will be hidden altogether. Default value is "master", making the edit link point to the master branch.

canonical specifies the canonical URL for your documentation. We recommend you set this to the base url of your stable documentation, e.g. https://juliadocs.github.io/Documenter.jl/stable. This allows search engines to know which version to send their users to. See wikipedia for more information. Default is nothing, in which case no canonical link is set.

analytics can be used specify the Google Analytics tracking ID.

assets can be used to include additional assets (JS, CSS, ICO etc. files). See below for more information.

ansicolor can be used to enable/disable colored output from @repl and @example blocks globally.

sidebar_sitename determines whether the site name is shown in the sidebar or not. Setting it to false can be useful when the logo already contains the name of the package. Defaults to true.

highlights can be used to add highlighting for additional languages. By default, Documenter already highlights all the "Common" highlight.js languages and Julia (julia, julia-repl). Additional languages must be specified by their filenames as they appear on CDNJS for the highlight.js version Documenter is using. E.g. to include highlighting for YAML and LLVM IR, you would set highlights = ["llvm", "yaml"]. Note that no verification is done whether the provided language names are sane.

mathengine specifies which LaTeX rendering engine will be used to render the math blocks. The options are either KaTeX (default), MathJax v2, or MathJax v3, enabled by passing an instance of KaTeX, MathJax2, or MathJax3 objects, respectively. The rendering engine can further be customized by passing options to the KaTeX or MathJax2/MathJax3 constructors.

lang specifies the lang attribute of the top-level <html> element, declaring the language of the generated pages. The default value is "en".

footer can be a valid single-line markdown String or nothing and is displayed below the page navigation. Defaults to "Powered by [Documenter.jl](https://github.com/JuliaDocs/Documenter.jl) and the [Julia Programming Language](https://julialang.org/).".

warn_outdated inserts a warning if the current page is not the newest version of the documentation.

Experimental options

prerender a boolean (true or false (default)) for enabling prerendering/build time application of syntax highlighting of code blocks. Requires a node (NodeJS) executable to be available in PATH or to be passed as the node keyword.

node path to a node (NodeJS) executable used for prerendering.

highlightjs file path to custom highglight.js library to be used with prerendering.

Default and custom assets

Documenter copies all files under the source directory (e.g. /docs/src/) over to the compiled site. It also copies a set of default assets from /assets/html/ to the site's assets/ directory, unless the user already had a file with the same name, in which case the user's files overrides the Documenter's file. This could, in principle, be used for customizing the site's style and scripting.

The HTML output also links certain custom assets to the generated HTML documents, specifically a logo and additional javascript files. The asset files that should be linked must be placed in assets/, under the source directory (e.g /docs/src/assets) and must be on the top level (i.e. files in the subdirectories of assets/ are not linked).

For the logo, Documenter checks for the existence of assets/logo.{svg,png,webp,gif,jpg,jpeg}, in this order. The first one it finds gets displayed at the top of the navigation sidebar. It will also check for assets/logo-dark.{svg,png,webp,gif,jpg,jpeg} and use that for dark themes.

Additional JS, ICO, and CSS assets can be included in the generated pages by passing them as a list with the assets keyword. Each asset will be included in the <head> of every page in the order in which they are given. The type of the asset (i.e. whether it is going to be included with a <script> or a <link> tag) is determined by the file's extension – either .js, .ico[1], or .css (unless overridden with asset).

Simple strings are assumed to be local assets and that each correspond to a file relative to the documentation source directory (conventionally src/). Non-local assets, identified by their absolute URLs, can be included with the asset function.

source
Documenter.Writers.HTMLWriter.KaTeXType
KaTeX(config::Dict = <default>, override = false)

An instance of the KaTeX type can be passed to HTML via the mathengine keyword to specify that the KaTeX rendering engine should be used in the HTML output to render mathematical expressions.

A dictionary can be passed via the config argument to configure KaTeX. It becomes the options argument of renderMathInElement. By default, Documenter only sets a custom delimiters option.

By default, the user-provided dictionary gets merged with the default dictionary (i.e. the resulting configuration dictionary will contain the values from both dictionaries, but e.g. setting your own delimiters value will override the default). This can be overridden by setting override to true, in which case the default values are ignored and only the user-provided dictionary is used.

source
Documenter.Writers.HTMLWriter.MathJax2Type
MathJax2(config::Dict = <default>, override = false)

An instance of the MathJax2 type can be passed to HTML via the mathengine keyword to specify that the MathJax v2 rendering engine should be used in the HTML output to render mathematical expressions.

A dictionary can be passed via the config argument to configure MathJax. It gets passed to the MathJax.Hub.Config function. By default, Documenter sets custom configurations for tex2jax, config, jax, extensions and Tex.

By default, the user-provided dictionary gets merged with the default dictionary (i.e. the resulting configuration dictionary will contain the values from both dictionaries, but e.g. setting your own tex2jax value will override the default). This can be overridden by setting override to true, in which case the default values are ignored and only the user-provided dictionary is used.

The URL of the MathJax JS file can be overridden using the url keyword argument (e.g. to use a particular minor version).

source
Documenter.Writers.HTMLWriter.MathJax3Type
MathJax3(config::Dict = <default>, override = false)

An instance of the MathJax3 type can be passed to HTML via the mathengine keyword to specify that the MathJax v3 rendering engine should be used in the HTML output to render mathematical expressions.

A dictionary can be passed via the config argument to configure MathJax. It gets passed to Window.MathJax function. By default, Documenter specifies in the key tex that $...$ and \(...\) denote inline math, that AMS style tags should be used and the base, ams and autoload packages should be imported. The key options, by default, specifies which HTML classes to ignore and which to process using MathJax.

By default, the user-provided dictionary gets merged with the default dictionary (i.e. the resulting configuration dictionary will contain the values from both dictionaries, but e.g. setting your own tex value will override the default). This can be overridden by setting override to true, in which case the default values are ignored and only the user-provided dictionary is used.

The URL of the MathJax JS file can be overridden using the url keyword argument (e.g. to use a particular minor version).

source
Documenter.Writers.HTMLWriter.assetMethod
asset(uri)

Can be used to pass non-local web assets to HTML, where uri should be an absolute HTTP or HTTPS URL.

It accepts the following keyword arguments:

class can be used to override the asset class, which determines how exactly the asset gets included in the HTML page. This is necessary if the class can not be determined automatically (default).

Should be one of: :js, :css or :ico. They become a <script>, <link rel="stylesheet" type="text/css"> and <link rel="icon" type="image/x-icon"> elements in <head>, respectively.

islocal can be used to declare the asset to be local. The uri should then be a path relative to the documentation source directory (conventionally src/). This can be useful when it is necessary to override the asset class of a local asset.

Usage

Documenter.HTML(assets = [
    # Standard local asset
    "assets/extra_styles.css",
    # Standard remote asset (extension used to determine that class = :js)
    asset("https://example.com/jslibrary.js"),
    # Setting asset class manually, since it can't be determined manually
    asset("https://example.com/fonts", class = :css),
    # Same as above, but for a local asset
    asset("asset/foo.script", class=:js, islocal=true),
])
source
Documenter.Writers.HTMLWriter.collect_subsectionsMethod

Returns an ordered list of tuples, (toplevel, anchor, text), corresponding to level 1 and 2 headings on the page. Note that if the first header on the page is a level 1 header then it is not included – it is assumed to be the page title and so does not need to be included in the navigation menu twice.

source
Documenter.Writers.HTMLWriter.navitemMethod

navitem returns the lists and list items of the navigation menu. It gets called recursively to construct the whole tree.

It always returns a DOM.Node. If there's nothing to display (e.g. the node is set to be invisible), it returns an empty text node (DOM.Node("")).

source
Documenter.Writers.HTMLWriter.pagetitleMethod

Tries to guess the page title by looking at the <h1> headers and returns the header contents of the first <h1> on a page (or nothing if the algorithm was unable to find any <h1> headers).

source
Documenter.Writers.LaTeXWriterModule

A module for rendering Document objects to LaTeX and PDF.

Keywords

LaTeXWriter uses the following additional keyword arguments that can be passed to makedocs: authors, sitename.

sitename is the site's title displayed in the title bar and at the top of the navigation menu. It goes into the \title LaTeX command.

authors can be used to specify the authors of. It goes into the \author LaTeX command.

source
Documenter.Writers.LaTeXWriter.LaTeXType
Documenter.LaTeX(; kwargs...)

Output format specifier that results in LaTeX/PDF output. Used together with makedocs, e.g.

makedocs(
    format = Documenter.LaTeX()
)

The makedocs argument sitename will be used for the \title field in the tex document, and if the build is for a release tag (i.e. when the "TRAVIS_TAG" environment variable is set) the version number will be appended to the title. The makedocs argument authors should also be specified, it will be used for the \authors field in the tex document.

Keyword arguments

platform sets the platform where the tex-file is compiled, either "native" (default), "docker", or "none" which doesn't compile the tex.

See Other Output Formats for more information.

source
Documenter.PluginType
abstract type Plugin end

Any plugin that needs to either solicit user input or store information in a Documents.Document should create a subtype of Plugin. The subtype, T <: Documenter.Plugin, must have an empty constructor T() that initialized T with the appropriate default values.

To retrieve the values stored in T, the plugin can call Documents.getplugin. If T was passed to makedocs, the passed type will be returned. Otherwise, a new T object will be created.

source
  • 1Adding an ICO asset is primarily useful for setting a custom favicon.