summaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-11-24 11:54:14 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-11-24 11:54:14 +0200
commit469605e872aeca50c7556708de5d50d7e7935d83 (patch)
tree646940c7653065dbb97346f171d097515ec45afd /cli
parent7e9cb673ccfc77c5871292aa5491fc2c2dc2a663 (diff)
Implement support for documentation inside classes
Diffstat (limited to 'cli')
-rw-r--r--cli/header.cxx24
-rw-r--r--cli/html.cxx78
-rw-r--r--cli/man.cxx36
-rw-r--r--cli/options.cxx13
-rw-r--r--cli/options.hxx28
-rw-r--r--cli/options.ixx8
-rw-r--r--cli/parser.cxx25
-rw-r--r--cli/runtime-header.cxx21
-rw-r--r--cli/runtime-inline.cxx12
-rw-r--r--cli/source.cxx283
10 files changed, 330 insertions, 198 deletions
diff --git a/cli/header.cxx b/cli/header.cxx
index 35097af..d5ab674 100644
--- a/cli/header.cxx
+++ b/cli/header.cxx
@@ -189,16 +189,21 @@ namespace
//
if (usage != ut_none)
{
+ string up (cli + "::usage_para");
+ string const& ost (options.ostream_type ());
+
os << "// Print usage information." << endl
<< "//" << endl;
- os << "static void" << endl
- << "print_usage (" << options.ostream_type () << "&);"
+ os << "static " << up << endl
+ << "print_usage (" << ost << "&," << endl
+ << up << " = " << up << "::none);"
<< endl;
if (usage == ut_both)
- os << "static void" << endl
- << "print_long_usage (" << options.ostream_type () << "&);"
+ os << "static " << up << endl
+ << "print_long_usage (" << ost << "&," << endl
+ << up << " = " << up << "::none);"
<< endl;
}
@@ -336,15 +341,18 @@ generate_header (context& ctx)
const string& qn (ctx.options.page_usage ());
string n (ctx.escape (ctx.substitute (ctx.ns_open (qn, false))));
+ string up (ctx.cli + "::usage_para");
string const& ost (ctx.options.ostream_type ());
- os << "void" << endl
- << n << "usage (" << ost << "&);"
+ os << up << endl
+ << n << "usage (" << ost << "&," << endl
+ << up << " = " << up << "::none);"
<< endl;
if (ctx.usage == ut_both)
- os << "void" << endl
- << n << "long_usage (" << ost << "&);"
+ os << up << endl
+ << n << "long_usage (" << ost << "&," << endl
+ << up << " = " << up << "::none);"
<< endl;
ctx.ns_close (qn, false);
diff --git a/cli/html.cxx b/cli/html.cxx
index 0394a3a..6659bf6 100644
--- a/cli/html.cxx
+++ b/cli/html.cxx
@@ -114,7 +114,7 @@ namespace
struct doc: traversal::doc, context
{
- doc (context& c) : context (c) {}
+ doc (context& c, bool& l): context (c), list_ (l) {}
virtual void
traverse (type& ds)
@@ -129,24 +129,34 @@ namespace
size_t n (ds.size ());
const string& d (n == 1 ? ds[0] : n == 2 ? ds[1] : ds[2]);
- if (d.empty ())
- return;
-
std::set<string> arg_set;
if (n > 1)
translate_arg (ds[0], arg_set);
string s (format (ot_html, escape_html (translate (d, arg_set)), true));
+ if (s.empty ())
+ return;
+
+ if (list_)
+ {
+ os << " </dl>" << endl
+ << endl;
+ list_ = false;
+ }
+
wrap_lines (os, s, 2);
os << endl
<< endl;
}
+
+ private:
+ bool& list_; // True if we are currently in <dl>.
};
struct option: traversal::option, context
{
- option (context& c) : context (c) {}
+ option (context& c, bool& l): context (c), list_ (l) {}
virtual void
traverse (type& o)
@@ -158,6 +168,14 @@ namespace
if (options.suppress_undocumented () && doc.empty ())
return;
+ if (!list_)
+ {
+ os << " <dl class=\"options\">" << endl;
+ list_ = true;
+ }
+ else
+ os << endl; // Separate from the previous <dl>.
+
names& n (o.named ());
os << " <dt><code><b>";
@@ -212,69 +230,63 @@ namespace
d = format (ot_html, escape_html (translate (d, arg_set)), false);
wrap_lines (os, "<dd>" + d + "</dd>", 4);
- os << endl
- << endl;
+ os << endl;
}
+
+ private:
+ bool& list_; // True if we are currently in <dl>.
};
//
//
struct class_: traversal::class_, context
{
- class_ (context& c)
- : context (c), option_ (c)
- {
- *this >> inherits_base_ >> *this;
- names_option_ >> option_;
- }
+ class_ (context& c): context (c) {}
virtual void
traverse (type& c)
{
if (!options.exclude_base () && !options.include_base_last ())
- inherits (c, inherits_base_);
+ inherits (c);
- if (!c.names_empty ())
- {
- os << " <dl class=\"options\">" << endl;
- names (c, names_option_);
- os << " </dl>" << endl
- << endl;
- }
+ names (c);
if (!options.exclude_base () && options.include_base_last ())
- inherits (c, inherits_base_);
+ inherits (c);
}
-
- private:
- traversal::inherits inherits_base_;
-
- option option_;
- traversal::names names_option_;
};
}
void
generate_html (context& ctx)
{
+ bool list (false);
+
traversal::cli_unit unit;
traversal::names unit_names;
traversal::namespace_ ns;
- doc dc (ctx);
+ doc dc (ctx, list);
class_ cl (ctx);
-
unit >> unit_names;
unit_names >> dc;
unit_names >> ns;
unit_names >> cl;
traversal::names ns_names;
-
ns >> ns_names;
ns_names >> dc;
ns_names >> ns;
ns_names >> cl;
+ traversal::inherits cl_inherits;
+ cl >> cl_inherits >> cl;
+
+ option op (ctx, list);
+ traversal::names cl_names;
+ cl >> cl_names;
+ cl_names >> dc;
+ cl_names >> op;
+
if (ctx.options.class_ ().empty ())
unit.dispatch (ctx.unit);
else
@@ -298,4 +310,8 @@ generate_html (context& ctx)
}
}
}
+
+ if (list)
+ ctx.os << " </dl>" << endl
+ << endl;
}
diff --git a/cli/man.cxx b/cli/man.cxx
index 2d5cce7..606fec6 100644
--- a/cli/man.cxx
+++ b/cli/man.cxx
@@ -85,15 +85,15 @@ namespace
size_t n (ds.size ());
const string& d (n == 1 ? ds[0] : n == 2 ? ds[1] : ds[2]);
- if (d.empty ())
- return;
-
std::set<string> arg_set;
if (n > 1)
translate_arg (ds[0], arg_set);
string s (format (ot_man, translate (d, arg_set), true));
+ if (s.empty ())
+ return;
+
wrap_lines (os, s);
os << endl;
}
@@ -175,30 +175,19 @@ namespace
//
struct class_: traversal::class_, context
{
- class_ (context& c)
- : context (c), option_ (c)
- {
- *this >> inherits_base_ >> *this;
- names_option_ >> option_;
- }
+ class_ (context& c): context (c) {}
virtual void
traverse (type& c)
{
if (!options.exclude_base () && !options.include_base_last ())
- inherits (c, inherits_base_);
+ inherits (c);
- names (c, names_option_);
+ names (c);
if (!options.exclude_base () && options.include_base_last ())
- inherits (c, inherits_base_);
+ inherits (c);
}
-
- private:
- traversal::inherits inherits_base_;
-
- option option_;
- traversal::names names_option_;
};
}
@@ -210,19 +199,26 @@ generate_man (context& ctx)
traversal::namespace_ ns;
doc dc (ctx);
class_ cl (ctx);
-
unit >> unit_names;
unit_names >> ns;
unit_names >> dc;
unit_names >> cl;
traversal::names ns_names;
-
ns >> ns_names;
ns_names >> ns;
ns_names >> dc;
ns_names >> cl;
+ traversal::inherits cl_inherits;
+ cl >> cl_inherits >> cl;
+
+ option op (ctx);
+ traversal::names cl_names;
+ cl >> cl_names;
+ cl_names >> dc;
+ cl_names >> op;
+
if (ctx.options.class_ ().empty ())
unit.dispatch (ctx.unit);
else
diff --git a/cli/options.cxx b/cli/options.cxx
index 7d7f9cb..6869a60 100644
--- a/cli/options.cxx
+++ b/cli/options.cxx
@@ -1210,9 +1210,14 @@ options (::cli::scanner& s,
_parse (s, opt, arg);
}
-void options::
-print_usage (::std::ostream& os)
+::cli::usage_para options::
+print_usage (::std::ostream& os, ::cli::usage_para p)
{
+ CLI_POTENTIALLY_UNUSED (os);
+
+ if (p == ::cli::usage_para::text)
+ os << ::std::endl;
+
os << "--help Print usage information and exit." << ::std::endl;
os << "--version Print version and exit." << ::std::endl;
@@ -1384,6 +1389,10 @@ print_usage (::std::ostream& os)
os << "--options-file <file> Read additional options from <file> with each" << ::std::endl
<< " option appearing on a separate line optionally" << ::std::endl
<< " followed by space and an option value." << ::std::endl;
+
+ p = ::cli::usage_para::option;
+
+ return p;
}
typedef
diff --git a/cli/options.hxx b/cli/options.hxx
index 65dae49..0612882 100644
--- a/cli/options.hxx
+++ b/cli/options.hxx
@@ -28,6 +28,27 @@
namespace cli
{
+ class usage_para
+ {
+ public:
+ enum value
+ {
+ none,
+ text,
+ option
+ };
+
+ usage_para (value);
+
+ operator value () const
+ {
+ return v_;
+ }
+
+ private:
+ value v_;
+ };
+
class unknown_mode
{
public:
@@ -38,7 +59,7 @@ namespace cli
fail
};
- unknown_mode (value v);
+ unknown_mode (value);
operator value () const
{
@@ -666,8 +687,9 @@ class options
// Print usage information.
//
- static void
- print_usage (::std::ostream&);
+ static ::cli::usage_para
+ print_usage (::std::ostream&,
+ ::cli::usage_para = ::cli::usage_para::none);
// Implementation details.
//
diff --git a/cli/options.ixx b/cli/options.ixx
index 9759dd2..24dc37b 100644
--- a/cli/options.ixx
+++ b/cli/options.ixx
@@ -11,6 +11,14 @@
namespace cli
{
+ // usage_para
+ //
+ inline usage_para::
+ usage_para (value v)
+ : v_ (v)
+ {
+ }
+
// unknown_mode
//
inline unknown_mode::
diff --git a/cli/parser.cxx b/cli/parser.cxx
index 164a3c0..aee5c04 100644
--- a/cli/parser.cxx
+++ b/cli/parser.cxx
@@ -224,9 +224,8 @@ def_unit ()
}
cerr << *path_ << ':' << t.line () << ':' << t.column () << ": error: "
- << "expected namespace, class, or documentation declaration or "
- << "instead of " << t
- << endl;
+ << "expected namespace, class, or documentation instead of "
+ << t << endl;
throw error ();
}
catch (error const&)
@@ -588,8 +587,8 @@ namespace_def ()
if (t.punctuation () != token::p_rcbrace)
{
cerr << *path_ << ':' << t.line () << ':' << t.column () << ": error: "
- << "expected namespace, class, or documentation declaration or '}' "
- << "instead of " << t << endl;
+ << "expected namespace, class, documentation, or '}' instead of "
+ << t << endl;
throw error ();
}
}
@@ -684,7 +683,7 @@ class_def ()
auto_restore<scope> new_scope (scope_, n);
- // decl-seq
+ // class-decl-seq
//
t = lexer_->next ();
@@ -692,8 +691,16 @@ class_def ()
{
try
{
- if (!option_def (t))
- break;
+ if (t.type () == token::t_string_lit ||
+ t.punctuation () == token::p_lcbrace)
+ {
+ scope_doc (t);
+ }
+ else
+ {
+ if (!option_def (t))
+ break;
+ }
t = lexer_->next ();
}
@@ -707,7 +714,7 @@ class_def ()
if (t.punctuation () != token::p_rcbrace)
{
cerr << *path_ << ':' << t.line () << ':' << t.column () << ": error: "
- << "expected option declaration or '}' instead of " << t << endl;
+ << "expected option, documentation, or '}' instead of " << t << endl;
throw error ();
}
diff --git a/cli/runtime-header.cxx b/cli/runtime-header.cxx
index 42f7063..98a2e5d 100644
--- a/cli/runtime-header.cxx
+++ b/cli/runtime-header.cxx
@@ -40,6 +40,25 @@ generate_runtime_header (context& ctx)
ctx.ns_open (ctx.cli);
+ // usage_para
+ //
+ if (!ctx.options.suppress_usage ())
+ os << "class usage_para"
+ << "{"
+ << "public:" << endl
+ << "enum value"
+ << "{"
+ << "none," << endl
+ << "text," << endl
+ << "option" << endl
+ << "};"
+ << "usage_para (value);"
+ << endl
+ << "operator value () const {return v_;}" // Can't generate outside.
+ << "private:" << endl
+ << "value v_;"
+ << "};";
+
// unknown_mode
//
os << "class unknown_mode"
@@ -51,7 +70,7 @@ generate_runtime_header (context& ctx)
<< "stop," << endl
<< "fail" << endl
<< "};"
- << "unknown_mode (value v);"
+ << "unknown_mode (value);"
<< endl
<< "operator value () const {return v_;}" // Can't generate outside.
<< "private:" << endl
diff --git a/cli/runtime-inline.cxx b/cli/runtime-inline.cxx
index 15efa8d..ce53575 100644
--- a/cli/runtime-inline.cxx
+++ b/cli/runtime-inline.cxx
@@ -16,6 +16,18 @@ generate_runtime_inline (context& ctx)
ctx.ns_open (ctx.cli);
+ // usage_para
+ //
+ if (!ctx.options.suppress_usage ())
+ os << "// usage_para" << endl
+ << "//" << endl
+
+ << inl << "usage_para::" << endl
+ << "usage_para (value v)" << endl
+ << ": v_ (v)"
+ << "{"
+ << "}";
+
// unknown_mode
//
os << "// unknown_mode" << endl
diff --git a/cli/source.cxx b/cli/source.cxx
index 29f671e..2cb317d 100644
--- a/cli/source.cxx
+++ b/cli/source.cxx
@@ -11,8 +11,6 @@ using namespace std;
namespace
{
- //
- //
struct option_init: traversal::option, context
{
option_init (context& c) : context (c), comma_ (false) {}
@@ -292,6 +290,73 @@ namespace
}
}
+ enum paragraph {para_unknown, para_text, para_option};
+
+ struct doc: traversal::doc, context
+ {
+ doc (context& c, usage_type u, paragraph& p)
+ : context (c), usage_ (u), para_ (p) {}
+
+ virtual void
+ traverse (type& ds)
+ {
+ if (ds.name ().compare (0, 3, "doc") != 0) // Ignore doc variables.
+ return;
+
+ // Figure out which documentation string we should use.
+ //
+ // n = 1 - common doc string
+ // n = 2 - arg string, common doc string
+ // n > 2 - arg string, short string, long string
+ //
+ size_t n (ds.size ());
+ string d;
+
+ if (usage == ut_both && usage_ == ut_long)
+ {
+ d = n > 2 // Have both short and long?
+ ? ds[2] // Then use long.
+ : (n == 1 ? ds[0] : ds[1]); // Else, use common.
+ }
+ else // Short or long.
+ {
+ d = n > 2 // Have both short and long?
+ ? ds[1] // Then use short,
+ : (n == 1 ? ds[0] : ds[1]); // Else, use common (no first sentence).
+ }
+
+ std::set<string> arg_set;
+ if (n > 1 && options.ansi_color ())
+ translate_arg (ds[0], arg_set);
+
+ d = format (ot_plain, translate (d, arg_set), true);
+
+ if (d.empty ())
+ return;
+
+ string up (cli + "::usage_para");
+
+ if (para_ == para_unknown)
+ os << "if (p != " << up << "::none)" << endl
+ << "os << ::std::endl;"
+ << endl
+ << "os << \"";
+ else
+ os << "os << std::endl" << endl
+ << " << \"";
+
+ wrap_lines (os, d);
+ os << ";"
+ << endl;
+
+ para_ = para_text;
+ }
+
+ private:
+ usage_type usage_;
+ paragraph& para_;
+ };
+
struct option_length: traversal::option, context
{
option_length (context& c, size_t& l)
@@ -355,8 +420,8 @@ namespace
//
struct option_usage: traversal::option, context
{
- option_usage (context& c, size_t l, usage_type u)
- : context (c), length_ (l), usage_ (u) {}
+ option_usage (context& c, size_t l, usage_type u, paragraph& p)
+ : context (c), length_ (l), usage_ (u), para_ (p) {}
virtual void
traverse (type& o)
@@ -373,7 +438,18 @@ namespace
size_t l (0);
names& n (o.named ());
- os << "os << \"";
+ string up (cli + "::usage_para");
+
+ if (para_ == para_unknown)
+ os << "if (p == " << up << "::text)" << endl
+ << "os << ::std::endl;"
+ << endl
+ << "os << \"";
+ else if (para_ == para_text)
+ os << "os << std::endl" << endl
+ << " << \"";
+ else
+ os << "os << \"";
for (names::name_iterator i (n.name_begin ()); i != n.name_end (); ++i)
{
@@ -452,6 +528,8 @@ namespace
os << ";"
<< endl;
+
+ para_ = para_option;
}
private:
@@ -475,6 +553,7 @@ namespace
private:
size_t length_;
usage_type usage_;
+ paragraph& para_;
};
//
@@ -521,7 +600,7 @@ namespace
os << "// " << escape (c.name ()) << " base" << endl
<< "//" << endl
- << fq_name (c) << "::print_" << t << "usage (os);"
+ << "p = " << fq_name (c) << "::print_" << t << "usage (os, p);"
<< endl;
}
@@ -745,39 +824,53 @@ namespace
}
}
- // If len is 0 then it means we have no options to print.
- //
- os << "void " << name << "::" << endl
- << "print_usage (" <<
- options.ostream_type () << "&" << (len != 0 || b ? " os)" : ")")
- << "{";
+ string up (cli + "::usage_para");
+ string const& ost (options.ostream_type ());
+
+ os << up << " " << name << "::" << endl
+ << "print_usage (" << ost << "& os, " << up << " p)"
+ << "{"
+ << "CLI_POTENTIALLY_UNUSED (os);"
+ << endl;
{
- base_usage bu (*this, usage == ut_both ? ut_short : usage);
+ usage_type u (usage == ut_both ? ut_short : usage);
+
+ base_usage bu (*this, u);
traversal::inherits i (bu);
if (b && !options.include_base_last ())
inherits (c, i);
- // Print option usage.
- //
- option_usage ou (*this, len, usage == ut_both ? ut_short : usage);
- traversal::names n (ou);
+ paragraph p (para_unknown);
+
+ doc dc (*this, u, p);
+ option_usage ou (*this, len, u, p);
+ traversal::names n;
+ n >> dc;
+ n >> ou;
+
names (c, n);
+ if (p != para_unknown)
+ os << "p = " << up << (p == para_text ? "::text;" : "::option;")
+ << endl;
+
if (b && options.include_base_last ())
inherits (c, i);
}
- os << "}";
+ os << "return p;"
+ << "}";
// Long version.
//
if (usage == ut_both)
{
- os << "void " << name << "::" << endl
- << "print_long_usage (" <<
- options.ostream_type () << "&" << (len != 0 || b ? " os)" : ")")
- << "{";
+ os << up << " " << name << "::" << endl
+ << "print_long_usage (" << ost << "& os, " << up << " p)"
+ << "{"
+ << "CLI_POTENTIALLY_UNUSED (os);"
+ << endl;
base_usage bu (*this, ut_long);
traversal::inherits i (bu);
@@ -785,14 +878,25 @@ namespace
if (b && !options.include_base_last ())
inherits (c, i);
- option_usage ou (*this, len, ut_long);
- traversal::names n (ou);
+ paragraph p (para_unknown);
+
+ doc dc (*this, ut_long, p);
+ option_usage ou (*this, len, ut_long, p);
+ traversal::names n;
+ n >> dc;
+ n >> ou;
+
names (c, n);
+ if (p != para_unknown)
+ os << "p = " << up << (p == para_text ? "::text;" : "::option;")
+ << endl;
+
if (b && options.include_base_last ())
inherits (c, i);
- os << "}";
+ os << "return p;"
+ << "}";
}
}
@@ -986,68 +1090,6 @@ namespace
// Page usage.
//
- enum paragraph {para_none, para_text, para_option};
-
- struct doc: traversal::doc, context
- {
- doc (context& c, usage_type u, paragraph& p)
- : context (c), usage_ (u), para_ (p) {}
-
- virtual void
- traverse (type& ds)
- {
- if (ds.name ().compare (0, 3, "doc") != 0) // Ignore doc variables.
- return;
-
- // Figure out which documentation string we should use.
- //
- // n = 1 - common doc string
- // n = 2 - arg string, common doc string
- // n > 2 - arg string, short string, long string
- //
- size_t n (ds.size ());
- string d;
-
- if (usage == ut_both && usage_ == ut_long)
- {
- d = n > 2 // Have both short and long?
- ? ds[2] // Then use long.
- : (n == 1 ? ds[0] : ds[1]); // Else, use common.
- }
- else // Short or long.
- {
- d = n > 2 // Have both short and long?
- ? ds[1] // Then use short,
- : (n == 1 ? ds[0] : ds[1]); // Else, use common (no first sentence).
- }
-
- std::set<string> arg_set;
- if (n > 1 && options.ansi_color ())
- translate_arg (ds[0], arg_set);
-
- d = format (ot_plain, translate (d, arg_set), true);
-
- if (d.empty ())
- return;
-
- if (para_ == para_none) // First.
- os << "os << \"";
- else
- os << "os << ::std::endl" << endl
- << " << \"";
-
- wrap_lines (os, d);
- os << ";"
- << endl;
-
- para_ = para_text;
- }
-
- private:
- usage_type usage_;
- paragraph& para_;
- };
-
struct class_usage: traversal::class_, context
{
class_usage (context& c, usage_type u, paragraph& p)
@@ -1056,35 +1098,17 @@ namespace
virtual void
traverse (type& c)
{
- // Figure out if this class has any documentation by calculating
- // the option length. If it is 0, then we don't have any.
- //
- size_t len (0);
- {
- option_length olt (*this, len);
- traversal::class_ ct;
- traversal::inherits i;
- traversal::names n;
-
- if (!options.exclude_base ()) // Go into bases unless --exclude-base.
- ct >> i >> ct;
-
- ct >> n >> olt;
- ct.traverse (c);
- }
-
- if (len == 0)
- return;
-
- if (para_ == para_text)
- os << "os << ::std::endl;";
+ string p (
+ para_ == para_unknown
+ ? "p"
+ : cli + "::usage_para::" + (para_ == para_text ? "text" : "option"));
const char* t (usage != ut_both || usage_ == ut_short ? "" : "long_");
-
- os << fq_name (c) << "::print_" << t << "usage (os);"
+ os << "p = " << fq_name (c) << "::print_" << t << "usage (os, " <<
+ p << ");"
<< endl;
- para_ = para_option;
+ para_ = para_unknown;
}
private:
@@ -1125,22 +1149,23 @@ generate_source (context& ctx)
string n (ctx.escape (ctx.substitute (ctx.ns_open (qn, false))));
usage u (ctx.usage);
+ string up (ctx.cli + "::usage_para");
string const& ost (ctx.options.ostream_type ());
{
- os << "void" << endl
- << n << "usage (" << ost << "& os)"
+ os << up << endl
+ << n << "usage (" << ost << "& os, " << up << " p)"
<< "{"
<< "CLI_POTENTIALLY_UNUSED (os);"
<< endl;
- paragraph para (para_none);
+ paragraph p (para_unknown);
traversal::cli_unit unit;
traversal::names unit_names;
traversal::namespace_ ns;
- doc dc (ctx, u == ut_both ? ut_short : u, para);
- class_usage cl (ctx, u == ut_both ? ut_short : u, para);
+ doc dc (ctx, u == ut_both ? ut_short : u, p);
+ class_usage cl (ctx, u == ut_both ? ut_short : u, p);
unit >> unit_names;
unit_names >> dc;
@@ -1156,26 +1181,31 @@ generate_source (context& ctx)
unit.dispatch (ctx.unit);
- os << "}";
+ if (p != para_unknown)
+ os << "p = " << up << (p == para_text ? "::text;" : "::option;")
+ << endl;
+
+ os << "return p;"
+ << "}";
}
// Long version.
//
if (u == ut_both)
{
- os << "void" << endl
- << n << "long_usage (" << ost << "& os)"
+ os << up << endl
+ << n << "long_usage (" << ost << "& os, " << up << " p)"
<< "{"
<< "CLI_POTENTIALLY_UNUSED (os);"
<< endl;
- paragraph para (para_none);
+ paragraph p (para_unknown);
traversal::cli_unit unit;
traversal::names unit_names;
traversal::namespace_ ns;
- doc dc (ctx, ut_long, para);
- class_usage cl (ctx, ut_long, para);
+ doc dc (ctx, ut_long, p);
+ class_usage cl (ctx, ut_long, p);
unit >> unit_names;
unit_names >> dc;
@@ -1191,7 +1221,12 @@ generate_source (context& ctx)
unit.dispatch (ctx.unit);
- os << "}";
+ if (p != para_unknown)
+ os << "p = " << up << (p == para_text ? "::text;" : "::option;")
+ << endl;
+
+ os << "return p;"
+ << "}";
}
ctx.ns_close (qn, false);