Xmipp  v3.23.11-Nereus
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
WikiPrinter Class Reference

#include <argsprinter.h>

Inheritance diagram for WikiPrinter:
Inheritance graph
[legend]
Collaboration diagram for WikiPrinter:
Collaboration graph
[legend]

Public Member Functions

 WikiPrinter (std::ostream &out=std::cout)
 
virtual void printProgram (const ProgramDef &program, int v=0)
 
virtual void printSection (const SectionDef &section, int v=0)
 
virtual void printParam (const ParamDef &param, int v=0)
 
virtual void printArgument (const ArgumentDef &argument, int v=0)
 
virtual void printCommentList (const CommentList &comments, int v=0)
 
- Public Member Functions inherited from Printer
virtual ~Printer ()
 
virtual void printToken (ArgToken *token)
 

Protected Member Functions

void printRequiresList (StringVector requires)
 

Protected Attributes

std::ostream * pOut
 

Detailed Description

Print wiki text

Definition at line 87 of file argsprinter.h.

Constructor & Destructor Documentation

◆ WikiPrinter()

WikiPrinter::WikiPrinter ( std::ostream &  out = std::cout)

Constructor

Definition at line 305 of file argsprinter.cpp.

306 {
307  this->pOut = &out;
308 }
std::ostream * pOut
Definition: argsprinter.h:90

Member Function Documentation

◆ printArgument()

void WikiPrinter::printArgument ( const ArgumentDef argument,
int  v = 0 
)
virtual

Implements Printer.

Definition at line 457 of file argsprinter.cpp.

458 {
459  *pOut << "&lt;" << argument.name;
460  if (argument.hasDefault)
461  *pOut << "=" << argument.argDefault;
462  *pOut << "&gt;";
463 }
String name
Definition: argsparser.h:152
bool hasDefault
Definition: argsparser.h:176
String argDefault
Definition: argsparser.h:172
std::ostream * pOut
Definition: argsprinter.h:90

◆ printCommentList()

void WikiPrinter::printCommentList ( const CommentList comments,
int  v = 0 
)
virtual

Implements Printer.

Definition at line 465 of file argsprinter.cpp.

466 {
467  *pOut << " ";
468  for (size_t i = 0; i < comments.size(); ++i)
469  if (comments.visibility[i] <= v)
470  *pOut << comments.comments[i] << " ";
471  *pOut << "%BR%" << std::endl;
472 }
std::vector< int > visibility
Definition: comment_list.h:36
#define i
size_t size() const
StringVector comments
Definition: comment_list.h:35
std::ostream * pOut
Definition: argsprinter.h:90

◆ printParam()

void WikiPrinter::printParam ( const ParamDef param,
int  v = 0 
)
virtual

Implements Printer.

Definition at line 400 of file argsprinter.cpp.

401 {
402  //* =%BLUE%-i [selfile] %ENDCOLOR%= This file contains all the images that are to build the 3D reconstruction
403  //* =%GREEN% -o [output file root name] %ENDCOLOR%= If you don't supply this parameter, the same as the input selection one is taken without extension. If you give, for instance, =-o art0001= the following files are created:
404  if (param.visible <= v)
405  {
406  *pOut << " $";
407 
408  if (param.orBefore)
409  *pOut << " or";
410 
411  String color = param.notOptional ? "BLUE" : "GREEN";
412 
413  *pOut << " =%" << color << "%" << param.name;
414  //print alias
415  for (size_t i = 0; i < param.aliases.size(); ++i)
416  *pOut << ", " << param.aliases[i];
417  //print arguments
418  for (size_t i = 0; i < param.arguments.size(); ++i)
419  {
420  *pOut << " ";
421  printArgument(*param.arguments[i], v);
422  }
423  *pOut << " %ENDCOLOR%=";
425  *pOut <<": " ;
426  printCommentList(param.comments, v);
427 
428  if (param.comments.size() == 0)
429  *pOut << "%BR%" << std::endl;
430 
431  for (size_t i = 0; i < param.arguments.size(); ++i)
432  {
433  ArgumentDef &arg = *param.arguments[i];
434  if (!arg.subParams.empty())
435  {
436  *pOut << " where &lt;" << arg.name << "&gt; can be:" << std::endl;
437  for (size_t j = 0; j < arg.subParams.size(); ++j)
438  {
439  *pOut << " * %MAROON% " << arg.subParams[j]->name;
440  for (size_t k = 0; k < arg.subParams[j]->arguments.size(); ++k)
441  {
442  *pOut << " ";
443  printArgument(*(arg.subParams[j]->arguments[k]), v);
444  }
445  *pOut << " %ENDCOLOR%" << std::endl;
446  printRequiresList(arg.subParams[j]->requires);
447  // *pOut << std::endl;
448  printCommentList(arg.subParams[j]->comments, v);
449 
450  }
451  }
452  }
453 
454  }
455 }
String name
Definition: argsparser.h:152
bool notOptional
Definition: argsparser.h:195
virtual void printArgument(const ArgumentDef &argument, int v=0)
CommentList comments
Definition: argsparser.h:203
void printRequiresList(StringVector requires)
#define i
ql0001_ & k(htemp+1),(cvec+1),(atemp+1),(bj+1),(bl+1),(bu+1),(x+1),(clamda+1), &iout, infoqp, &zero,(w+1), &lenw,(iw+1), &leniw, &glob_grd.epsmac
StringVector requires
Definition: argsparser.h:205
int visible
Definition: argsparser.h:153
std::vector< ParamDef * > subParams
Definition: argsparser.h:175
virtual void printCommentList(const CommentList &comments, int v=0)
std::vector< ArgumentDef * > arguments
Definition: argsparser.h:198
size_t size() const
for(j=1;j<=i__1;++j)
#define j
std::string String
Definition: xmipp_strings.h:34
std::ostream * pOut
Definition: argsprinter.h:90
bool orBefore
Definition: argsparser.h:196
StringVector aliases
Definition: argsparser.h:204

◆ printProgram()

void WikiPrinter::printProgram ( const ProgramDef program,
int  v = 0 
)
virtual

Implements Printer.

Definition at line 310 of file argsprinter.cpp.

311 {
312  //print program name and usage
313  *pOut << "---+ !!" << program.name << " (v" << XMIPP_MAJOR <<"." << XMIPP_MINOR << ")" << std::endl;
314  *pOut << "%TOC%" << std::endl;
315  //print usage
316  if (program.usageComments.size() > 0)
317  {
318  *pOut << "---++ Usage" << std::endl;
319  for (size_t i = 0; i < program.usageComments.size(); ++i)
320  if (program.usageComments.wikiVerbatim[i])
321  *pOut << " <pre>" << program.usageComments.comments[i] << "</pre>\n";
322  else
323  *pOut << " " << program.usageComments.comments[i] << std::endl;
324  }
325  if (!program.seeAlso.empty())
326  {
327  *pOut << std::endl << "*See also* %BR%" << std::endl;
328  StringVector links;
329  splitString(program.seeAlso, ",", links);
330  for (size_t i = 0; i < links.size(); ++i)
331  *pOut << "[[" << links[i] << "_v" << XMIPP_MAJOR << "][" << links[i] <<"]] ";
332  *pOut << "%BR%" << std::endl;
333  }
334  //print sections and params
335  if (program.sections.size() > 0)
336  {
337  *pOut << std::endl << "*Parameters*" << std::endl;
338  for (size_t i = 0; i < program.sections.size(); ++i)
339  printSection(*program.sections[i], v);
340  }
341  //print examples
342  if (program.examples.size() > 0)
343  {
344  *pOut << "---++ Examples and notes" << std::endl;
345  bool verbatim = false;
346  for (size_t i = 0; i < program.examples.size(); ++i)
347  {
348  if (program.examples.wikiVerbatim[i])
349  {
350  if (!verbatim)
351  {
352  *pOut << "<pre>" << std::endl;
353  verbatim = true;
354  }
355  }
356  else
357  {
358  if (verbatim)
359  {
360  *pOut << "</pre>" << std::endl;
361  verbatim = false;
362  }
363  }
364  *pOut << program.examples.comments[i] << std::endl;
365  }
366  if (verbatim)
367  *pOut << "</pre>" << std::endl;
368  }
369  //print user comments
370  *pOut << "---++ User's comments" << std::endl;
371  *pOut << "%COMMENT{type=\"tableappend\"}%" << std::endl;
372 }
String name
Definition: argsparser.h:152
std::vector< SectionDef * > sections
Definition: argsparser.h:241
std::vector< String > StringVector
Definition: xmipp_strings.h:35
#define i
std::vector< bool > wikiVerbatim
Definition: comment_list.h:37
int splitString(const String &input, const String &delimiter, StringVector &results, bool includeEmpties)
String seeAlso
Definition: argsparser.h:247
size_t size() const
#define XMIPP_MAJOR
Definition: argsprinter.h:31
StringVector comments
Definition: comment_list.h:35
CommentList examples
examples of use
Definition: argsparser.h:243
CommentList usageComments
comments of usage
Definition: argsparser.h:242
std::ostream * pOut
Definition: argsprinter.h:90
#define XMIPP_MINOR
Definition: argsprinter.h:32
virtual void printSection(const SectionDef &section, int v=0)

◆ printRequiresList()

void WikiPrinter::printRequiresList ( StringVector  requires)
protected

Definition at line 389 of file argsprinter.cpp.

390 {
391  if (!requires.empty())
392  {
393  *pOut << " ( requires ";
394  for (size_t i = 0; i < requires.size(); ++i)
395  *pOut << requires[i] << " ";
396  *pOut << ")";
397  }
398 }
#define i
std::ostream * pOut
Definition: argsprinter.h:90

◆ printSection()

void WikiPrinter::printSection ( const SectionDef section,
int  v = 0 
)
virtual

Implements Printer.

Definition at line 374 of file argsprinter.cpp.

375 {
376  if (section.name != " Common options "
377  && section.visible <= v)
378  {
379  *pOut << std::endl;
380  String name = section.name;
381  trim(name);
382  if (name.length() > 0)
383  *pOut << "_" << name << "_" << std::endl;
384  for (size_t i = 0; i < section.params.size(); ++i)
385  printParam(*section.params[i], v);
386  }
387 }
String name
Definition: argsparser.h:152
void trim(std::string &s)
Definition: text.cpp:205
#define i
int visible
Definition: argsparser.h:153
std::vector< ParamDef * > params
All params defined for the program.
Definition: argsparser.h:224
std::string String
Definition: xmipp_strings.h:34
virtual void printParam(const ParamDef &param, int v=0)
std::ostream * pOut
Definition: argsprinter.h:90

Member Data Documentation

◆ pOut

std::ostream* WikiPrinter::pOut
protected

Definition at line 90 of file argsprinter.h.


The documentation for this class was generated from the following files: