TraceMaker
C++ API of the engine
Loading...
Searching...
No Matches
render.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-3.0-or-later
2#pragma once
3// Renders the run report (doc 18 D3, D136) from a route summary (`route --json`, with the sections `route --report`
4// adds). The renderer reads nothing but the summary and does no arithmetic: every number and every name it prints is a
5// field of the JSON, and the HTML marks each with its JSON pointer (`data-src`), so a reader can trace any figure.
6#include <string>
7
8#include <nlohmann/json.hpp>
9
10namespace tmk::report {
11
12enum class Format { Html, Markdown };
13
14// Markdown for a path ending in .md or .markdown, else HTML.
15Format format_for_path(const std::string& path);
16
17// A JSON value as the report prints it: integers as they are, other numbers to three decimals without trailing zeros,
18// true/false as yes/no, null as n/a, strings as they are.
19std::string value_text(const nlohmann::json& v);
20
21// The report of `summary`. `json_name` is the summary file the report points at for its sources (shown as written).
22std::string render(const nlohmann::json& summary, Format format, const std::string& json_name);
23
24} // namespace tmk::report
std::string value_text(const nlohmann::json &v)
A JSON value as the report prints it: integers as they are, other numbers to three decimals without t...
std::string render(const nlohmann::json &summary, Format format, const std::string &json_name)
The report of summary. json_name is the summary file the report points at for its sources (shown as w...
Format format_for_path(const std::string &path)
Markdown for a path ending in .md or .markdown, else HTML.