61 class format_html :
public format_base
76 template <
typename option_type,
typename val
idator_type>
77 void add_option(option_type & value,
79 std::string
const & long_id,
80 std::string
const & desc,
82 validator_type && validator)
84 parser_set_up_calls.push_back([=, &value]()
87 print_list_item(prep_id_for_help(short_id, long_id) +
" " + option_type_and_list_info(value),
88 (desc +
" " + validator.get_help_page_message()));
99 void add_flag(
bool & ,
101 std::string
const & long_id,
102 std::string
const & desc,
105 parser_set_up_calls.push_back([=] ()
107 if (!(spec & option_spec::HIDDEN) && (!(spec & option_spec::ADVANCED)))
108 print_list_item(prep_id_for_help(short_id, long_id), desc);
121 template <
typename option_type,
typename val
idator_type>
122 void add_positional_option(option_type & value,
123 std::string
const & desc,
124 validator_type && validator)
126 ++positional_option_count;
128 positional_option_calls.push_back([=, &value]()
130 std::string key{
"\\fBARGUMENT " + std::to_string(positional_option_count) +
"\\fP " + option_type_and_list_info(value)};
131 print_list_item(key, (desc +
" " + validator.get_help_page_message()));
138 void parse(argument_parser_meta_data
const & parser_meta)
142 print_section(
"Synopsis");
145 if (!parser_meta.description.empty())
147 print_section(
"Description");
148 for (
auto desc : parser_meta.description)
153 if (!positional_option_calls.empty())
154 print_section(
"Positional Arguments");
157 for (
auto f : positional_option_calls)
161 if (!parser_set_up_calls.empty())
162 print_section(
"Options");
165 for (
auto f : parser_set_up_calls)
170 throw parser_interruption();
176 void add_section(std::string
const & title)
178 parser_set_up_calls.push_back([=] ()
180 print_section(title);
186 void add_subsection(std::string
const & title)
188 parser_set_up_calls.push_back([=] ()
190 print_subsection(title);
199 void add_line(std::string
const & text,
bool const line_is_paragraph)
201 parser_set_up_calls.push_back([=] ()
203 print_line(text, line_is_paragraph);
212 void add_list_item(std::string
const & key, std::string
const & description)
214 parser_set_up_calls.push_back([=] ()
216 print_list_item(key, description);
222 void maybe_close_list()
226 std::cout <<
"</dl>\n";
232 void maybe_close_paragraph()
236 std::cout <<
"</p>\n";
245 std::cout <<
"<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\" " 246 <<
"http://www.w3.org/TR/html4/strict.dtd\">\n" 247 <<
"<html lang=\"en\">\n" 249 <<
"<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">\n" 250 <<
"<title>" << escape_special_xml_chars(meta.app_name) <<
" — " 251 << escape_special_xml_chars(meta.short_description) <<
"</title>\n" 255 std::cout <<
"<h1>" << to_html(meta.app_name) <<
"</h1>\n" 256 <<
"<div>" << to_html(meta.short_description) <<
"</div>\n";
260 void _print_synopsis()
262 for (
unsigned i = 0; i < meta.synopsis.size(); ++i)
264 std::string text =
"\\fB";
265 text.append(meta.app_name);
266 text.append(
"\\fP ");
267 text.append(meta.synopsis[i]);
269 print_line(text,
false);
276 void print_section(std::string
const & title)
280 maybe_close_paragraph();
281 std::cout <<
"<h2>" << to_html(title) <<
"</h2>\n";
287 void print_subsection(std::string
const & title)
291 maybe_close_paragraph();
292 std::cout <<
"<h3>" << to_html(title) <<
"</h3>\n";
300 void print_line(std::string
const & text,
bool line_is_paragraph)
306 std::cout <<
"<p>\n";
309 std::cout << to_html(text) <<
"\n";
310 if (line_is_paragraph)
311 maybe_close_paragraph();
313 std::cout <<
"<br />\n";
319 void print_line(std::string
const & text)
321 print_line(text,
true);
333 void print_list_item(std::string
const & term, std::string
const & desc)
336 maybe_close_paragraph();
340 std::cout <<
"<dl>\n";
343 std::cout <<
"<dt>" << to_html(term) <<
"</dt>\n" 344 <<
"<dd>" << to_html(desc) <<
"</dd>\n";
353 std::cout <<
"<h2>Version</h2>\n" 354 <<
"<strong>Last update:</strong> " << to_html(meta.date) <<
"<br>\n<strong>" 355 << meta.app_name <<
" version:</strong> " << meta.version <<
"<br>\n" 359 if (!meta.url.empty())
361 std::cout <<
"<h2>Url</h2>\n" 362 << meta.url <<
"<br>\n";
364 std::cout <<
"<br>\n";
367 if ((!meta.short_copyright.empty()) || (!meta.long_copyright.empty()) || (!meta.citation.empty()))
369 std::cout <<
"<h2>Legal</h2>\n<strong>";
371 if (!meta.short_copyright.empty())
372 std::cout << meta.app_name <<
" Copyright: </strong>" 373 << meta.short_copyright <<
"<br>\n<strong>";
375 std::cout <<
"SeqAn Copyright:</strong> 2006-2015 Knut Reinert, FU-Berlin; released under the 3-clause BSDL.<br>\n<strong>";
377 if (!meta.citation.empty())
378 std::cout <<
"In your academic works please cite:</strong> " << meta.citation <<
"<br>\n";
380 std::cout <<
"</strong>";
382 if (!meta.long_copyright.empty())
383 std::cout <<
"For full copyright and/or warranty information see <tt>--copyright</tt>.\n";
387 std::cout <<
"</body></html>";
394 std::string to_html(std::string
const & input)
396 std::string buffer = escape_special_xml_chars(input);
398 std::vector<std::string> open_tags;
400 for (
auto it = input.begin(); it != input.end(); ++it)
406 assert(!(it == input.end()));
409 result.push_back(*it);
414 assert(!(it == input.end()));
417 open_tags.push_back(
"em");
418 result.append(
"<em>");
422 open_tags.push_back(
"strong");
423 result.append(
"<strong>");
427 assert(!open_tags.empty());
429 result.append(open_tags.back());
431 open_tags.pop_back();
435 result.append(
"\\f");
436 result.push_back(*it);
441 result.push_back(
'\\');
442 result.push_back(*it);
447 result.push_back(*it);
468 argument_parser_meta_data meta;
470 std::vector<std::function<void()>> parser_set_up_calls;
472 std::vector<std::function<void()>> positional_option_calls;
478 unsigned positional_option_count{0};
#define SEQAN3_VERSION_MINOR
The minor version as MACRO.
Definition: version.hpp:49
Definition: auxiliary.hpp:72
Checks if program is run interactively and retrieves dimensions of terminal (Transferred from seqan2)...
Definition: aligned_sequence_concept.hpp:288
Definition: auxiliary.hpp:68
option_spec
Used to further specify argument_parser options/flags.
Definition: auxiliary.hpp:60
#define SEQAN3_VERSION_PATCH
The patch version as MACRO.
Definition: version.hpp:51
#define SEQAN3_VERSION_MAJOR
The major version as MACRO.
Definition: version.hpp:47
Contains SeqAn version macros and global variables.