summaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2012-05-11 12:25:53 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2012-05-11 12:25:53 +0200
commitaa33636c20b65dbf87e2189dc3d8759b883e7909 (patch)
tree8b57ff0e570429dae4266a0204b7d4ab4f73a744 /cli
parent5a2e172ce1f2d823bf0957602662bbab0c0dcd0b (diff)
Add support for specifying multiple classes with --class option
Diffstat (limited to 'cli')
-rw-r--r--cli/html.cxx40
-rw-r--r--cli/man.cxx40
-rw-r--r--cli/options.cli12
-rw-r--r--cli/options.cxx4
-rw-r--r--cli/options.hxx4
-rw-r--r--cli/options.ixx2
6 files changed, 68 insertions, 34 deletions
diff --git a/cli/html.cxx b/cli/html.cxx
index 1f0c328..8897f4e 100644
--- a/cli/html.cxx
+++ b/cli/html.cxx
@@ -3,8 +3,13 @@
// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
// license : MIT; see accompanying LICENSE file
+#include <vector>
+#include <iostream>
+
#include "html.hxx"
+using namespace std;
+
namespace
{
struct option: traversal::option, context
@@ -169,17 +174,6 @@ namespace
virtual void
traverse (type& c)
{
- string const& n (options.class_ ());
-
- if (!n.empty ())
- {
- string fqn (fq_name (c, false));
- fqn = string (fqn, 2, fqn.size () - 2); // Get rid of leading ::.
-
- if (n != fqn)
- return;
- }
-
if (!options.exclude_base ())
inherits (c, inherits_base_);
@@ -213,7 +207,29 @@ generate_html (context& ctx)
ctx.os << "<dl class=\"options\">" << endl;
- unit.dispatch (ctx.unit);
+ if (ctx.options.class_ ().empty ())
+ unit.dispatch (ctx.unit);
+ else
+ {
+ for (vector<string>::const_iterator i (ctx.options.class_ ().begin ());
+ i != ctx.options.class_ ().end (); ++i)
+ {
+ string n (*i);
+
+ // Strip leading :: if present.
+ //
+ if (n.size () > 2 && n[0] == ':' && n[1] == ':')
+ n = string (n, 2, string::npos);
+
+ if (semantics::class_* c = ctx.unit.lookup<semantics::class_> ("", n))
+ cl.traverse (*c);
+ else
+ {
+ cerr << "error: class '" << *i << "' not found" << endl;
+ throw generation_failed ();
+ }
+ }
+ }
ctx.os << "</dl>" << endl;
}
diff --git a/cli/man.cxx b/cli/man.cxx
index ac5d9b1..576ee04 100644
--- a/cli/man.cxx
+++ b/cli/man.cxx
@@ -3,8 +3,13 @@
// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
// license : MIT; see accompanying LICENSE file
+#include <vector>
+#include <iostream>
+
#include "man.hxx"
+using namespace std;
+
namespace
{
struct option: traversal::option, context
@@ -129,17 +134,6 @@ namespace
virtual void
traverse (type& c)
{
- string const& n (options.class_ ());
-
- if (!n.empty ())
- {
- string fqn (fq_name (c, false));
- fqn = string (fqn, 2, fqn.size () - 2); // Get rid of leading ::.
-
- if (n != fqn)
- return;
- }
-
if (!options.exclude_base ())
inherits (c, inherits_base_);
@@ -171,5 +165,27 @@ generate_man (context& ctx)
ns >> ns_names >> ns;
ns_names >> cl;
- unit.dispatch (ctx.unit);
+ if (ctx.options.class_ ().empty ())
+ unit.dispatch (ctx.unit);
+ else
+ {
+ for (vector<string>::const_iterator i (ctx.options.class_ ().begin ());
+ i != ctx.options.class_ ().end (); ++i)
+ {
+ string n (*i);
+
+ // Strip leading :: if present.
+ //
+ if (n.size () > 2 && n[0] == ':' && n[1] == ':')
+ n = string (n, 2, string::npos);
+
+ if (semantics::class_* c = ctx.unit.lookup<semantics::class_> ("", n))
+ cl.traverse (*c);
+ else
+ {
+ cerr << "error: class '" << *i << "' not found" << endl;
+ throw generation_failed ();
+ }
+ }
+ }
}
diff --git a/cli/options.cli b/cli/options.cli
index 074e7a9..ad91ddc 100644
--- a/cli/options.cli
+++ b/cli/options.cli
@@ -20,7 +20,7 @@ class options
std::vector<std::string> --include-path | -I
{
"<dir>",
- "Search <dir> for bracket-included (\cb{<>}) option files."
+ "Search <dir> for bracket-included (\cb{<>}) options files."
};
std::string --output-dir | -o
@@ -138,14 +138,16 @@ class options
"Insert the content of <file> at the end of the HTML file."
};
- std::string --class
+ std::vector<std::string> --class
{
"<fq-name>",
"Generate the man page or HTML documentation only for the <fq-name> options
class. The <fq-name> name should be a fully-qualified options class name,
- for example, \cb{app::options}. This functionality is useful if you need
- to insert custom documentation between options belonging to different
- classes."
+ for example, \cb{app::options}. To generate documentation for multiple
+ classes, repeat this option and the documentation will be produced in
+ the order specified. This functionality is useful if you need to assemble
+ documentation from multiple classes in a specific order or to insert
+ custom documentation between options belonging to different classes."
};
bool --stdout
diff --git a/cli/options.cxx b/cli/options.cxx
index a720a2a..ed9645b 100644
--- a/cli/options.cxx
+++ b/cli/options.cxx
@@ -833,7 +833,7 @@ print_usage (::std::ostream& os)
os << "--version Print version and exit." << ::std::endl;
- os << "--include-path|-I <dir> Search <dir> for bracket-included ('<>') option" << ::std::endl
+ os << "--include-path|-I <dir> Search <dir> for bracket-included ('<>') options" << ::std::endl
<< " files." << ::std::endl;
os << "--output-dir|-o <dir> Write the generated files to <dir> instead of the" << ::std::endl
@@ -991,7 +991,7 @@ struct _cli_options_map_init
_cli_options_map_["--html-epilogue"] =
&::cli::thunk< options, std::string, &options::html_epilogue_ >;
_cli_options_map_["--class"] =
- &::cli::thunk< options, std::string, &options::class__ >;
+ &::cli::thunk< options, std::vector<std::string>, &options::class__ >;
_cli_options_map_["--stdout"] =
&::cli::thunk< options, bool, &options::stdout__ >;
_cli_options_map_["--hxx-suffix"] =
diff --git a/cli/options.hxx b/cli/options.hxx
index 748e7bb..61674fc 100644
--- a/cli/options.hxx
+++ b/cli/options.hxx
@@ -416,7 +416,7 @@ class options
const std::string&
html_epilogue () const;
- const std::string&
+ const std::vector<std::string>&
class_ () const;
const bool&
@@ -500,7 +500,7 @@ class options
std::string man_epilogue_;
std::string html_prologue_;
std::string html_epilogue_;
- std::string class__;
+ std::vector<std::string> class__;
bool stdout__;
std::string hxx_suffix_;
std::string ixx_suffix_;
diff --git a/cli/options.ixx b/cli/options.ixx
index 34efe21..8d8a35f 100644
--- a/cli/options.ixx
+++ b/cli/options.ixx
@@ -328,7 +328,7 @@ html_epilogue () const
return this->html_epilogue_;
}
-inline const std::string& options::
+inline const std::vector<std::string>& options::
class_ () const
{
return this->class__;