summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-11-23 12:22:19 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-11-23 12:22:19 +0200
commit7e9cb673ccfc77c5871292aa5491fc2c2dc2a663 (patch)
treeccb92fe421c895525be3a5c82429db8ea984775a
parentccd0499c10b1ebf075bc251c4827ab79a6975165 (diff)
Add --include-base-last option
-rw-r--r--cli/html.cxx5
-rw-r--r--cli/man.cxx5
-rw-r--r--cli/options.cli6
-rw-r--r--cli/options.cxx11
-rw-r--r--cli/options.hxx12
-rw-r--r--cli/options.ixx6
-rw-r--r--cli/source.cxx45
7 files changed, 65 insertions, 25 deletions
diff --git a/cli/html.cxx b/cli/html.cxx
index 41d4c59..0394a3a 100644
--- a/cli/html.cxx
+++ b/cli/html.cxx
@@ -231,7 +231,7 @@ namespace
virtual void
traverse (type& c)
{
- if (!options.exclude_base ())
+ if (!options.exclude_base () && !options.include_base_last ())
inherits (c, inherits_base_);
if (!c.names_empty ())
@@ -241,6 +241,9 @@ namespace
os << " </dl>" << endl
<< endl;
}
+
+ if (!options.exclude_base () && options.include_base_last ())
+ inherits (c, inherits_base_);
}
private:
diff --git a/cli/man.cxx b/cli/man.cxx
index 70a5a4a..2d5cce7 100644
--- a/cli/man.cxx
+++ b/cli/man.cxx
@@ -185,10 +185,13 @@ namespace
virtual void
traverse (type& c)
{
- if (!options.exclude_base ())
+ if (!options.exclude_base () && !options.include_base_last ())
inherits (c, inherits_base_);
names (c, names_option_);
+
+ if (!options.exclude_base () && options.include_base_last ())
+ inherits (c, inherits_base_);
}
private:
diff --git a/cli/options.cli b/cli/options.cli
index 7f8c138..9212024 100644
--- a/cli/options.cli
+++ b/cli/options.cli
@@ -176,6 +176,12 @@ class options
"Exclude base class information from usage and documentation."
};
+ bool --include-base-last
+ {
+ "Include base class information after derived for usage and documentation.
+ By default, base classes are included first."
+ };
+
std::vector<std::string> --class
{
"<fq-name>",
diff --git a/cli/options.cxx b/cli/options.cxx
index 0ac1b4c..7d7f9cb 100644
--- a/cli/options.cxx
+++ b/cli/options.cxx
@@ -591,6 +591,7 @@ options ()
option_length_specified_ (false),
ansi_color_ (),
exclude_base_ (),
+ include_base_last_ (),
class__ (),
class__specified_ (false),
docvar_ (),
@@ -697,6 +698,7 @@ options (int& argc,
option_length_specified_ (false),
ansi_color_ (),
exclude_base_ (),
+ include_base_last_ (),
class__ (),
class__specified_ (false),
docvar_ (),
@@ -806,6 +808,7 @@ options (int start,
option_length_specified_ (false),
ansi_color_ (),
exclude_base_ (),
+ include_base_last_ (),
class__ (),
class__specified_ (false),
docvar_ (),
@@ -915,6 +918,7 @@ options (int& argc,
option_length_specified_ (false),
ansi_color_ (),
exclude_base_ (),
+ include_base_last_ (),
class__ (),
class__specified_ (false),
docvar_ (),
@@ -1026,6 +1030,7 @@ options (int start,
option_length_specified_ (false),
ansi_color_ (),
exclude_base_ (),
+ include_base_last_ (),
class__ (),
class__specified_ (false),
docvar_ (),
@@ -1133,6 +1138,7 @@ options (::cli::scanner& s,
option_length_specified_ (false),
ansi_color_ (),
exclude_base_ (),
+ include_base_last_ (),
class__ (),
class__specified_ (false),
docvar_ (),
@@ -1272,6 +1278,9 @@ print_usage (::std::ostream& os)
os << "--exclude-base Exclude base class information from usage and" << ::std::endl
<< " documentation." << ::std::endl;
+ os << "--include-base-last Include base class information after derived for" << ::std::endl
+ << " usage and documentation." << ::std::endl;
+
os << "--class <fq-name> Generate the man page or HTML documentation only" << ::std::endl
<< " for the <fq-name> options class." << ::std::endl;
@@ -1447,6 +1456,8 @@ struct _cli_options_map_init
&::cli::thunk< options, bool, &options::ansi_color_ >;
_cli_options_map_["--exclude-base"] =
&::cli::thunk< options, bool, &options::exclude_base_ >;
+ _cli_options_map_["--include-base-last"] =
+ &::cli::thunk< options, bool, &options::include_base_last_ >;
_cli_options_map_["--class"] =
&::cli::thunk< options, std::vector<std::string>, &options::class__,
&options::class__specified_ >;
diff --git a/cli/options.hxx b/cli/options.hxx
index 020ff40..65dae49 100644
--- a/cli/options.hxx
+++ b/cli/options.hxx
@@ -18,6 +18,14 @@
#include <cstddef>
#include <exception>
+#ifndef CLI_POTENTIALLY_UNUSED
+# if defined(_MSC_VER) || defined(__xlC__)
+# define CLI_POTENTIALLY_UNUSED(x) (void*)&x
+# else
+# define CLI_POTENTIALLY_UNUSED(x) (void)x
+# endif
+#endif
+
namespace cli
{
class unknown_mode
@@ -452,6 +460,9 @@ class options
const bool&
exclude_base () const;
+ const bool&
+ include_base_last () const;
+
const std::vector<std::string>&
class_ () const;
@@ -701,6 +712,7 @@ class options
bool option_length_specified_;
bool ansi_color_;
bool exclude_base_;
+ bool include_base_last_;
std::vector<std::string> class__;
bool class__specified_;
std::map<std::string, std::string> docvar_;
diff --git a/cli/options.ixx b/cli/options.ixx
index 447fe18..9759dd2 100644
--- a/cli/options.ixx
+++ b/cli/options.ixx
@@ -383,6 +383,12 @@ exclude_base () const
return this->exclude_base_;
}
+inline const bool& options::
+include_base_last () const
+{
+ return this->include_base_last_;
+}
+
inline const std::vector<std::string>& options::
class_ () const
{
diff --git a/cli/source.cxx b/cli/source.cxx
index 2113034..29f671e 100644
--- a/cli/source.cxx
+++ b/cli/source.cxx
@@ -751,22 +751,21 @@ namespace
<< "print_usage (" <<
options.ostream_type () << "&" << (len != 0 || b ? " os)" : ")")
<< "{";
-
- // Call our bases.
- //
- if (b)
{
- base_usage t (*this, usage == ut_both ? ut_short : usage);
- traversal::inherits i (t);
- inherits (c, i);
- }
+ base_usage bu (*this, usage == ut_both ? ut_short : usage);
+ traversal::inherits i (bu);
- // Print option usage.
- //
- {
- option_usage t (*this, len, usage == ut_both ? ut_short : usage);
- traversal::names n (t);
+ 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);
names (c, n);
+
+ if (b && options.include_base_last ())
+ inherits (c, i);
}
os << "}";
@@ -780,18 +779,18 @@ namespace
options.ostream_type () << "&" << (len != 0 || b ? " os)" : ")")
<< "{";
- if (b)
- {
- base_usage t (*this, ut_long);
- traversal::inherits i (t);
+ base_usage bu (*this, ut_long);
+ traversal::inherits i (bu);
+
+ if (b && !options.include_base_last ())
inherits (c, i);
- }
- {
- option_usage t (*this, len, ut_long);
- traversal::names n (t);
- names (c, n);
- }
+ option_usage ou (*this, len, ut_long);
+ traversal::names n (ou);
+ names (c, n);
+
+ if (b && options.include_base_last ())
+ inherits (c, i);
os << "}";
}