aboutsummaryrefslogtreecommitdiff
path: root/paludis/args/man.cc
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-01-27 02:07:38 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-01-27 02:07:38 +0000
commit17b2f8db16626eb819e13663dd36c8278ddff068 (patch)
treefba0763de125f1f4cc6bcd8fdbbc8a83145e0b55 /paludis/args/man.cc
parenta283fe406d5acb3d3f2729825a9271ffb06764e1 (diff)
downloadpaludis-17b2f8db16626eb819e13663dd36c8278ddff068.tar.gz
paludis-17b2f8db16626eb819e13663dd36c8278ddff068.tar.xz
Include HTML man pages. Fixes: ticket:46.
Diffstat (limited to 'paludis/args/man.cc')
-rw-r--r--paludis/args/man.cc208
1 files changed, 176 insertions, 32 deletions
diff --git a/paludis/args/man.cc b/paludis/args/man.cc
index e802b6397..0997eff4d 100644
--- a/paludis/args/man.cc
+++ b/paludis/args/man.cc
@@ -31,8 +31,10 @@ namespace
ArgsVisitorTypes::ConstVisitor
{
std::stringstream s;
+ ManFormat mf;
- ExtraText()
+ ExtraText(ManFormat m) :
+ mf(m)
{
}
@@ -58,14 +60,47 @@ namespace
void visit(const EnumArg * const e)
{
+ if (e->begin_allowed_args() == e->end_allowed_args())
+ return;
+
+ switch (mf)
+ {
+ case mf_man:
+ break;
+
+ case mf_html:
+ s << "<dl>" << endl;
+ break;
+ }
+
for (EnumArg::AllowedArgIterator a(e->begin_allowed_args()), a_end(e->end_allowed_args()) ;
a != a_end ; ++a)
{
- s << ".RS" << endl;
- s << ".TP" << endl;
- s << ".B \"" << a->first << "\"" << endl;
- s << a->second << endl;
- s << ".RE" << endl;
+ switch (mf)
+ {
+ case mf_man:
+ s << ".RS" << endl;
+ s << ".TP" << endl;
+ s << ".B \"" << a->first << "\"" << endl;
+ s << a->second << endl;
+ s << ".RE" << endl;
+ break;
+
+ case mf_html:
+ s << "<dt>" << a->first << "</dt>" << endl;
+ s << "<dd>" << a->second << "</dd>" << endl;
+ break;
+ }
+ }
+
+ switch (mf)
+ {
+ case mf_man:
+ break;
+
+ case mf_html:
+ s << "</dl>" << endl;
+ break;
}
}
@@ -95,59 +130,168 @@ namespace
void
paludis::args::generate_man(std::ostream & f, const ArgsHandler * const h)
{
- f << ".TH \"" << h->app_name() << "\" "
- << h->man_section() << endl;
+ generate_man(f, h, mf_man);
+}
- f << ".SH NAME" << endl;
- f << h->app_name() << " \\- "
- << h->app_synopsis() << endl;
+void
+paludis::args::generate_man(std::ostream & f, const ArgsHandler * const h,
+ const ManFormat mf)
+{
+ switch (mf)
+ {
+ case mf_man:
+ f << ".TH \"" << h->app_name() << "\" " << h->man_section() << endl;
+ f << ".SH NAME" << endl;
+ f << h->app_name() << " \\- " << h->app_synopsis() << endl;
+ f << ".SH SYNOPSIS" << endl;
+ break;
- f << ".SH SYNOPSIS" << endl;
+ case mf_html:
+ f << "<h1>" << h->app_name() << "(" << h->man_section() << ")" << "</h1>" << endl;
+ f << "<h2>Name</h2>" << endl;
+ f << "<p>" << h->app_name() << " - " << h->app_synopsis() << "</p>" << endl;
+ f << "<h2>Synopsis</h2>" << endl;
+ break;
+ }
for (ArgsHandler::UsageLineIterator u(h->begin_usage_lines()),
u_end(h->end_usage_lines()) ; u != u_end ; ++u)
- f << ".B " << h->app_name() << " " << *u << endl << endl;
+ {
+ switch (mf)
+ {
+ case mf_man:
+ f << ".B " << h->app_name() << " " << *u << endl << endl;
+ break;
+
+ case mf_html:
+ f << "<p>" << h->app_name() << " " << *u << "</p>" << endl;
+ break;
+ }
+ }
- f << ".SH DESCRIPTION" << endl;
- f << h->app_description() << endl;
+ switch (mf)
+ {
+ case mf_man:
+ f << ".SH DESCRIPTION" << endl;
+ f << h->app_description() << endl;
+ f << ".SH OPTIONS" << endl;
+ break;
- f << ".SH OPTIONS" << endl;
+ case mf_html:
+ f << "<h2>Description</h2>" << endl;
+ f << "<p>" << h->app_description() << "</p>" << endl;
+ f << "<h2>Options</h2>" << endl;
+ break;
+ }
for (ArgsHandler::ArgsGroupsIterator a(h->begin_args_groups()),
a_end(h->end_args_groups()) ; a != a_end ; ++a)
{
- f << ".SS \"" << (*a)->name() << "\"" << endl;
- f << (*a)->description() << endl;
+ switch (mf)
+ {
+ case mf_man:
+ f << ".SS \"" << (*a)->name() << "\"" << endl;
+ f << (*a)->description() << endl;
+ break;
+
+ case mf_html:
+ f << "<h3>" << (*a)->name() << "</h3>" << endl;
+ f << "<p>" << (*a)->description() << "</p>" << endl;
+ f << "<dl>";
+ break;
+ }
for (paludis::args::ArgsGroup::Iterator b((*a)->begin()), b_end((*a)->end()) ;
b != b_end ; ++b)
{
- f << ".TP" << endl;
- f << ".B \"";
- if ((*b)->short_name())
- f << "\\-" << (*b)->short_name() << " , ";
- f << "\\-\\-" << (*b)->long_name() << "\"" << endl;
- f << (*b)->description() << endl;
-
- ExtraText t;
+ switch (mf)
+ {
+ case mf_man:
+ f << ".TP" << endl;
+ f << ".B \"";
+ if ((*b)->short_name())
+ f << "\\-" << (*b)->short_name() << " , ";
+ f << "\\-\\-" << (*b)->long_name() << "\"" << endl;
+ f << (*b)->description() << endl;
+ break;
+
+ case mf_html:
+ f << "<dt>";
+ if ((*b)->short_name())
+ f << "-" << (*b)->short_name() << ", ";
+ f << "--" << (*b)->long_name() << "</dt>" << endl;
+ f << "<dd>" << (*b)->description() << endl;
+
+ break;
+ }
+
+ ExtraText t(mf);
(*b)->accept(&t);
f << t;
+
+ switch (mf)
+ {
+ case mf_man:
+ break;
+
+ case mf_html:
+ f << "</dd>" << endl;
+ break;
+ }
+ }
+
+ switch (mf)
+ {
+ case mf_man:
+ break;
+
+ case mf_html:
+ f << "</dl>";
+ break;
}
}
- if (h->begin_environment_lines() !=
- h->end_environment_lines())
+ if (h->begin_environment_lines() != h->end_environment_lines())
{
- f << ".SH ENVIRONMENT" << endl;
+ switch (mf)
+ {
+ case mf_man:
+ f << ".SH ENVIRONMENT" << endl;
+ break;
+
+ case mf_html:
+ f << "<h2>Environment</h2>" << endl;
+ f << "<dl>" << endl;
+ break;
+ }
for (ArgsHandler::EnvironmentLineIterator a(h->begin_environment_lines()),
a_end(h->end_environment_lines()) ; a != a_end ; ++a)
{
- f << ".TP" << endl;
- f << ".B \"" << a->first << "\"" << endl;
- f << a->second << endl;
+ switch (mf)
+ {
+ case mf_man:
+ f << ".TP" << endl;
+ f << ".B \"" << a->first << "\"" << endl;
+ f << a->second << endl;
+ break;
+
+ case mf_html:
+ f << "<dt>" << a->first << "</dt>" << endl;
+ f << "<dd>" << a->second << "</dd>" << endl;
+ break;
+ }
}
+ switch (mf)
+ {
+ case mf_man:
+ break;
+
+ case mf_html:
+ f << "</dl>" << endl;
+ break;
+ }
}
}