FAUST compiler  0.9.9.6b8
Functions | Variables
doc_autodoc.cpp File Reference
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <cstdlib>
#include "doc_autodoc.hh"
#include "tlib.hh"
#include "boxes.hh"
#include "doc.hh"
Include dependency graph for doc_autodoc.cpp:

Go to the source code of this file.

Functions

static void initDocAutodocKeySet ()
 Initialize gDocAutodocKeySet, a set containing all the keywords. More...
 
void declareAutoDoc ()
 Declare an automatic documentation. More...
 
void initDocAutodoc ()
 Dispatch initialization of autodoc container. More...
 
static void printDocAutodocStringMapContent ()
 Simple trace function. More...
 

Variables

SourceReader gReader
 
string gDocName
 Contains the filename for out documentation. More...
 
map< Tree, set< Tree > > gMetaDataSet
 
map< string, string > gDocMetadatasStringMap
 
map< string, string > gDocAutodocStringMap
 
set< string > gDocAutodocKeySet
 

Function Documentation

void declareAutoDoc ( )

Declare an automatic documentation.

This function simulates a default documentation : if no <mdoc> tag was found in the input faust file, and yet the '-mdoc' option was called, then print a complete 'process' doc.

Autodoc's "head", with title, author, date, and metadatas.

The latex title macro is bound to the metadata "name" if it exists, (corresponding to "declare name") or else just to the file name.

The latex author macro is bound to the metadata "author" if it exists, (corresponding to "declare author") or else no author item is printed.

The latex date macro is bound to the metadata "date" if it exists, (corresponding to "declare date") or else to the today latex macro.

The latex maketitle macro.

Insert all declared metadatas in a latex tabular environment.

Autodoc's "body", with equation and diagram of process, and notice and listing.

Definition at line 61 of file doc_autodoc.cpp.

References boxIdent(), cons(), declareDoc(), docDgm(), docEqn(), docLst(), docMtd(), docNtc(), docTxt(), gDocAutodocStringMap, gDocMetadatasStringMap, gDocName, gMetaDataSet, SourceReader::listSrcFiles(), nil, tree(), and tree2str().

Referenced by printDoc().

62 {
63  Tree autodoc = nil;
64  Tree process = boxIdent("process");
65 
70  autodoc = cons(docTxt("\\title{"), autodoc);
71  if (gMetaDataSet.count(tree("name"))) {
72  autodoc = cons(docMtd(tree("name")), autodoc);
73  } else {
74  autodoc = cons(docTxt(gDocName.c_str()), autodoc);
75  }
76  autodoc = cons(docTxt("}\n"), autodoc);
77 
80  if (gMetaDataSet.count(tree("author"))) {
81  autodoc = cons(docTxt("\\author{"), autodoc);
82  autodoc = cons(docMtd(tree("author")), autodoc);
83  autodoc = cons(docTxt("}\n"), autodoc);
84  }
85 
88  autodoc = cons(docTxt("\\date{"), autodoc);
89  if (gMetaDataSet.count(tree("date"))) {
90  autodoc = cons(docMtd(tree("date")), autodoc);
91  } else {
92  autodoc = cons(docTxt("\\today"), autodoc);
93  }
94  autodoc = cons(docTxt("}\n"), autodoc);
95 
97  autodoc = cons(docTxt("\\maketitle\n"), autodoc);
98 
99 
101  if (! gMetaDataSet.empty()) {
102  autodoc = cons(docTxt("\\begin{tabular}{ll}\n"), autodoc);
103  autodoc = cons(docTxt("\t\\hline\n"), autodoc);
104  for (map<Tree, set<Tree> >::iterator i = gMetaDataSet.begin(); i != gMetaDataSet.end(); i++) {
105  string mtdkey = tree2str(i->first);
106  string mtdTranslatedKey = gDocMetadatasStringMap[mtdkey];
107  if (mtdTranslatedKey.empty()) {
108  mtdTranslatedKey = mtdkey;
109  }
110  autodoc = cons(docTxt("\t\\textbf{"), autodoc);
111  autodoc = cons(docTxt(mtdTranslatedKey.c_str()), autodoc);
112  autodoc = cons(docTxt("} & "), autodoc);
113  autodoc = cons(docMtd(tree(mtdkey.c_str())), autodoc);
114  autodoc = cons(docTxt(" \\\\\n"), autodoc);
115  }
116  autodoc = cons(docTxt("\t\\hline\n"), autodoc);
117  autodoc = cons(docTxt("\\end{tabular}\n"), autodoc);
118  autodoc = cons(docTxt("\\bigskip\n"), autodoc);
119  }
120 
121 
124  string autoPresentationTxt = "\n\\bigskip\n" + gDocAutodocStringMap["thisdoc"] + "\n\n";
125  autodoc = cons(docTxt(autoPresentationTxt.c_str()), autodoc);
126 
127  string autoEquationTxt = "\n" + gDocAutodocStringMap["autoeqntitle"] + "\n\n";
128  autoEquationTxt += gDocAutodocStringMap["autoeqntext"] + "\n";
129  autodoc = cons(docTxt(autoEquationTxt.c_str()), autodoc);
130  autodoc = cons(docEqn(process), autodoc);
131 
132  string autoDiagramTxt = "\n" + gDocAutodocStringMap["autodgmtitle"] + "\n\n";
133  autoDiagramTxt += gDocAutodocStringMap["autodgmtext"] + "\n";
134  autodoc = cons(docTxt(autoDiagramTxt.c_str()), autodoc);
135  autodoc = cons(docDgm(process), autodoc);
136 
137  string autoNoticeTxt = "\n" + gDocAutodocStringMap["autontctitle"] + "\n\n";
138 // autoNoticeTxt += gDocAutodocStringMap["autontctext"] + "\n";
139  autodoc = cons(docTxt(autoNoticeTxt.c_str()), autodoc);
140  autodoc = cons(docNtc(), autodoc);
141 
142  string autoListingTxt;
143  vector<string> pathnames = gReader.listSrcFiles();
144  if(pathnames.size() > 1) {
145  autoListingTxt = "\n" + gDocAutodocStringMap["autolsttitle2"] + "\n\n";
146  autoListingTxt += gDocAutodocStringMap["autolsttext2"] + "\n";
147  } else {
148  autoListingTxt = "\n" + gDocAutodocStringMap["autolsttitle1"] + "\n\n";
149  autoListingTxt += gDocAutodocStringMap["autolsttext1"] + "\n";
150  }
151  autodoc = cons(docTxt(autoListingTxt.c_str()), autodoc);
152  autodoc = cons(docLst(), autodoc);
153 
154  declareDoc(autodoc);
155 }
string gDocName
Contains the filename for out documentation.
Definition: main.cpp:107
Tree docMtd(Tree x)
Definition: doc.cpp:201
Tree cons(Tree a, Tree b)
Definition: list.hh:124
void declareDoc(Tree t)
A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches.
Definition: tree.hh:109
Tree boxIdent(const char *name)
Definition: boxes.cpp:57
Tree docTxt(const char *name)
Definition: doc.cpp:171
map< string, string > gDocAutodocStringMap
Definition: doc_autodoc.cpp:40
Tree docEqn(Tree x)
Definition: doc.cpp:185
vector< string > listSrcFiles()
Return a vector of pathnames representing the list of all the source files that have been required to...
Tree docLst()
Definition: doc.cpp:197
SourceReader gReader
Definition: main.cpp:89
map< string, string > gDocMetadatasStringMap
Tree tree(const Node &n)
Definition: tree.hh:186
Tree docNtc()
Definition: doc.cpp:193
Tree docDgm(Tree x)
Definition: doc.cpp:189
Tree nil
Definition: list.cpp:116
const char * tree2str(Tree t)
if t has a node of type symbol, return its name otherwise error
Definition: tree.cpp:278
map< Tree, set< Tree > > gMetaDataSet
Definition: main.cpp:91

Here is the call graph for this function:

Here is the caller graph for this function:

void initDocAutodoc ( )

Dispatch initialization of autodoc container.

Definition at line 161 of file doc_autodoc.cpp.

References initDocAutodocKeySet().

Referenced by loadTranslationFile().

162 {
164 }
static void initDocAutodocKeySet()
Initialize gDocAutodocKeySet, a set containing all the keywords.

Here is the call graph for this function:

Here is the caller graph for this function:

static void initDocAutodocKeySet ( )
static

Initialize gDocAutodocKeySet, a set containing all the keywords.

Definition at line 176 of file doc_autodoc.cpp.

References gDocAutodocKeySet.

Referenced by initDocAutodoc().

176  {
177 
178  gDocAutodocKeySet.insert("thisdoc");
179 
180  gDocAutodocKeySet.insert("autoeqntitle");
181  gDocAutodocKeySet.insert("autoeqntext");
182 
183  gDocAutodocKeySet.insert("autodgmtitle");
184  gDocAutodocKeySet.insert("autodgmtext");
185 
186  gDocAutodocKeySet.insert("autontctitle");
187  gDocAutodocKeySet.insert("autontctext");
188 
189  gDocAutodocKeySet.insert("autolsttitle1");
190  gDocAutodocKeySet.insert("autolsttext1");
191 
192  gDocAutodocKeySet.insert("autolsttitle2");
193  gDocAutodocKeySet.insert("autolsttext2");
194 }
set< string > gDocAutodocKeySet
Definition: doc_autodoc.cpp:41

Here is the caller graph for this function:

static void printDocAutodocStringMapContent ( )
static

Simple trace function.

Definition at line 200 of file doc_autodoc.cpp.

References gDocAutodocStringMap.

200  {
201  bool trace = false;
202  if(trace) {
203  cout << "gDocAutodocStringMap.size() = " << gDocAutodocStringMap.size() << endl;
204  map<string,string>::iterator it;
205  int i = 1;
206  for(it = gDocAutodocStringMap.begin(); it!=gDocAutodocStringMap.end(); ++it)
207  cout << i++ << ".\tgDocNoticeStringMap[" << it->first << "] \t= '" << it->second << "'" << endl;
208  }
209 }
map< string, string > gDocAutodocStringMap
Definition: doc_autodoc.cpp:40

Variable Documentation

set<string> gDocAutodocKeySet

Definition at line 41 of file doc_autodoc.cpp.

Referenced by initDocAutodocKeySet(), and storePair().

map<string, string> gDocAutodocStringMap
map<string, string> gDocMetadatasStringMap

Definition at line 35 of file doc_metadatas.cpp.

Referenced by declareAutoDoc().

string gDocName

Contains the filename for out documentation.

Definition at line 107 of file main.cpp.

Referenced by declareAutoDoc(), and initFaustDirectories().

map<Tree, set<Tree> > gMetaDataSet

Definition at line 91 of file main.cpp.

Referenced by declareAutoDoc().

SourceReader gReader

Definition at line 89 of file main.cpp.