doc.cpp File Reference

Implementation of documentation trees support and printing. More...

#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <sys/stat.h>
#include <time.h>
#include <algorithm>
#include <functional>
#include <iostream>
#include <fstream>
#include <sstream>
#include <map>
#include <string>
#include <vector>
#include "ppbox.hh"
#include "prim2.hh"
#include "doc.hh"
#include "tlib.hh"
#include "eval.hh"
#include "errormsg.hh"
#include "sigprint.hh"
#include "propagate.hh"
#include "enrobage.hh"
#include "drawschema.hh"
#include "names.hh"
#include "simplify.hh"
#include "privatise.hh"
#include "recursivness.hh"
#include "sourcereader.hh"
#include <list>
#include "sigtyperules.hh"
#include "occurences.hh"
#include "property.hh"
#include "signals.hh"
#include "lateq.hh"
#include "Text.hh"
#include "doc_Text.hh"
#include "description.hh"
#include "compatibility.hh"
Include dependency graph for doc.cpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define MAXIDCHARS   5
 max numbers (characters) to represent ids (e.g. for directories).

Enumerations

enum  { langEN, langFR, langIT }

Functions

static void printlatexheader (istream &latexheader, const string &faustversion, ostream &docout)
 Print a static LaTeX header.
static void printfaustlistings (ostream &docout)
 Print listings of each Faust code ".dsp" files, calling the 'printfaustlisting' function.
static void printfaustlisting (string &faustfile, ostream &docout)
 Print a listing of the Faust code, in a LaTeX "listing" environment.
static void printlatexfooter (ostream &docout)
 Print the static LaTeX footer.
static void printdoccontent (const char *svgTopDir, const vector< Tree > &docVector, const string &faustversion, ostream &docout)
 Main documentator loop.
static void printfaustdocstamp (const string &faustversion, ostream &docout)
 Print a "doc stamp" in the LaTeX document :

  • the Faust version,
  • the date of doc compilation,
  • faust's web site URL.

static void printDocEqn (Lateq *ltq, ostream &docout)
 Print doc equations, following the Lateq::println method.
static void printDocDgm (const Tree expr, const char *svgTopDir, ostream &docout, int i)
 Doc diagrams handling.
static void printDocMetadata (const Tree expr, ostream &docout)
 Print a metadata set.
static void prepareDocEqns (const vector< Tree > &docBoxes, vector< Lateq * > &docCompiledEqnsVector)
 Caller function.
static void collectDocEqns (const vector< Tree > &docBoxes, vector< Tree > &eqBoxes)
 step 0. Feed a vector.
static void mapEvalDocEqn (const vector< Tree > &eqBoxes, const Tree &env, vector< Tree > &evalEqBoxes)
 step 1. Evaluate boxes.
static void mapGetEqName (const vector< Tree > &evalEqBoxes, vector< string > &eqNames)
 step 2. Get boxes name.
static void calcEqnsNicknames (const vector< string > &eqNames, vector< string > &eqNicknames)
 step 3. Calculate nicknames.
static void mapPrepareEqSig (const vector< Tree > &evalEqBoxes, vector< int > &eqInputs, vector< int > &eqOutputs, vector< Tree > &eqSigs)
 step 4&5. Propagate and prepare signals.
static void mapSetSigNickname (const vector< string > &eqNicknames, const vector< int > &eqInputs, const vector< Tree > &eqSigs)
 step 6. Set signals nicknames.
static void collectEqSigs (const vector< Tree > &eqSigs, Tree &superEqList)
 step 7. Collect all signals in a superlist.
static void annotateSuperList (DocCompiler *DC, Tree superEqList)
 step 8. Annotate superlist.
static void mapCompileDocEqnSigs (const vector< Tree > &eqSigs, const vector< int > &eqInputs, const vector< int > &eqOutputs, DocCompiler *DC, vector< Lateq * > &docCompiledEqnsVector)
 step 10. Compile equations.
static string calcNumberedName (const char *base, int i)
 Simply concat a string with a number in a "%03d" format.
static void getBoxInputsAndOutputs (const Tree t, int &numInputs, int &numOutputs)
 Just get the number of inputs and the number of outputs of a box.
static string calcDocEqnInitial (const string s)
 Calculate an appropriate nickname for equations, from previous names.
static void initCompilationDate ()
static struct tm * getCompilationDate ()
static int cholddir ()
 Switch back to the previously stored current directory.
static int mkchdir (const char *dirname)
 Create a new directory in the current one, then 'cd' into this new directory.
static int makedir (const char *dirname)
 Create a new directory in the current one.
static void getCurrentDir ()
 Get current directory and store it in gCurrentDir.
static istream * openArchFile (const string &filename)
 Open architecture file.
static char * legalFileName (const Tree t, int n, char *dst)
 Transform the definition name property of tree <t> into a legal file name.
static string rmExternalDoubleQuotes (const string &s)
 Remove the leading and trailing double quotes of a string (but not those in the middle of the string).
static void copyFaustSources (const char *projname, const vector< string > &pathnames)
 Copy all Faust source files into an 'src' subdirectory.
vector< string > & docCodeSlicer (const string &faustfile, vector< string > &codeSlices)
 Slice faust code between "mdoc" sections.
static void printdocCodeSlices (const string &code, ostream &docout)
 Print faust code inside a listing environment.
static bool doesFileBeginWithCode (const string &faustfile)
 Test whether a file does begin with some faust code or not.
Tree docTxt (const char *name)
bool isDocTxt (Tree t)
bool isDocTxt (Tree t0, const char **str)
Tree docEqn (Tree x)
bool isDocEqn (Tree t, Tree &x)
Tree docDgm (Tree x)
bool isDocDgm (Tree t, Tree &x)
Tree docNtc ()
bool isDocNtc (Tree t)
Tree docLst ()
bool isDocLst (Tree t)
Tree docMtd (Tree x)
bool isDocMtd (Tree t, Tree &x)
void printDoc (const char *projname, const char *docdev, const char *faustversion)
 The entry point to generate faust doc files.

Variables

Tree gExpandedDefList
map< Tree, set< Tree > > gMetaDataSet
map< string, string > gDocMetadatasStringMap
map< string, string > gDocMathStringMap
bool gDetailsSwitch
bool gStripDocSwitch
string gFaustDirectory
string gFaustSuperDirectory
string gFaustSuperSuperDirectory
string gMasterDocument
string gMasterName
SourceReader gReader
string gDocName
 Contains the filename for out documentation.
static const char * gDocDevSuffix
 ".tex" (or .??? - used to choose output device).
static string gCurrentDir
 Room to save current directory name.
static const string gLatexheaderfilename = "latexheader.tex"
vector< TreegDocVector
 Contains <mdoc> parsed trees: DOCTXT, DOCEQN, DOCDGM.
static struct tm gCompilationDate
bool gLstDependenciesSwitch = true
 mdoc listing management.
bool gLstMdocTagsSwitch = true
 mdoc listing management.
bool gLstDistributedSwitch = true
 mdoc listing management.
string gDocLang
Sym DOCTXT = symbol ("DocTxt")
Sym DOCEQN = symbol ("DocEqn")
Sym DOCDGM = symbol ("DocDgm")
Sym DOCNTC = symbol ("DocNtc")
Sym DOCLST = symbol ("DocLst")
Sym DOCMTD = symbol ("DocMtd")

Detailed Description

Implementation of documentation trees support and printing.

Author:
Karim Barkati and Yann Orlarey
Version:
1.0
Date:
2009

Definition in file doc.cpp.


Define Documentation

#define MAXIDCHARS   5

max numbers (characters) to represent ids (e.g. for directories).

Definition at line 83 of file doc.cpp.

Referenced by calcNumberedName(), and printDocDgm().


Enumeration Type Documentation

anonymous enum
Enumerator:
langEN 
langFR 
langIT 

Definition at line 118 of file doc.cpp.

00118 { langEN, langFR, langIT };


Function Documentation

static void annotateSuperList ( DocCompiler DC,
Tree  superEqList 
) [static]

step 8. Annotate superlist.

#8.

Annotate superEqList (to find candidate signals to be named later).

Parameters:
[in] DC The signals compiler.
[out] superEqList The super equations signal tree to annotate.

Definition at line 737 of file doc.cpp.

References DocCompiler::annotate().

Referenced by prepareDocEqns().

00738 {
00739     DC->annotate(superEqList);
00740 }

Here is the call graph for this function:

Here is the caller graph for this function:

static string calcDocEqnInitial ( const string  s  )  [static]

Calculate an appropriate nickname for equations, from previous names.

Parameters:
The string to parse.
Returns:
Essentially returns the initial character, except "Y" for "process", and "Z" for unnamed equations.

Definition at line 788 of file doc.cpp.

Referenced by calcEqnsNicknames().

00789 {
00790     string nn;
00791     if(s == "process")
00792         nn = "Y";
00793     else if (s.substr(0,6) == "doceqn")
00794         nn = "Z";
00795     else
00796         nn += toupper(s[0]);
00797     return nn;
00798 }

Here is the caller graph for this function:

static void calcEqnsNicknames ( const vector< string > &  eqNames,
vector< string > &  eqNicknames 
) [static]

step 3. Calculate nicknames.

#3.

Calculate a nickname for each equation and store it.

Parameters:
[in] eqNames Equations names to parse.
[out] eqNicknames The place to store calculated nicknames.
Todo:
Should check unicity : check whether several names share the same initial, or else capture consonants for example.

Check duplicates

Definition at line 623 of file doc.cpp.

References calcDocEqnInitial().

Referenced by prepareDocEqns().

00624 {
00625     //cerr << "###\n# Documentator : calcEqnsNicknames" << endl;
00626     
00627     vector<string> v;
00628     
00629     for( vector<string>::const_iterator eq = eqNames.begin(); eq < eqNames.end(); eq++ ) {
00630         string init = calcDocEqnInitial(*eq);
00631         v.push_back(init);
00633 //      for( vector<string>::iterator it = v.begin(); it < v.end()-1; ++it ) {
00634 //          if (init == *it) {
00635 //              //cerr << "!! Warning Documentator : calcEqnsNicknames : duplicates \"" << init << "\"" << endl;
00636 //          }
00637 //      }
00638         eqNicknames.push_back(init);
00639     }
00640     
00641 //  for( vector<string>::const_iterator eq = eqNames.begin(); eq < eqNames.end(); eq++ ) {
00642 //      int c = 0;
00643 //      c = count_if(eqNames.begin(), eqNames.end(), bind2nd(equal_to<string>(), *eq));
00644 //      if (c > 0) { 
00645 //          cerr << "- Duplicate nickname !! " << *eq << endl; 
00646 //      } else {
00647 //          cerr << "(no duplicate) " << *eq << endl;
00648 //      }
00649 //  }
00650     
00651     //cerr << "Documentator : end of calcEqnsNicknames\n---" << endl;
00652 }

Here is the call graph for this function:

Here is the caller graph for this function:

static string calcNumberedName ( const char *  base,
int  i 
) [static]

Simply concat a string with a number in a "%03d" format.

The number has MAXIDCHARS characters.

Definition at line 1094 of file doc.cpp.

References MAXIDCHARS, and subst().

Referenced by mapGetEqName().

01095 {
01096     char nb[MAXIDCHARS+1];
01097     sprintf(nb, "%03d", i);
01098     return subst("$0$1", base, nb);
01099 }

Here is the call graph for this function:

Here is the caller graph for this function:

static int cholddir (  )  [static]

Switch back to the previously stored current directory.

Definition at line 1026 of file doc.cpp.

References gCurrentDir.

Referenced by openArchFile(), and printDoc().

01027 {
01028     if (chdir(gCurrentDir.c_str()) == 0) {
01029         return 0;
01030     } else {
01031         perror("cholddir");
01032         exit(errno);
01033     }
01034 }

Here is the caller graph for this function:

static void collectDocEqns ( const vector< Tree > &  docBoxes,
vector< Tree > &  eqBoxes 
) [static]

step 0. Feed a vector.

#0.

Collect every <equation> found in all <mdoc> faust comments.

Parameters:
[in] docBoxes The <mdoc> boxes to filter.
[out] eqBoxes The place to store only <equation> boxes.

Definition at line 549 of file doc.cpp.

References doc, hd(), isDocEqn(), isList(), reverse(), and tl().

Referenced by prepareDocEqns().

00550 {
00551     int nbdoceqn = 0;
00552     
00553     for (vector<Tree>::const_iterator doc=docBoxes.begin(); doc<docBoxes.end(); doc++) {
00554         Tree L = reverse(*doc);
00555         Tree expr;
00556         while (isList(L)) {
00557             if ( isDocEqn(hd(L), expr) ) {
00558                 eqBoxes.push_back(expr);
00559                 nbdoceqn++;
00560             }
00561             L = tl(L);
00562         }
00563     }
00564     //cerr << "Documentator : collectDocEqns : " << nbdoceqn << " <equation> tags found." << endl;
00565 }

Here is the call graph for this function:

Here is the caller graph for this function:

static void collectEqSigs ( const vector< Tree > &  eqSigs,
Tree superEqList 
) [static]

step 7. Collect all signals in a superlist.

#7.

Collect each prepared list of signals to construct a super list.

Parameters:
[in] eqSigs Contains well-prepared and nicknamed signals.
[out] superEqList The root where to 'cons' signals all together.

Definition at line 716 of file doc.cpp.

References cons(), and nil.

Referenced by prepareDocEqns().

00717 {
00718     //cerr << "###\n# Documentator : collectEqSigs" << endl;
00719     
00720     superEqList = nil;
00721     
00722     for( vector<Tree>::const_iterator it = eqSigs.begin(); it < eqSigs.end(); ++it ) {
00723         superEqList = cons( *it, superEqList );
00724     }
00725     //printSignal(superEqList, stdout, 0);
00726     
00727     //cerr << endl << "Documentator : end of collectEqSigs\n---" << endl;
00728 }

Here is the call graph for this function:

Here is the caller graph for this function:

static void copyFaustSources ( const char *  projname,
const vector< string > &  pathnames 
) [static]

Copy all Faust source files into an 'src' subdirectory.

Parameters:
[in] projname Basename of the new doc directory ("*-math").
[in] pathnames The paths list of the source files to copy.

Definition at line 1124 of file doc.cpp.

References filebasename(), makedir(), and subst().

Referenced by printDoc().

01125 {
01126     string srcdir = subst("$0/src", projname);
01127     //cerr << "Documentator : copyFaustSources : Creating directory '" << srcdir << "'" << endl;
01128     makedir(srcdir.c_str());    // create a directory.
01129         
01130     for (unsigned int i=0; i< pathnames.size(); i++) {
01131         ifstream src;
01132         ofstream dst;
01133         string faustfile = pathnames[i];
01134         string copy = subst("$0/$1", srcdir, filebasename(faustfile.c_str()));
01135         //cerr << "Documentator : copyFaustSources : Opening input file  '" << faustfile << "'" << endl;
01136         //cerr << "Documentator : copyFaustSources : Opening output file '" << copy << "'" << endl;
01137         src.open(faustfile.c_str(), ifstream::in);
01138         dst.open(copy.c_str(), ofstream::out);
01139         string  s;
01140         while ( getline(src,s) ) dst << s << endl;
01141     }
01142 }

Here is the call graph for this function:

Here is the caller graph for this function:

vector< string > & docCodeSlicer ( const string &  faustfile,
vector< string > &  codeSlices 
)

Slice faust code between "mdoc" sections.

Parameters:
[in] faustfile Name of the input faust file to parse.
[in] codeSlices The place to store code "slices".

Caution: we suppose there's only one <mdoc> tag per line!

A change has come. ;)

Definition at line 896 of file doc.cpp.

Referenced by printdoccontent().

00897 {
00898     string  s;
00899     ifstream src;
00900     src.open(faustfile.c_str(), ifstream::in);
00901     string tmp = "";
00902     
00903     bool isInsideDoc = false;
00904     
00905     if (faustfile != "" && src.good()) {
00906         while(getline(src, s)) { 
00907             size_t foundopendoc  = s.find("<mdoc>");
00908             
00909             if (foundopendoc != string::npos) { 
00910                 if (isInsideDoc == false) { 
00911                     if (! tmp.empty() ) {
00912                         codeSlices.push_back(tmp); }
00913                     tmp = "";
00914                 }
00915                 isInsideDoc = true;  
00916             }
00917             
00918             if (isInsideDoc == false) {
00919                 tmp += s + '\n';
00920             }
00921             
00922             size_t foundclosedoc = s.find("</mdoc>");
00923             if (foundclosedoc != string::npos) isInsideDoc = false;
00924         }
00925     } else {
00926         cerr << "ERROR : can't open faust source file " << faustfile << endl;
00927         exit(1);
00928     }
00929     return codeSlices;
00930 }

Here is the caller graph for this function:

Tree docDgm ( Tree  x  ) 

Definition at line 194 of file doc.cpp.

References tree().

Referenced by declareAutoDoc(), and yyparse().

00194 { return tree(DOCDGM, x);       }

Here is the call graph for this function:

Here is the caller graph for this function:

Tree docEqn ( Tree  x  ) 

Definition at line 190 of file doc.cpp.

References tree().

Referenced by declareAutoDoc(), and yyparse().

00190 { return tree(DOCEQN, x);       }

Here is the call graph for this function:

Here is the caller graph for this function:

Tree docLst (  ) 

Definition at line 202 of file doc.cpp.

References tree().

Referenced by declareAutoDoc(), and yyparse().

00202 { return tree(DOCLST);          }

Here is the call graph for this function:

Here is the caller graph for this function:

Tree docMtd ( Tree  x  ) 

Definition at line 206 of file doc.cpp.

References tree().

Referenced by declareAutoDoc(), and yyparse().

00206 { return tree(DOCMTD, x);       }

Here is the call graph for this function:

Here is the caller graph for this function:

Tree docNtc (  ) 

Definition at line 198 of file doc.cpp.

References tree().

Referenced by declareAutoDoc(), and yyparse().

00198 { return tree(DOCNTC);          }

Here is the call graph for this function:

Here is the caller graph for this function:

Tree docTxt ( const char *  name  ) 

Definition at line 176 of file doc.cpp.

References symbol(), and tree().

Referenced by declareAutoDoc(), and yyparse().

00176 { return tree( DOCTXT, tree(symbol(name)) ); }

Here is the call graph for this function:

Here is the caller graph for this function:

static bool doesFileBeginWithCode ( const string &  faustfile  )  [static]

Test whether a file does begin with some faust code or not.

Parameters:
[in] faustfile Name of the input faust file to parse.

Definition at line 954 of file doc.cpp.

Referenced by printdoccontent().

00955 {
00956     string  s;
00957     ifstream src;
00958     src.open(faustfile.c_str(), ifstream::in);
00959     
00960     if (faustfile != "" && src.good()) {
00961         getline(src, s);
00962         size_t foundopendoc = s.find("<mdoc>");
00963         if(int(foundopendoc)==0) {
00964             return false;
00965         } else {
00966             return true;
00967         }
00968     } else {
00969         cerr << "ERROR : can't open faust source file " << faustfile << endl;
00970         exit(1);
00971     }
00972 }   

Here is the caller graph for this function:

static void getBoxInputsAndOutputs ( const Tree  t,
int &  numInputs,
int &  numOutputs 
) [static]

Just get the number of inputs and the number of outputs of a box.

Parameters:
[in] t The box tree to get inputs and outputs from.
[out] numInputs The place to store the number of inputs.
[out] numOutputs The place to store the number of outputs.

Definition at line 808 of file doc.cpp.

References getBoxType().

Referenced by mapPrepareEqSig().

00809 {
00810     if (!getBoxType(t, &numInputs, &numOutputs)) {
00811         cerr << "ERROR during the evaluation of t : " << boxpp(t) << endl;
00812         exit(1);
00813     }
00814     //cerr << "Documentator : " << numInputs <<" inputs and " << numOutputs <<" outputs for box : " << boxpp(t) << endl;
00815 }

Here is the call graph for this function:

Here is the caller graph for this function:

static struct tm * getCompilationDate (  )  [static, read]

Definition at line 1156 of file doc.cpp.

References gCompilationDate, and initCompilationDate().

Referenced by printfaustdocstamp(), and printlatexheader().

01157 {
01158     initCompilationDate();
01159     return &gCompilationDate;
01160 }

Here is the call graph for this function:

Here is the caller graph for this function:

static void getCurrentDir (  )  [static]

Get current directory and store it in gCurrentDir.

Definition at line 1040 of file doc.cpp.

References FAUST_PATH_MAX, and gCurrentDir.

Referenced by openArchFile().

01041 {
01042     char    buffer[FAUST_PATH_MAX];
01043     gCurrentDir = getcwd (buffer, FAUST_PATH_MAX);
01044 }

Here is the caller graph for this function:

static void initCompilationDate (  )  [static]

Definition at line 1148 of file doc.cpp.

References gCompilationDate.

Referenced by getCompilationDate().

01149 {
01150     time_t now;
01151     
01152     time(&now);
01153     gCompilationDate = *localtime(&now);
01154 }

Here is the caller graph for this function:

bool isDocDgm ( Tree  t,
Tree x 
)

Definition at line 195 of file doc.cpp.

References isTree().

Referenced by printdoccontent().

00195 { return isTree(t, DOCDGM, x);  }

Here is the call graph for this function:

Here is the caller graph for this function:

bool isDocEqn ( Tree  t,
Tree x 
)

Definition at line 191 of file doc.cpp.

References isTree().

Referenced by collectDocEqns(), and printdoccontent().

00191 { return isTree(t, DOCEQN, x);  }

Here is the call graph for this function:

Here is the caller graph for this function:

bool isDocLst ( Tree  t  ) 

Definition at line 203 of file doc.cpp.

References isTree().

Referenced by printdoccontent().

00203 { return isTree(t, DOCLST);     }

Here is the call graph for this function:

Here is the caller graph for this function:

bool isDocMtd ( Tree  t,
Tree x 
)

Definition at line 207 of file doc.cpp.

References isTree().

Referenced by printdoccontent().

00207 { return isTree(t, DOCMTD, x);  }

Here is the call graph for this function:

Here is the caller graph for this function:

bool isDocNtc ( Tree  t  ) 

Definition at line 199 of file doc.cpp.

References isTree().

Referenced by printdoccontent().

00199 { return isTree(t, DOCNTC);     }

Here is the call graph for this function:

Here is the caller graph for this function:

bool isDocTxt ( Tree  t0,
const char **  str 
)

Definition at line 178 of file doc.cpp.

References isSym(), isTree(), name(), and CTree::node().

00179 {
00180     Tree t1; Sym s;
00181     if ( isTree(t0, DOCTXT, t1) && isSym(t1->node(), &s) ) {
00182         *str = name(s);
00183         return true;
00184     } else {
00185         return false;
00186     }
00187 }

Here is the call graph for this function:

bool isDocTxt ( Tree  t  ) 

Definition at line 177 of file doc.cpp.

References CTree::node().

Referenced by printdoccontent().

00177 { return t->node() == Node(DOCTXT); }

Here is the call graph for this function:

Here is the caller graph for this function:

static char * legalFileName ( const Tree  t,
int  n,
char *  dst 
) [static]

Transform the definition name property of tree <t> into a legal file name.

The resulting file name is stored in <dst> a table of at least <n> chars. Returns the <dst> pointer for convenience.

Definition at line 1072 of file doc.cpp.

References getDefNameProperty(), and tree2str().

Referenced by printDocDgm().

01073 {
01074     Tree    id;
01075     int     i=0;
01076     if (getDefNameProperty(t, id)) {
01077         const char*     src = tree2str(id);
01078         for (i=0; isalnum(src[i]) && i<16; i++) {
01079             dst[i] = src[i];
01080         }
01081     }
01082     dst[i] = 0;
01083     if (strcmp(dst, "process") != 0) { 
01084         // if it is not process add the hex address to make the name unique
01085         snprintf(&dst[i], n-i, "-%p", t);
01086     }
01087     return dst;
01088 }

Here is the call graph for this function:

Here is the caller graph for this function:

static int makedir ( const char *  dirname  )  [static]

Create a new directory in the current one.

Definition at line 982 of file doc.cpp.

References FAUST_PATH_MAX, and gCurrentDir.

Referenced by copyFaustSources(), and printDoc().

00983 {
00984     char    buffer[FAUST_PATH_MAX];
00985     gCurrentDir = getcwd (buffer, FAUST_PATH_MAX);
00986     
00987     if ( gCurrentDir.c_str() != 0) {
00988         int status = mkdir(dirname, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
00989         if (status == 0 || errno == EEXIST) {
00990             return 0;
00991         }
00992     }
00993     perror("makedir");
00994     exit(errno);
00995 }

Here is the caller graph for this function:

static void mapCompileDocEqnSigs ( const vector< Tree > &  eqSigs,
const vector< int > &  eqInputs,
const vector< int > &  eqOutputs,
DocCompiler DC,
vector< Lateq * > &  docCompiledEqnsVector 
) [static]

step 10. Compile equations.

#9.

Calculated and set lateq (LaTeX equation) names. Note : Transfered into mapCompileDocEqnSigs (DocCompiler::compileMultiSignal). #10. Name and compile prepared doc <equation> signals.

Parameters:
[in] eqSigs Contains well-prepared and nicknamed signals.
[in] DC The signals compiler.
[out] docCompiledEqnsVector The place to store each compiled Lateq* object.

Definition at line 760 of file doc.cpp.

References DocCompiler::compileLateq().

Referenced by prepareDocEqns().

00761 {
00762     //cerr << "###\n# Documentator : mapCompileDocEqnSigs" << endl;
00763     
00764     for( unsigned int i=0; i < eqSigs.size(); i++ ) {
00765         
00766         //      docCompiledEqnsVector.push_back( DC->compileMultiSignal(*it, 0) );
00767         docCompiledEqnsVector.push_back( DC->compileLateq(eqSigs[i], new Lateq(eqInputs[i], eqOutputs[i])) );
00768     }
00769     
00770     //cerr << "Documentator : end of mapCompileDocEqnSigs\n---" << endl;
00771 }

Here is the call graph for this function:

Here is the caller graph for this function:

static void mapEvalDocEqn ( const vector< Tree > &  eqBoxes,
const Tree env,
vector< Tree > &  evalEqBoxes 
) [static]

step 1. Evaluate boxes.

#1.

Evaluate every doc <equation> (evaluation replaces abstractions by symbolic boxes).

Parameters:
[in] eqBoxes The boxes to evaluate.
[in] env The environment for the evaluation.
[out] evalEqBoxes The place to store evaluated equations boxes.

Definition at line 575 of file doc.cpp.

References evaldocexpr().

Referenced by prepareDocEqns().

00576 {
00577     //cerr << "###\n# Documentator : mapEvalDocEqn" << endl;
00578     
00579     for ( vector<Tree>::const_iterator eq=eqBoxes.begin(); eq < eqBoxes.end(); eq++)
00580     {
00581         evalEqBoxes.push_back(evaldocexpr( *eq, env ));
00582     }
00583     //cerr << "Documentator : end of mapEvalDocEqn\n---" << endl;
00584 }

Here is the call graph for this function:

Here is the caller graph for this function:

static void mapGetEqName ( const vector< Tree > &  evalEqBoxes,
vector< string > &  eqNames 
) [static]

step 2. Get boxes name.

#2.

Get name if exists, else create one, and store it.

Parameters:
[in] evalEqBoxes Evaluated box trees, eventually containing an equation name.
[out] eqNames The place to store equations names.

Definition at line 593 of file doc.cpp.

References calcNumberedName(), getBoxType(), getDefNameProperty(), and tree2str().

Referenced by prepareDocEqns().

00594 {
00595     //cerr << "###\n# Documentator : mapGetEqName" << endl;
00596     
00597     int i = 1;
00598     for( vector<Tree>::const_iterator eq = evalEqBoxes.begin(); eq < evalEqBoxes.end(); eq++, i++ ) {
00599         Tree id;
00600         string s;
00601         int n,m; getBoxType(*eq, &n, &m); // eq name only for bd without inputs
00602         if ( n==0 && getDefNameProperty(*eq, id) ) {
00603             s = tree2str(id);
00604         }
00605         else {
00606             s = calcNumberedName("doceqn-", i);
00607         }       
00608         eqNames.push_back( s ) ;
00609     }
00610     //cerr << "Documentator : end of mapGetEqName\n---" << endl;
00611 }

Here is the call graph for this function:

Here is the caller graph for this function:

static void mapPrepareEqSig ( const vector< Tree > &  evalEqBoxes,
vector< int > &  eqInputs,
vector< int > &  eqOutputs,
vector< Tree > &  eqSigs 
) [static]

step 4&5. Propagate and prepare signals.

#4&5.

Propagate and prepare every doc <equation>.

Call boxPropagateSig, deBruijn2Sym, simplify, and privatise.

Parameters:
[in] evalEqBoxes Equations boxes to propagate as signals.
[out] eqSigs The place to store prepared signals.

< Convert debruijn recursion into symbolic recursion

< Simplify by executing every computable operation

< convert regular tables into special doctables (regular tables are difficult to translate to equations)

Definition at line 663 of file doc.cpp.

References boxPropagateSig(), deBruijn2Sym(), docTableConvertion(), getBoxInputsAndOutputs(), makeSigInputList(), nil, and simplify().

Referenced by prepareDocEqns().

00664 {
00665     //cerr << "###\n# Documentator : mapPrepareEqSig" << endl;
00666     
00667     for( vector<Tree>::const_iterator eq = evalEqBoxes.begin(); eq < evalEqBoxes.end(); eq++ ) {
00668         
00669         int numInputs, numOutputs;
00670         getBoxInputsAndOutputs(*eq, numInputs, numOutputs);
00671         //cerr << numInputs <<" ins and " << numOutputs <<" outs" << endl;
00672         eqInputs.push_back(numInputs);
00673         eqOutputs.push_back(numOutputs);
00674         
00675         Tree lsig1 = boxPropagateSig( nil, *eq , makeSigInputList(numInputs) );
00676         //cerr << "output signals are : " << endl;  printSignal(lsig1, stderr);
00677         
00678         Tree lsig2 = deBruijn2Sym(lsig1);   
00679         Tree lsig3 = simplify(lsig2);       
00680         //Tree lsig4 = privatise(lsig3);        ///< Un-share tables with multiple writers
00681         Tree lsig4 = docTableConvertion(lsig3);     
00682 
00683 
00684         eqSigs.push_back(lsig4);
00685     }
00686     //cerr << "Documentator : end of mapPrepareEqSig\n---" << endl;
00687 }

Here is the call graph for this function:

Here is the caller graph for this function:

static void mapSetSigNickname ( const vector< string > &  eqNicknames,
const vector< int > &  eqInputs,
const vector< Tree > &  eqSigs 
) [static]

step 6. Set signals nicknames.

#6.

Set signals nicknames.

Do nothing for the moment !

Parameters:
[in] eqNicknames Contains previously calculated nicknames.
[out] eqSigs The signals to tag with a NICKNAMEPROPERTY.

Definition at line 697 of file doc.cpp.

Referenced by prepareDocEqns().

00698 {
00699     //cerr << "###\n# Documentator : mapSetSigNickname" << endl;
00700 
00701 //  Do nothing for the moment...
00702 //  for( unsigned int i=0; i < eqSigs.size(); i++ ) {
00703 //      if (eqInputs[i] == 0) // Only "generators" should be finally named with user equation (nick)name.
00704 //          setSigListNickName(eqSigs[i], eqNicknames[i]);
00705 //  }
00706     //cerr << "Documentator : end of mapSetSigNickname\n---" << endl;
00707 }

Here is the caller graph for this function:

static int mkchdir ( const char *  dirname  )  [static]

Create a new directory in the current one, then 'cd' into this new directory.

Remarks:
The current directory is saved to be later restaured.

Definition at line 1005 of file doc.cpp.

References FAUST_PATH_MAX, and gCurrentDir.

Referenced by printDoc().

01006 {
01007     char    buffer[FAUST_PATH_MAX];
01008     gCurrentDir = getcwd (buffer, FAUST_PATH_MAX);
01009 
01010     if ( gCurrentDir.c_str() != 0) {
01011         int status = mkdir(dirname, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
01012         if (status == 0 || errno == EEXIST) {
01013             if (chdir(dirname) == 0) {
01014                 return 0;
01015             }
01016         }
01017     }
01018     perror("mkchdir");
01019     exit(errno);
01020 }

Here is the caller graph for this function:

static istream * openArchFile ( const string &  filename  )  [static]

Open architecture file.

Definition at line 1050 of file doc.cpp.

References cholddir(), getCurrentDir(), and open_arch_stream().

Referenced by printDoc().

01051 {
01052     istream* file;
01053     getCurrentDir();    // Save the current directory.
01054     //cerr << "Documentator : openArchFile : Opening input file  '" << filename << "'" << endl;
01055     if ( (file = open_arch_stream(filename.c_str())) ) {
01056         //cerr << "Documentator : openArchFile : Opening '" << filename << "'" << endl;
01057     } else {
01058         cerr << "ERROR : can't open architecture file " << filename << endl;
01059         exit(1);
01060     }
01061     cholddir();         // Return to current directory.
01062     return file;
01063 }

Here is the call graph for this function:

Here is the caller graph for this function:

static void prepareDocEqns ( const vector< Tree > &  docBoxes,
vector< Lateq * > &  docCompiledEqnsVector 
) [static]

Caller function.

Caller function for all steps of doc equations preparation.

Note : many of the functions called put their result into their last argument in a "source / destination" manner, the "destination" being declared before the function call.

Parameters:
[in] docBoxes The <mdoc> boxes to collect and prepare.
[out] docCompiledEqnsVector The place to store compiled equations.

< step 0. Feed a vector.

< step 1. Evaluate boxes.

< step 2. Get boxes name.

< step 3. Calculate nicknames.

< step 4&5. Propagate and prepare signals.

< step 6. Set signals nicknames.

< step 7. Collect all signals in a superlist.

< step 8. Annotate superEqList.

< step 10. Compile every signal.

Definition at line 520 of file doc.cpp.

References annotateSuperList(), calcEqnsNicknames(), collectDocEqns(), collectEqSigs(), mapCompileDocEqnSigs(), mapEvalDocEqn(), mapGetEqName(), mapPrepareEqSig(), and mapSetSigNickname().

Referenced by printdoccontent().

00521 {   
00522     vector<Tree>    eqBoxes;        collectDocEqns( docBoxes, eqBoxes );        
00523     
00524     if(! eqBoxes.empty() ) {
00525         vector<Tree>    evalEqBoxes;    mapEvalDocEqn( eqBoxes, gExpandedDefList, evalEqBoxes );    
00526         vector<string>  eqNames;        mapGetEqName( evalEqBoxes, eqNames );       
00527         vector<string>  eqNicknames;    calcEqnsNicknames( eqNames, eqNicknames );  
00528         
00529         vector<int>     eqInputs;
00530         vector<int>     eqOutputs;
00531         vector<Tree>    eqSigs;         mapPrepareEqSig( evalEqBoxes, eqInputs, eqOutputs, eqSigs );    
00532         mapSetSigNickname( eqNicknames, eqInputs, eqSigs );                                 
00533         Tree            superEqList;    collectEqSigs( eqSigs, superEqList );       
00534         
00535         DocCompiler* DC = new DocCompiler(0, 0);
00536         annotateSuperList( DC, superEqList );                                       
00537         //calcAndSetLtqNames( superEqList );                                        ///< step 9. (directly in 10.)
00538         mapCompileDocEqnSigs( eqSigs, eqInputs, eqOutputs, DC, docCompiledEqnsVector );     
00539     }
00540 }

Here is the call graph for this function:

Here is the caller graph for this function:

void printDoc ( const char *  projname,
const char *  docdev,
const char *  faustversion 
)

The entry point to generate faust doc files.

The entry point to generate the output LaTeX file, stored in the directory "<projname>-math/". This file eventually references images for diagrams, generated in SVG subdirectories. The device system was adapted from drawSchema's device system.

Parameters:
[in] projname Basename of the new doc directory ("*-math").
[in] docdev The doc device; only ".tex" is supported for the moment.
[in] faustversion The current version of this Faust compiler.

File stuff : create doc directories and a tex file.

Create THE mathdoc tex file.

Init and load translation file.

Simulate a default doc if no <mdoc> tag detected.

Printing stuff : in the '.tex' ouptut file, eventually including SVG files.

< Faust version and compilation date (comment).

< Static LaTeX header (packages and setup).

< Generate math contents (main stuff!).

< Static LaTeX footer.

Definition at line 229 of file doc.cpp.

References cholddir(), copyFaustSources(), declareAutoDoc(), gDocDevSuffix, gDocLang, gDocName, gDocVector, gLatexheaderfilename, SourceReader::listSrcFiles(), loadTranslationFile(), makedir(), mkchdir(), openArchFile(), printdoccontent(), printfaustdocstamp(), printlatexfooter(), printlatexheader(), and subst().

Referenced by main().

00230 {
00231     gDocDevSuffix = docdev;
00232     
00234     //cerr << "Documentator : printDoc : gFaustDirectory = '" << gFaustDirectory << "'" << endl;
00235     //cerr << "Documentator : printDoc : gFaustSuperDirectory = '" << gFaustSuperDirectory << "'" << endl;
00236     //cerr << "Documentator : printDoc : gFaustSuperSuperDirectory = '" << gFaustSuperSuperDirectory << "'" << endl;
00237     //cerr << "Documentator : printDoc : gCurrentDir = '" << gCurrentDir << "'" << endl;
00238     
00239     makedir(projname);          // create a top directory to store files
00240     
00241     string svgTopDir = subst("$0/svg", projname);
00242     makedir(svgTopDir.c_str()); // create a directory to store svg-* subdirectories.
00243     
00244     string cppdir = subst("$0/cpp", projname);
00245     makedir(cppdir.c_str());    // create a cpp directory.
00246     
00247     string pdfdir = subst("$0/pdf", projname);
00248     makedir(pdfdir.c_str());    // create a pdf directory.
00249     
00250     /* Copy all Faust source files into an 'src' sub-directory. */
00251     vector<string> pathnames = gReader.listSrcFiles();
00252     copyFaustSources(projname, pathnames);
00253     
00254     string texdir = subst("$0/tex", projname);
00255     mkchdir(texdir.c_str());    // create a directory and move into.
00256 
00258     ofstream docout(subst("$0.$1", gDocName, docdev).c_str());
00259     cholddir();                 // return to current directory
00260     
00262     loadTranslationFile(gDocLang);
00263     
00265     if (gDocVector.empty()) { declareAutoDoc(); }   
00266     
00268     printfaustdocstamp(faustversion, docout);                       
00269     istream* latexheader = openArchFile(gLatexheaderfilename);
00270     printlatexheader(*latexheader, faustversion, docout);                       
00271     printdoccontent(svgTopDir.c_str(), gDocVector, faustversion, docout);       
00272     printlatexfooter(docout);                                       
00273 }

Here is the call graph for this function:

Here is the caller graph for this function:

static void printdocCodeSlices ( const string &  code,
ostream &  docout 
) [static]

Print faust code inside a listing environment.

Parameters:
[in] code Faust code as a string (may contain '
' characters).
[out] docout The output file to print into.

Definition at line 939 of file doc.cpp.

Referenced by printdoccontent().

00940 {
00941     if ( ! code.empty() ) {
00942         docout << endl << "\\begin{lstlisting}[numbers=none, frame=none, basicstyle=\\small\\ttfamily, backgroundcolor=\\color{yobg}]" << endl;
00943         docout << code << endl;
00944         docout << "\\end{lstlisting}" << endl << endl;
00945     }
00946 }

Here is the caller graph for this function:

static void printdoccontent ( const char *  svgTopDir,
const vector< Tree > &  docVector,
const string &  faustversion,
ostream &  docout 
) [static]

Main documentator loop.

First loop on gDocVector, which contains the faust <mdoc> trees. Second loop for each of these <mdoc> trees, which contain parsed input expressions of 3 types : DOCEQN for <equation> tags, DOCDGM for <diagram> tags, and DOCTXT for direct LaTeX text (no tag).

  • DOCTXT expressions printing is trivial.
  • DOCDGM expressions printing calls 'printDocDgm' to generate SVG files and print LaTeX "figure" code.
  • DOCEQN expressions printing calls 'printDocEqn' after an important preparing work has been done by 'prepareDocEqns'.
Parameters:
[in] projname Basename of the new doc directory ("*-math").
[in] docVector Contains all <mdoc> parsed content (as boxes).
[in] faustversion The current version of this Faust compiler.
[out] docout The output file to print into.

Equations need to be prepared (named and compiled) before printing.

< Quite a lot of stuff there.

< For diagram directories numbering.

First level printing loop, on docVector.

Second level printing loop, on each <mdoc>.

< After equations are well prepared and named.

Definition at line 441 of file doc.cpp.

References CTree::branch(), doc, docCodeSlicer(), doesFileBeginWithCode(), gLstDistributedSwitch, gMasterDocument, hd(), isDocDgm(), isDocEqn(), isDocLst(), isDocMtd(), isDocNtc(), isDocTxt(), isList(), prepareDocEqns(), printdocCodeSlices(), printDocDgm(), printDocEqn(), printDocMetadata(), printDocNotice(), printfaustlistings(), reverse(), and tl().

Referenced by printDoc().

00442 {
00443     //cerr << endl << "Documentator : printdoccontent : " << docVector.size() << " <mdoc> tags read." << endl;
00444     
00446     vector<Lateq*>  docCompiledEqnsVector;
00447     prepareDocEqns( docVector, docCompiledEqnsVector ); 
00448     vector<Lateq*>::iterator eqn_it = docCompiledEqnsVector.begin();
00449     
00450     int dgmIndex = 1;           
00451 
00452     vector<string> docMasterCodeMap;
00453     docMasterCodeMap = docCodeSlicer(gMasterDocument, docMasterCodeMap);
00454     
00455     vector<Tree>::const_iterator doc;
00456     vector<string>::const_iterator code;
00457     code = docMasterCodeMap.begin();
00458     
00459     if(doesFileBeginWithCode(gMasterDocument) && (! docMasterCodeMap.empty()) && gLstDistributedSwitch ) {
00460         printdocCodeSlices(*code, docout);
00461         code++;
00462     }
00463     
00465     for (doc=docVector.begin(); doc<docVector.end(); doc++, code++) {
00466         
00467         Tree L = reverse(*doc);
00468         //cerr << "Entering into <mdoc> parsing..." << endl; 
00469         
00471         while (isList(L)) {
00472             Tree expr;
00473             if ( isDocEqn(hd(L), expr) ) { 
00474                 printDocEqn(*eqn_it++, docout);
00475             }
00476             else if ( isDocDgm(hd(L), expr) ) { 
00477                 printDocDgm(expr, svgTopDir, docout, dgmIndex++);
00478             }
00479             else if ( isDocMtd(hd(L), expr) ) { 
00480                 printDocMetadata(expr, docout);
00481             }
00482             else if ( isDocTxt(hd(L)) ) { 
00483                 docout << *hd(L)->branch(0); // Directly print registered doc text.
00484             }
00485             else if ( isDocNtc(hd(L)) ) { 
00486                 printDocNotice(faustversion, docout);
00487             }
00488             else if ( isDocLst(hd(L)) ) { 
00489                 printfaustlistings(docout);
00490             }
00491             else { 
00492                 cerr << "ERROR : " << *hd(L) << " is not a valid documentation type." << endl; 
00493             }
00494             L = tl(L);
00495         }
00496         //cerr << " ...end of <mdoc> parsing." << endl; 
00497         
00498         if ( code != docMasterCodeMap.end() && gLstDistributedSwitch ) {
00499             printdocCodeSlices(*code, docout);
00500         }
00501     }
00502 }

Here is the call graph for this function:

Here is the caller graph for this function:

static void printDocDgm ( const Tree  expr,
const char *  svgTopDir,
ostream &  docout,
int  i 
) [static]

Doc diagrams handling.

Three steps : 1. evaluate expression 2. call svg drawing in the appropriate directory 3. print latex figure code with the appropriate directory reference

Parameters:
[in] expr Parsed input expression, as boxes tree.
[in] svgTopDir Basename of the new doc directory ("*-math/svg").
[out] docout The output file to print into.

1. Evaluate expression.

2. Draw the diagram after its evaluation, in SVG. Warning : pdflatex can't directly include SVG files !

3. Print LaTeX figure code.

4. Warn about naming interferences (in the notice).

Definition at line 847 of file doc.cpp.

References drawSchema(), evaldocexpr(), gDocMathStringMap, gDocNoticeFlagMap, gErrorCount, legalFileName(), MAXIDCHARS, and subst().

Referenced by printdoccontent().

00848 {
00850     Tree docdgm = evaldocexpr(expr, gExpandedDefList);
00851     if (gErrorCount > 0) {
00852         cerr << "Total of " << gErrorCount << " errors during evaluation of : diagram docdgm = " << boxpp(docdgm) << ";\n";
00853         exit(1);
00854     }
00855     
00860     char dgmid[MAXIDCHARS+1];
00861     sprintf(dgmid, "%02d", i);
00862     string thisdgmdir = subst("$0/svg-$1", svgTopDir, dgmid);
00863     //cerr << "Documentator : printDocDgm : drawSchema in '" << gCurrentDir << "/" << thisdgmdir << "'" << endl;
00864     
00865     drawSchema( docdgm, thisdgmdir.c_str(), "svg" );
00866     
00868     char temp[1024];
00869     const string dgmfilename = legalFileName(docdgm, 1024, temp);
00870     //docout << "figure \\ref{figure" << i << "}";
00871     docout << "\\begin{figure}[ht!]" << endl;
00872     docout << "\t\\centering" << endl;
00873     docout << "\t\\includegraphics[width=\\textwidth]{" << subst("../svg/svg-$0/", dgmid) << dgmfilename << "}" << endl;
00874     docout << "\t\\caption{" << gDocMathStringMap["dgmcaption"] << " \\texttt{" << dgmfilename << "}}" << endl;
00875     docout << "\t\\label{figure" << i << "}" << endl;
00876     docout << "\\end{figure}" << endl << endl;
00877     
00879     gDocNoticeFlagMap["nameconflicts"] = true;
00880     gDocNoticeFlagMap["svgdir"] = true;
00881 }

Here is the call graph for this function:

Here is the caller graph for this function:

static void printDocEqn ( Lateq ltq,
ostream &  docout 
) [static]

Print doc equations, following the Lateq::println method.

Parameters:
[in] ltq The object containing compiled LaTeX code of equations.
[out] docout The output file to print into.

Definition at line 824 of file doc.cpp.

References Lateq::println().

Referenced by printdoccontent().

00825 {
00826     ltq->println(docout);
00827     //cerr << "Documentator : printDocEqn : "; ltq->println(cerr); cerr << endl;
00828 }

Here is the call graph for this function:

Here is the caller graph for this function:

static void printDocMetadata ( const Tree  expr,
ostream &  docout 
) [static]

Print a metadata set.

Each metadata is a set, in order to handle multiple items, like multiple authors, even if most of metadatas have unique items.

Parameters:
[in] expr Parsed metadata keyname, as boxes tree.
[out] docout The output file to print into.

Definition at line 316 of file doc.cpp.

References gMetaDataSet, rmExternalDoubleQuotes(), and tree2str().

Referenced by printdoccontent().

00317 {
00318     if (gMetaDataSet.count(expr)) {
00319         string sep = "";
00320         set<Tree> mset = gMetaDataSet[expr];
00321         
00322         for (set<Tree>::iterator j = mset.begin(); j != mset.end(); j++) {
00323             docout << sep << rmExternalDoubleQuotes(tree2str(*j));
00324             sep = ", ";
00325         }
00326     }
00327 }

Here is the call graph for this function:

Here is the caller graph for this function:

static void printfaustdocstamp ( const string &  faustversion,
ostream &  docout 
) [static]

Print a "doc stamp" in the LaTeX document :

  • the Faust version,
  • the date of doc compilation,
  • faust's web site URL.

Parameters:
[in] faustversion The current version of this Faust compiler.
[out] docout The LaTeX output file to print into.

Definition at line 409 of file doc.cpp.

References getCompilationDate().

Referenced by printDoc().

00410 {
00411     char datebuf [150];
00412     strftime (datebuf, 150, "%c", getCompilationDate());
00413     
00414     docout << "%% This documentation was generated with Faust version " << faustversion << endl;
00415     docout << "%% " << datebuf << endl;
00416     docout << "%% http://faust.grame.fr" << endl << endl;
00417 }

Here is the call graph for this function:

Here is the caller graph for this function:

static void printfaustlisting ( string &  faustfile,
ostream &  docout 
) [static]

Print a listing of the Faust code, in a LaTeX "listing" environment.

Strip content of <mdoc> tags.

Parameters:
[in] faustfile The source file containing the Faust code.
[out] docout The LaTeX output file to print into.

We suppose there's only one <mdoc> tag per line.

Definition at line 356 of file doc.cpp.

References filebasename(), and gStripDocSwitch.

Referenced by printfaustlistings().

00357 {   
00358     string  s;
00359     ifstream src;
00360     
00361     //cerr << "Documentator : printfaustlisting : Opening file '" << faustfile << "'" << endl;
00362     src.open(faustfile.c_str(), ifstream::in);
00363     
00364     docout << endl << "\\bigskip\\bigskip" << endl;
00365     docout << "\\begin{lstlisting}[caption=\\texttt{" << filebasename(faustfile.c_str()) << "}]" << endl;
00366 
00367     bool isInsideDoc = false;
00368     
00369     if (faustfile != "" && src.good()) {
00370         while(getline(src, s)) { 
00371             size_t foundopendoc  = s.find("<mdoc>");
00372             if (foundopendoc != string::npos && gStripDocSwitch) isInsideDoc = true;
00373             
00374             if (isInsideDoc == false)
00375                 docout << s << endl;
00376             
00377             size_t foundclosedoc = s.find("</mdoc>");
00378             if (foundclosedoc != string::npos && gStripDocSwitch) isInsideDoc = false;
00379         }
00380     } else {
00381         cerr << "ERROR : can't open faust source file " << faustfile << endl;
00382         exit(1);
00383     }
00384     
00385     docout << "\\end{lstlisting}" << endl << endl;
00386 }

Here is the call graph for this function:

Here is the caller graph for this function:

static void printfaustlistings ( ostream &  docout  )  [static]

Print listings of each Faust code ".dsp" files, calling the 'printfaustlisting' function.

Parameters:
[out] docout The LaTeX output file to print into.

Definition at line 336 of file doc.cpp.

References gLstDependenciesSwitch, gMasterDocument, SourceReader::listSrcFiles(), and printfaustlisting().

Referenced by printdoccontent().

00337 {   
00338     if (gLstDependenciesSwitch) {
00339         vector<string> pathnames = gReader.listSrcFiles();
00340         for (unsigned int i=0; i< pathnames.size(); i++) {
00341             printfaustlisting(pathnames[i], docout);
00342         }
00343     } else {
00344         printfaustlisting(gMasterDocument, docout);
00345     }
00346 }

Here is the call graph for this function:

Here is the caller graph for this function:

static void printlatexfooter ( ostream &  docout  )  [static]

Print the static LaTeX footer.

Parameters:
[out] docout The LaTeX output file to print into.

Definition at line 394 of file doc.cpp.

Referenced by printDoc().

00395 {
00396     docout << endl << "\\end{document}" << endl << endl;
00397 }

Here is the caller graph for this function:

static void printlatexheader ( istream &  latexheader,
const string &  faustversion,
ostream &  docout 
) [static]

Print a static LaTeX header.

Parameters:
[in] latexheader The file containing the static part of the LaTeX header.
[in] faustversion The current version of this Faust compiler.
[out] docout The LaTeX output file to print into.

Specific LaTeX macros for Faust

Definition at line 288 of file doc.cpp.

References getCompilationDate(), gMasterDocument, and gMasterName.

Referenced by printDoc().

00289 {   
00290     string  s;
00291     while(getline(latexheader, s)) docout << s << endl;
00292     
00294     docout << "\\newcommand{\\faustfilename}{" << gMasterDocument << "}" << endl;
00295     docout << "\\newcommand{\\faustdocdir}{" << gMasterName << "-mdoc}" << endl;
00296     docout << "\\newcommand{\\faustprogname}{" << gMasterName << "}" << endl;
00297     docout << "\\newcommand{\\faustversion}{" << faustversion << "}" << endl;
00298     char datebuf [150];
00299     strftime (datebuf, 150, "%B %d, %Y", getCompilationDate());
00300     docout << "\\newcommand{\\faustdocdate}{" << datebuf << "}" << endl;
00301     
00302     docout << endl << "\\begin{document}" << endl;
00303 }

Here is the call graph for this function:

Here is the caller graph for this function:

static string rmExternalDoubleQuotes ( const string &  s  )  [static]

Remove the leading and trailing double quotes of a string (but not those in the middle of the string).

Definition at line 1105 of file doc.cpp.

Referenced by printDocMetadata().

01106 {
01107     size_t i = s.find_first_not_of("\"");
01108     size_t j = s.find_last_not_of("\"");
01109     
01110     if ( (i != string::npos) & (j != string::npos) ) {
01111         return s.substr(i, 1+j-i);
01112     } else {
01113         return "";
01114     }
01115 }

Here is the caller graph for this function:


Variable Documentation

Sym DOCDGM = symbol ("DocDgm")

Definition at line 193 of file doc.cpp.

Sym DOCEQN = symbol ("DocEqn")

Definition at line 189 of file doc.cpp.

Sym DOCLST = symbol ("DocLst")

Definition at line 201 of file doc.cpp.

Sym DOCMTD = symbol ("DocMtd")

Definition at line 205 of file doc.cpp.

Sym DOCNTC = symbol ("DocNtc")

Definition at line 197 of file doc.cpp.

Sym DOCTXT = symbol ("DocTxt")

Definition at line 175 of file doc.cpp.

struct tm gCompilationDate [static]

Definition at line 112 of file doc.cpp.

Referenced by getCompilationDate(), and initCompilationDate().

string gCurrentDir [static]

Room to save current directory name.

Definition at line 107 of file doc.cpp.

Referenced by cholddir(), getCurrentDir(), makedir(), and mkchdir().

Definition at line 114 of file main.cpp.

Referenced by main(), and process_cmdline().

const char* gDocDevSuffix [static]

".tex" (or .??? - used to choose output device).

Definition at line 106 of file doc.cpp.

Referenced by printDoc().

string gDocLang

Definition at line 119 of file doc.cpp.

Referenced by printDoc(), and process_cmdline().

map<string, string> gDocMathStringMap
map<string, string> gDocMetadatasStringMap

Definition at line 35 of file doc_metadatas.cpp.

Referenced by declareAutoDoc(), importDocStrings(), and storePair().

string gDocName

Contains the filename for out documentation.

Definition at line 107 of file main.cpp.

Referenced by declareAutoDoc(), initFaustDirectories(), and printDoc().

vector<Tree> gDocVector

Contains <mdoc> parsed trees: DOCTXT, DOCEQN, DOCDGM.

Definition at line 110 of file doc.cpp.

Referenced by declareDoc(), and printDoc().

Definition at line 108 of file main.cpp.

Definition at line 103 of file main.cpp.

Referenced by fopensearch(), initFaustDirectories(), and open_arch_stream().

Definition at line 102 of file main.cpp.

Referenced by fopensearch(), initFaustDirectories(), and open_arch_stream().

Definition at line 101 of file main.cpp.

Referenced by fopensearch(), initFaustDirectories(), and open_arch_stream().

const string gLatexheaderfilename = "latexheader.tex" [static]

Definition at line 108 of file doc.cpp.

Referenced by printDoc().

mdoc listing management.

Definition at line 114 of file doc.cpp.

Referenced by printfaustlistings(), and yyparse().

bool gLstDistributedSwitch = true

mdoc listing management.

Definition at line 116 of file doc.cpp.

Referenced by printdoccontent(), and yyparse().

bool gLstMdocTagsSwitch = true

mdoc listing management.

Definition at line 115 of file doc.cpp.

string gMasterName

Definition at line 106 of file main.cpp.

Referenced by initFaustDirectories(), and printlatexheader().

map<Tree, set<Tree> > gMetaDataSet

Definition at line 89 of file main.cpp.

Definition at line 122 of file main.cpp.

Referenced by printfaustlisting(), process_cmdline(), and yyparse().

Generated on Thu Jul 15 15:46:58 2010 for FAUST compiler by  doxygen 1.6.3