aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-02-15 14:27:42 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-02-15 14:27:42 +0000
commita628fd00987749dc861f53c54864e83763066a58 (patch)
tree4e4bcb74b1e9e69692369fd84f99c3e21ac65f79
parent98b46fb61648d8b5aa4061256a5b41235afd94c1 (diff)
downloadpaludis-a628fd00987749dc861f53c54864e83763066a58.tar.gz
paludis-a628fd00987749dc861f53c54864e83763066a58.tar.xz
Allow extra description lines
-rw-r--r--paludis/args/args_handler.cc22
-rw-r--r--paludis/args/args_handler.hh20
-rw-r--r--paludis/args/man.cc47
-rw-r--r--paludis/args/man.hh20
4 files changed, 98 insertions, 11 deletions
diff --git a/paludis/args/args_handler.cc b/paludis/args/args_handler.cc
index 723e2ec..4df6b30 100644
--- a/paludis/args/args_handler.cc
+++ b/paludis/args/args_handler.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2005, 2006, 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2005, 2006, 2007, 2008, 2009 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -43,6 +43,7 @@ template class WrappedForwardIterator<ArgsHandler::ExamplesConstIteratorTag,
const std::pair<std::string, std::string> >;
template class WrappedForwardIterator<ArgsHandler::ArgsGroupsConstIteratorTag, ArgsGroup * const>;
template class WrappedForwardIterator<ArgsHandler::NotesIteratorTag, const std::string>;
+template class WrappedForwardIterator<ArgsHandler::DescriptionLineConstIterator, const std::string>;
namespace paludis
{
@@ -60,6 +61,7 @@ namespace paludis
std::list<std::pair<std::string, std::string> > environment_lines;
std::list<std::pair<std::string, std::string> > example_lines;
std::list<std::string> notes;
+ std::list<std::string> descriptions;
std::map<std::string, ArgsOption *> longopts;
std::map<char, ArgsOption *> shortopts;
@@ -331,3 +333,21 @@ ArgsHandler::end_args_groups() const
return ArgsGroupsConstIterator(_imp->groups.end());
}
+ArgsHandler::DescriptionLineConstIterator
+ArgsHandler::begin_description_lines() const
+{
+ return DescriptionLineConstIterator(_imp->descriptions.begin());
+}
+
+ArgsHandler::DescriptionLineConstIterator
+ArgsHandler::end_description_lines() const
+{
+ return DescriptionLineConstIterator(_imp->descriptions.end());
+}
+
+void
+ArgsHandler::add_description_line(const std::string & e)
+{
+ _imp->descriptions.push_back(e);
+}
+
diff --git a/paludis/args/args_handler.hh b/paludis/args/args_handler.hh
index 2f0320d..a2437d1 100644
--- a/paludis/args/args_handler.hh
+++ b/paludis/args/args_handler.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2005, 2006, 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2005, 2006, 2007, 2008, 2009 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -83,6 +83,11 @@ namespace paludis
void add_note(const std::string &);
/**
+ * Add a new description.
+ */
+ void add_description_line(const std::string & l);
+
+ /**
* Add an new ArgsGroup (called by the ArgsGroup constructor).
*/
void add(ArgsGroup * const);
@@ -221,6 +226,19 @@ namespace paludis
///\}
+ ///\name Iterate over our extra description lines (for documentation)
+ ///\{
+
+ struct DescriptionLineConstIteratorTag;
+ typedef WrappedForwardIterator<DescriptionLineConstIteratorTag, const std::string> DescriptionLineConstIterator;
+
+ DescriptionLineConstIterator begin_description_lines() const;
+
+ DescriptionLineConstIterator end_description_lines() const;
+
+ ///\}
+
+
/**
* Parse command line arguments. The third argument is used to
* set PALUDIS_CLIENT. The fourth argument is the name of an
diff --git a/paludis/args/man.cc b/paludis/args/man.cc
index 152297b..433c21e 100644
--- a/paludis/args/man.cc
+++ b/paludis/args/man.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006, 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2006, 2007, 2008, 2009 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -109,7 +109,13 @@ paludis::args::generate_doc(DocWriter & dw, const ArgsHandler * const h)
}
dw.start_description(h->app_description());
+ for (ArgsHandler::DescriptionLineConstIterator u(h->begin_description_lines()),
+ u_end(h->end_description_lines()) ;
+ u != u_end ; ++u)
+ dw.extra_description(*u);
+ dw.end_description();
+ dw.start_options();
for (ArgsHandler::ArgsGroupsConstIterator a(h->begin_args_groups()),
a_end(h->end_args_groups()) ; a != a_end ; ++a)
{
@@ -128,11 +134,11 @@ paludis::args::generate_doc(DocWriter & dw, const ArgsHandler * const h)
ExtraText t(dw);
(*b)->accept(t);
- dw.end_arg_group();
}
- dw.end_description();
+ dw.end_arg_group();
}
+ dw.end_options();
if (h->begin_environment_lines() != h->end_environment_lines())
{
@@ -198,6 +204,11 @@ HtmlWriter::start_description(const std::string & description)
{
_os << "<h2>Description</h2>" << endl;
_os << "<p>" << description << "</p>" << endl;
+}
+
+void
+HtmlWriter::start_options()
+{
_os << "<h2>Options</h2>" << endl;
}
@@ -256,13 +267,23 @@ HtmlWriter::end_extra_arg()
void
HtmlWriter::end_arg_group()
{
- _os << "</dd>" << endl;
+ _os << "</dl>" << endl;
+}
+
+void
+HtmlWriter::extra_description(const std::string & s)
+{
+ _os << "<p>" << s << "</p>" << endl;
}
void
HtmlWriter::end_description()
{
- _os << "</dl>" << endl;
+}
+
+void
+HtmlWriter::end_options()
+{
}
void
@@ -370,6 +391,11 @@ ManWriter::start_description(const std::string & description)
{
_os << ".SH DESCRIPTION" << endl;
_os << description << endl;
+}
+
+void
+ManWriter::start_options()
+{
_os << ".SH OPTIONS" << endl;
}
@@ -454,6 +480,11 @@ ManWriter::end_description()
}
void
+ManWriter::end_options()
+{
+}
+
+void
ManWriter::start_environment()
{
_os << ".SH ENVIRONMENT" << endl;
@@ -499,6 +530,12 @@ ManWriter::example(const std::string & first, const std::string & second)
}
void
+ManWriter::extra_description(const std::string & s)
+{
+ _os << endl << ungroff(s) << endl;
+}
+
+void
ManWriter::end_examples()
{
}
diff --git a/paludis/args/man.hh b/paludis/args/man.hh
index 527098c..de593a6 100644
--- a/paludis/args/man.hh
+++ b/paludis/args/man.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006, 2007 Ciaran McCreesh
+ * Copyright (c) 2006, 2007, 2009 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -60,6 +60,10 @@ namespace paludis
virtual void usage_line(const std::string & name, const std::string & line) = 0;
virtual void start_description(const std::string & description) = 0;
+ virtual void extra_description(const std::string & description) = 0;
+ virtual void end_description() = 0;
+
+ virtual void start_options() = 0;
virtual void start_arg_group(const std::string & name, const std::string & description) = 0;
virtual void arg_group_item(const char & short_name, const std::string & long_name,
const std::string & negated_long_name, const std::string & description) = 0;
@@ -69,7 +73,7 @@ namespace paludis
virtual void extra_arg_string_set(const std::string & first, const std::string & second) = 0;
virtual void end_extra_arg() = 0;
virtual void end_arg_group() = 0;
- virtual void end_description() = 0;
+ virtual void end_options() = 0;
virtual void start_environment() = 0;
virtual void environment_line(const std::string & first, const std::string & second) = 0;
@@ -116,6 +120,10 @@ namespace paludis
void usage_line(const std::string & name, const std::string & line);
void start_description(const std::string & description);
+ void extra_description(const std::string & description);
+ void end_description();
+
+ void start_options();
void start_arg_group(const std::string & name, const std::string & description);
void arg_group_item(const char & short_name, const std::string & long_name,
const std::string & negated_long_name, const std::string & description);
@@ -125,7 +133,7 @@ namespace paludis
void extra_arg_string_set(const std::string & first, const std::string & second);
void end_extra_arg();
void end_arg_group();
- void end_description();
+ void end_options();
void start_environment();
void environment_line(const std::string & first, const std::string & second);
@@ -170,6 +178,10 @@ namespace paludis
void usage_line(const std::string & name, const std::string & line);
void start_description(const std::string & description);
+ void extra_description(const std::string & description);
+ void end_description();
+
+ void start_options();
void start_arg_group(const std::string & name, const std::string & description);
void arg_group_item(const char & short_name, const std::string & long_name,
const std::string & negated_long_name, const std::string & description);
@@ -179,7 +191,7 @@ namespace paludis
void extra_arg_string_set(const std::string & first, const std::string & second);
void end_extra_arg();
void end_arg_group();
- void end_description();
+ void end_options();
void start_environment();
void environment_line(const std::string & first, const std::string & second);