Documentation Build Progress Guide
This guide explains how to follow a documentation build with the DocumenterProgress extension of CTBase.jl. The entry point is CTBase.DevTools.track_documentation_build, activated by loading the Documenter weak dependency.
During makedocs, Documenter runs the @example, @repl and @eval blocks of every page one after the other and prints nothing. A build can spend minutes there without any sign of which page is running, which pages are slow, or whether the time is real computation or compilation. The extension fills that gap, as the Test Runner does for tests.
Quick start
Call the function once, before makedocs:
using CTBase: CTBase
using Documenter: Documenter
CTBase.DevTools.track_documentation_build()
Documenter.makedocs(; sitename="MyPackage.jl", pages=["index.md", "guide.md"])Nothing else changes: the generated site is the same with and without the tracker. Without the call, the tracker is inert.
What is printed
While the pages are expanded, one line is printed when a page starts and one when it ends, with a counter and the time of the page:
── DocumenterProgress: 58 pages, global draft mode: off
→ [ 7/58] flows/shooting.md
✓ [ 7/58] flows/shooting.md 35.2 s
✓ [ 8/58] flows/multi-phase.md 12.0 s [draft]The header gives the number of pages and the global draft mode of the build.
[draft]marks a page built in draft mode, for instance with aDraft = trueline in its@metablock. Its blocks are not executed, so its time is small.The line with
→is printed before the page is expanded: if the build seems stuck, it names the page that is running.Pages are expanded in alphabetical order (after those listed in
expandfirst), sok/Nfollows that order, not the order of the sidebar.
When the expansion ends, a report summarises where the time went:
── 58 pages in 8 min 32 s — median 1.8 s, mean 8.8 s (skewed)
concentration: 50% of the time in 3 pages (5%), 80% in 9 pages (16%), 90% in 17 pages (29%)
critical (50% of the time, 3 pages): guided-tour.md 2 min 25 s (62% compile), flows/shooting.md 35.2 s (12% compile), results/plot.md 31.0 s (48% compile)
distribution: concentrated in a few pages
compile: 31% of the total time
light: 38 pages under 2.0 s = 1.4% of the timeReading the report
The times of the pages are positive and heavy-tailed: many text pages take a fraction of a second, a few pages that plot or solve take much longer. The mean and the standard deviation are then misleading, so the report assumes nothing on the distribution and counts instead.
| Line | What it tells you |
|---|---|
median, mean | The time of a typical page, and of the average one. A mean at least twice the median is flagged (skewed). |
concentration | How many pages are needed to reach each share of the total time. |
critical | The slowest pages that together reach critical_share of the time, with their compile share. If ten pages have similar times, they appear together. |
distribution | flat, no dominant page when the critical set holds at least two pages and more than flat_threshold of the pages, concentrated in a few pages otherwise. A single critical page is always a concentration, however few pages the site has. Not printed for a one-page site. |
compile | The share of the time spent compiling. |
light | The pages under light_threshold, and the share of the time they account for. |
sections | The time per section, if show_sections=true. |
Compilation or computation
Pages are expanded one after the other in the same process, so the first page that plots or solves pays the compilation for all the following ones. The compile share, measured with Base.cumulative_compile_time_ns, tells the two costs apart:
a high compile share means the page is slow because of the order of the pages: shortening it will not help, the cost moves to the next page that needs the same code;
a low compile share means the page really computes: it is the one to lighten.
The compile counter is summed over all threads, so the share of a page is capped at 100%.
Options
All options are keyword arguments of CTBase.DevTools.track_documentation_build, validated when the function is called: an unknown option, a wrong type or an invalid value throws an IncorrectArgument.
| Option | Default | Role |
|---|---|---|
enabled | true | Global switch: when false, the build is left untouched. |
io | nothing | Output stream; nothing means stderr, the stream of Documenter's own messages. |
show_page_lines | true | Print the → and ✓ lines. |
pareto_levels | (0.5, 0.8, 0.9) | Shares of the total time for which the number of pages is reported, in ]0, 1] and strictly increasing. |
critical_share | 0.5 | Share of the total time that the critical pages account for. |
max_critical | 12 | Number of critical pages listed before … +n. |
flat_threshold | 0.25 | Fraction of the pages above which the distribution is called flat. |
light_threshold | 2.0 | Duration in seconds under which a page is light; a finite number. |
show_compile | true | Report the compile share, per critical page and overall. |
show_sections | false | Report the time per section, the first directory of the page path. |
tsv_path | nothing | File receiving one line per page. A relative path is resolved against the current directory when track_documentation_build is called, not against the docs root where makedocs runs. |
For instance, to list more pages and keep a record of the times:
CTBase.DevTools.track_documentation_build(;
critical_share=0.8,
max_critical=20,
show_sections=true,
tsv_path=joinpath(@__DIR__, ".page-times.tsv"),
)TSV output
With tsv_path, the times are written at the end of the expansion, one line per page in expansion order:
page seconds compile_seconds draft
flows/shooting.md 35.214 4.2 false
flows/multi-phase.md 12.0 0.3 trueThe file is convenient as a CI artifact, to compare two builds.
Not under build/
With DocumenterVitepress, the content of build/ is moved before rendering. Write the file elsewhere, for instance in docs/, and add it to .gitignore.
How it works
The extension does not redefine any Documenter method. Like the API reference generator, it adds its own stages to the Documenter pipeline through the Selectors extension points:
a stage just before
ExpandTemplatesannounces the build and starts the compile timing;an expander that matches every node is called at the first node of each page: it closes the previous page and opens the next one, and never prevents the other expanders from running;
a stage just after
ExpandTemplatescloses the last page and prints the report.
All three are disabled unless track_documentation_build was called.
Limits
Only the expansion of the pages (
ExpandTemplates) is followed. The other steps, such as the rendering of the site, keep their own messages.A page without any content is not seen by the tracker.
If a build stops with an error before the end of the expansion, no report is printed. The
→line of the last page tells where it stopped.Errors and warnings are not attributed to pages: Documenter already reports them with the file and line.
With
doctest = :only, no page is expanded and the tracker prints nothing.The stages rely on Documenter internals (
Selectors, the pipelines,is_draft, the blueprint of the document), as the API reference generator does. A Documenter release that changes them may require an update of the extension.