Writers
Documenter.Writers
— Module.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.
Documenter.Writers.render
— Method.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...
Documenter.Writers.MarkdownWriter
— Module.A module for rendering Document
objects to markdown.
Documenter.Writers.HTMLWriter
— Module.A module for rendering Document
objects to HTML.
Keywords
HTMLWriter
uses the following additional keyword arguments that can be passed to Documenter.makedocs
: assets
, sitename
, analytics
, authors
, pages
, version
, html_prettyurls
.
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.
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:
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.If the first heading is interpreted as being the page title, it is not displayed in the navigation sidebar.
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, specfically 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.png
. If that's present, it gets displayed in the navigation bar.
Additional JS and CSS assets can be included in the generated pages using the assets
keyword for makedocs
. assets
must be a Vector{String}
and will include each listed asset in the <head>
of every page in the order in which they are listed. 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
or .css
.
Documenter.Writers.HTMLWriter.MDBlockContext
— Constant.MDBlockContext
is a union of all the Markdown nodes whose children should be blocks. It can be used to dispatch on all the block-context nodes at once.
HTMLWriter
-specific globals that are passed to domify
and other recursive functions.
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.
Documenter.Writers.HTMLWriter.copy_asset
— Method.Copies an asset from Documenters assets/html/
directory to doc.user.build
. Returns the path of the copied asset relative to .build
.
Documenter.Writers.HTMLWriter.domify
— Method.Converts recursively a Documents.Page
, Base.Markdown
or Documenter *Node
objects into HTML DOM.
Documenter.Writers.HTMLWriter.fixlinks!
— Method.Replaces URLs in Markdown.Link
elements (if they point to a local .md
page) with the actual URLs.
Documenter.Writers.HTMLWriter.get_url
— Method.Returns the full path corresponding to a path of a .md
page file. The the input and output paths are assumed to be relative to src/
.
Documenter.Writers.HTMLWriter.get_url
— Method.Returns the full path of a Documents.NavNode
relative to src/
.
Documenter.Writers.HTMLWriter.getpage
— Method.Returns a page (as a Documents.Page
object) using the HTMLContext
.
Documenter.Writers.HTMLWriter.mdconvert
— Method.Convert a markdown object to a DOM.Node
object.
The parent
argument is passed to allow for context-dependant conversions.
Documenter.Writers.HTMLWriter.navhref
— Method.Get the relative hyperlink between two Documents.NavNode
s. Assumes that both Documents.NavNode
s have an associated Documents.Page
(i.e. .page
is not null).
Documenter.Writers.HTMLWriter.navitem
— Method.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("")
).
Opens the output file of the navnode
in write node. If necessary, the path to the output file is created before opening the file.
Documenter.Writers.HTMLWriter.pagetitle
— Method.Tries to guess the page title by looking at the <h1>
headers and returns the header contents of the first <h1>
on a page as a Nullable
(nulled if the algorithm was unable to find any <h1>
headers).
Documenter.Writers.HTMLWriter.pretty_url
— Method.If html_prettyurls
is enabled, returns a "pretty" version of the path
which can then be used in links in the resulting HTML file.
Documenter.Writers.HTMLWriter.relhref
— Method.Calculates a relative HTML link from one path to another.
Constructs and writes the page referred to by the navnode
to .build
.
Documenter.Writers.LaTeXWriter
— Module.A module for rendering Document
objects to LaTeX and PDF.