man.hh

00001 /* vim: set sw=4 sts=4 et foldmethod=syntax : */
00002 
00003 /*
00004  * Copyright (c) 2006, 2007, 2009 Ciaran McCreesh
00005  *
00006  * This file is part of the Paludis package manager. Paludis is free software;
00007  * you can redistribute it and/or modify it under the terms of the GNU General
00008  * Public License version 2, as published by the Free Software Foundation.
00009  *
00010  * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
00011  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00012  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
00013  * details.
00014  *
00015  * You should have received a copy of the GNU General Public License along with
00016  * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
00017  * Place, Suite 330, Boston, MA  02111-1307  USA
00018  */
00019 
00020 #ifndef PALUDIS_GUARD_PALUDIS_ARGS_MAN_HH
00021 #define PALUDIS_GUARD_PALUDIS_ARGS_MAN_HH 1
00022 
00023 #include <paludis/args/args.hh>
00024 #include <iosfwd>
00025 
00026 namespace paludis
00027 {
00028     namespace args
00029     {
00030         class DocWriter;
00031 
00032         /**
00033          * Write docs to an ostream.
00034          *
00035          * \ingroup grplibpaludisargs
00036          */
00037         void generate_doc(DocWriter & dw, const ArgsHandler * const h) PALUDIS_VISIBLE;
00038 
00039         /**
00040          * Write docs from args classes in a particular format.
00041          *
00042          * \ingroup grplibpaludisargs
00043          * \nosubgrouping
00044          */
00045         class PALUDIS_VISIBLE DocWriter
00046         {
00047             public:
00048                 ///\name Basic operations
00049                 ///\{
00050 
00051                 virtual ~DocWriter() = 0;
00052 
00053                 ///\}
00054 
00055                 ///\name Output routines
00056                 ///\{
00057 
00058                 virtual void heading(const std::string & name, const std::string & section,
00059                         const std::string & synopsis) = 0;
00060                 virtual void usage_line(const std::string & name, const std::string & line) = 0;
00061 
00062                 virtual void start_description(const std::string & description) = 0;
00063                 virtual void extra_description(const std::string & description) = 0;
00064                 virtual void end_description() = 0;
00065 
00066                 virtual void start_options(const std::string &) = 0;
00067                 virtual void start_arg_group(const std::string & name, const std::string & description) = 0;
00068                 virtual void arg_group_item(const char & short_name, const std::string & long_name,
00069                         const std::string & negated_long_name, const std::string & description) = 0;
00070                 virtual void start_extra_arg() = 0;
00071                 virtual void extra_arg_enum(const AllowedEnumArg &, const std::string & default_arg) = 0;
00072                 virtual void extra_arg_string_set(const std::string & first, const std::string & second) = 0;
00073                 virtual void end_extra_arg() = 0;
00074                 virtual void end_arg_group() = 0;
00075                 virtual void end_options() = 0;
00076 
00077                 virtual void start_environment() = 0;
00078                 virtual void environment_line(const std::string & first, const std::string & second) = 0;
00079                 virtual void end_environment() = 0;
00080 
00081                 virtual void start_examples() = 0;
00082                 virtual void example(const std::string &, const std::string &) = 0;
00083                 virtual void end_examples() = 0;
00084 
00085                 virtual void start_notes() = 0;
00086                 virtual void note(const std::string &) = 0;
00087                 virtual void end_notes() = 0;
00088 
00089                 virtual void section(const std::string & title) = 0;
00090                 virtual void subsection(const std::string & title) = 0;
00091                 virtual void paragraph(const std::string & text) = 0;
00092 
00093                 ///\}
00094         };
00095 
00096         /**
00097          * Create HTML documentation from args classes.
00098          *
00099          * \ingroup grplibpaludisargs
00100          * \nosubgrouping
00101          */
00102         class PALUDIS_VISIBLE HtmlWriter :
00103             public DocWriter
00104         {
00105             private:
00106                 std::ostream & _os;
00107 
00108             public:
00109                 ///\name Basic operations
00110                 ///\{
00111 
00112                 HtmlWriter(std::ostream & os);
00113                 ~HtmlWriter();
00114 
00115                 ///\}
00116 
00117                 void heading(const std::string & name, const std::string & section,
00118                         const std::string & synopis);
00119                 void usage_line(const std::string & name, const std::string & line);
00120 
00121                 void start_description(const std::string & description);
00122                 void extra_description(const std::string & description);
00123                 void end_description();
00124 
00125                 void start_options(const std::string &);
00126                 void start_arg_group(const std::string & name, const std::string & description);
00127                 void arg_group_item(const char & short_name, const std::string & long_name,
00128                         const std::string & negated_long_name, const std::string & description);
00129                 void start_extra_arg();
00130                 void extra_arg_enum(const AllowedEnumArg &, const std::string & default_arg);
00131                 void extra_arg_string_set(const std::string & first, const std::string & second);
00132                 void end_extra_arg();
00133                 void end_arg_group();
00134                 void end_options();
00135 
00136                 void start_environment();
00137                 void environment_line(const std::string & first, const std::string & second);
00138                 void end_environment();
00139 
00140                 void start_examples();
00141                 void example(const std::string &, const std::string &);
00142                 void end_examples();
00143 
00144                 void start_notes();
00145                 void note(const std::string &);
00146                 void end_notes();
00147 
00148                 void section(const std::string & title);
00149                 void subsection(const std::string & title);
00150                 void paragraph(const std::string & text);
00151         };
00152 
00153         /**
00154          * Create man documentation from args classes.
00155          *
00156          * \ingroup grplibpaludisargs
00157          * \nosubgrouping
00158          */
00159         class PALUDIS_VISIBLE ManWriter :
00160             public DocWriter
00161         {
00162             private:
00163                 std::ostream & _os;
00164 
00165             public:
00166                 ///\name Basic operations
00167                 ///\{
00168 
00169                 ManWriter(std::ostream & os);
00170                 ~ManWriter();
00171 
00172                 ///\}
00173 
00174                 void heading(const std::string & name, const std::string & section,
00175                         const std::string & synopis);
00176                 void usage_line(const std::string & name, const std::string & line);
00177 
00178                 void start_description(const std::string & description);
00179                 void extra_description(const std::string & description);
00180                 void end_description();
00181 
00182                 void start_options(const std::string &);
00183                 void start_arg_group(const std::string & name, const std::string & description);
00184                 void arg_group_item(const char & short_name, const std::string & long_name,
00185                         const std::string & negated_long_name, const std::string & description);
00186                 void start_extra_arg();
00187                 void extra_arg_enum(const AllowedEnumArg &, const std::string & default_arg);
00188                 void extra_arg_string_set(const std::string & first, const std::string & second);
00189                 void end_extra_arg();
00190                 void end_arg_group();
00191                 void end_options();
00192 
00193                 void start_environment();
00194                 void environment_line(const std::string & first, const std::string & second);
00195                 void end_environment();
00196 
00197                 void start_examples();
00198                 void example(const std::string &, const std::string &);
00199                 void end_examples();
00200 
00201                 void start_notes();
00202                 void note(const std::string &);
00203                 void end_notes();
00204 
00205                 void section(const std::string & title);
00206                 void subsection(const std::string & title);
00207                 void paragraph(const std::string & text);
00208         };
00209 
00210     }
00211 }
00212 
00213 #endif

Generated on Mon Sep 21 10:36:08 2009 for paludis by  doxygen 1.5.4