|
FAUST compiler
0.9.9.6b8
|
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 "eval.hh"#include "errormsg.hh"#include "doc_Text.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 "lateq.hh"#include "doc_compile.hh"#include "doc_lang.hh"#include "doc_notice.hh"#include "doc_autodoc.hh"#include "compatibility.hh"
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 : | |
| 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< Tree > | gDocVector |
| 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") |
Implementation of documentation trees support and printing.
Definition in file doc.cpp.
| #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().
| anonymous enum |
| static void annotateSuperList | ( | DocCompiler * | DC, |
| Tree | superEqList | ||
| ) | [static] |
step 8. Annotate superlist.
Annotate superEqList (to find candidate signals to be named later).
| [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().
{
DC->annotate(superEqList);
}


| static string calcDocEqnInitial | ( | const string | s | ) | [static] |
Calculate an appropriate nickname for equations, from previous names.
| The | string to parse. |
Definition at line 788 of file doc.cpp.
Referenced by calcEqnsNicknames().
{
string nn;
if(s == "process")
nn = "Y";
else if (s.substr(0,6) == "doceqn")
nn = "Z";
else
nn += toupper(s[0]);
return nn;
}

| static void calcEqnsNicknames | ( | const vector< string > & | eqNames, |
| vector< string > & | eqNicknames | ||
| ) | [static] |
step 3. Calculate nicknames.
Calculate a nickname for each equation and store it.
| [in] | eqNames | Equations names to parse. |
| [out] | eqNicknames | The place to store calculated nicknames. |
Check duplicates
Definition at line 623 of file doc.cpp.
References calcDocEqnInitial().
Referenced by prepareDocEqns().
{
//cerr << "###\n# Documentator : calcEqnsNicknames" << endl;
vector<string> v;
for( vector<string>::const_iterator eq = eqNames.begin(); eq < eqNames.end(); eq++ ) {
string init = calcDocEqnInitial(*eq);
v.push_back(init);
// for( vector<string>::iterator it = v.begin(); it < v.end()-1; ++it ) {
// if (init == *it) {
// //cerr << "!! Warning Documentator : calcEqnsNicknames : duplicates \"" << init << "\"" << endl;
// }
// }
eqNicknames.push_back(init);
}
// for( vector<string>::const_iterator eq = eqNames.begin(); eq < eqNames.end(); eq++ ) {
// int c = 0;
// c = count_if(eqNames.begin(), eqNames.end(), bind2nd(equal_to<string>(), *eq));
// if (c > 0) {
// cerr << "- Duplicate nickname !! " << *eq << endl;
// } else {
// cerr << "(no duplicate) " << *eq << endl;
// }
// }
//cerr << "Documentator : end of calcEqnsNicknames\n---" << endl;
}


| 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().
{
char nb[MAXIDCHARS+1];
sprintf(nb, "%03d", i);
return subst("$0$1", base, nb);
}


| 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().
{
if (chdir(gCurrentDir.c_str()) == 0) {
return 0;
} else {
perror("cholddir");
exit(errno);
}
}

| static void collectDocEqns | ( | const vector< Tree > & | docBoxes, |
| vector< Tree > & | eqBoxes | ||
| ) | [static] |
step 0. Feed a vector.
Collect every <equation> found in all <mdoc> faust comments.
| [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().
{
int nbdoceqn = 0;
for (vector<Tree>::const_iterator doc=docBoxes.begin(); doc<docBoxes.end(); doc++) {
Tree L = reverse(*doc);
Tree expr;
while (isList(L)) {
if ( isDocEqn(hd(L), expr) ) {
eqBoxes.push_back(expr);
nbdoceqn++;
}
L = tl(L);
}
}
//cerr << "Documentator : collectDocEqns : " << nbdoceqn << " <equation> tags found." << endl;
}


| static void collectEqSigs | ( | const vector< Tree > & | eqSigs, |
| Tree & | superEqList | ||
| ) | [static] |
step 7. Collect all signals in a superlist.
Collect each prepared list of signals to construct a super list.
| [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.
Referenced by prepareDocEqns().
{
//cerr << "###\n# Documentator : collectEqSigs" << endl;
superEqList = nil;
for( vector<Tree>::const_iterator it = eqSigs.begin(); it < eqSigs.end(); ++it ) {
superEqList = cons( *it, superEqList );
}
//printSignal(superEqList, stdout, 0);
//cerr << endl << "Documentator : end of collectEqSigs\n---" << endl;
}


| static void copyFaustSources | ( | const char * | projname, |
| const vector< string > & | pathnames | ||
| ) | [static] |
Copy all Faust source files into an 'src' subdirectory.
| [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().
{
string srcdir = subst("$0/src", projname);
//cerr << "Documentator : copyFaustSources : Creating directory '" << srcdir << "'" << endl;
makedir(srcdir.c_str()); // create a directory.
for (unsigned int i=0; i< pathnames.size(); i++) {
ifstream src;
ofstream dst;
string faustfile = pathnames[i];
string copy = subst("$0/$1", srcdir, filebasename(faustfile.c_str()));
//cerr << "Documentator : copyFaustSources : Opening input file '" << faustfile << "'" << endl;
//cerr << "Documentator : copyFaustSources : Opening output file '" << copy << "'" << endl;
src.open(faustfile.c_str(), ifstream::in);
dst.open(copy.c_str(), ofstream::out);
string s;
while ( getline(src,s) ) dst << s << endl;
}
}


| vector< string > & docCodeSlicer | ( | const string & | faustfile, |
| vector< string > & | codeSlices | ||
| ) |
Slice faust code between "mdoc" sections.
| [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().
{
string s;
ifstream src;
src.open(faustfile.c_str(), ifstream::in);
string tmp = "";
bool isInsideDoc = false;
if (faustfile != "" && src.good()) {
while(getline(src, s)) {
size_t foundopendoc = s.find("<mdoc>");
if (foundopendoc != string::npos) {
if (isInsideDoc == false) {
if (! tmp.empty() ) {
codeSlices.push_back(tmp); }
tmp = "";
}
isInsideDoc = true;
}
if (isInsideDoc == false) {
tmp += s + '\n';
}
size_t foundclosedoc = s.find("</mdoc>");
if (foundclosedoc != string::npos) isInsideDoc = false;
}
} else {
cerr << "ERROR : can't open faust source file " << faustfile << endl;
exit(1);
}
return codeSlices;
}

| static bool doesFileBeginWithCode | ( | const string & | faustfile | ) | [static] |
Test whether a file does begin with some faust code or not.
| [in] | faustfile | Name of the input faust file to parse. |
Definition at line 954 of file doc.cpp.
Referenced by printdoccontent().
{
string s;
ifstream src;
src.open(faustfile.c_str(), ifstream::in);
if (faustfile != "" && src.good()) {
getline(src, s);
size_t foundopendoc = s.find("<mdoc>");
if(int(foundopendoc)==0) {
return false;
} else {
return true;
}
} else {
cerr << "ERROR : can't open faust source file " << faustfile << endl;
exit(1);
}
}

| 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.
| [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().
{
if (!getBoxType(t, &numInputs, &numOutputs)) {
cerr << "ERROR during the evaluation of t : " << boxpp(t) << endl;
exit(1);
}
//cerr << "Documentator : " << numInputs <<" inputs and " << numOutputs <<" outputs for box : " << boxpp(t) << endl;
}


| static struct tm * getCompilationDate | ( | ) | [static, read] |
Definition at line 1156 of file doc.cpp.
References gCompilationDate, and initCompilationDate().
Referenced by printfaustdocstamp(), and printlatexheader().
{
initCompilationDate();
return &gCompilationDate;
}


| 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().
{
char buffer[FAUST_PATH_MAX];
gCurrentDir = getcwd (buffer, FAUST_PATH_MAX);
}

| static void initCompilationDate | ( | ) | [static] |
Definition at line 1148 of file doc.cpp.
References gCompilationDate.
Referenced by getCompilationDate().
{
time_t now;
time(&now);
gCompilationDate = *localtime(&now);
}

Definition at line 191 of file doc.cpp.
References DOCEQN, and isTree().
Referenced by collectDocEqns(), and printdoccontent().


Definition at line 177 of file doc.cpp.
References DOCTXT, and CTree::node().
Referenced by printdoccontent().


| 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().
{
Tree id;
int i=0;
if (getDefNameProperty(t, id)) {
const char* src = tree2str(id);
for (i=0; isalnum(src[i]) && i<16; i++) {
dst[i] = src[i];
}
}
dst[i] = 0;
if (strcmp(dst, "process") != 0) {
// if it is not process add the hex address to make the name unique
snprintf(&dst[i], n-i, "-%p", t);
}
return dst;
}


| 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().
{
char buffer[FAUST_PATH_MAX];
gCurrentDir = getcwd (buffer, FAUST_PATH_MAX);
if ( gCurrentDir.c_str() != 0) {
int status = mkdir(dirname, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
if (status == 0 || errno == EEXIST) {
return 0;
}
}
perror("makedir");
exit(errno);
}

| 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.
Calculated and set lateq (LaTeX equation) names. Note : Transfered into mapCompileDocEqnSigs (DocCompiler::compileMultiSignal).
| [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().
{
//cerr << "###\n# Documentator : mapCompileDocEqnSigs" << endl;
for( unsigned int i=0; i < eqSigs.size(); i++ ) {
// docCompiledEqnsVector.push_back( DC->compileMultiSignal(*it, 0) );
docCompiledEqnsVector.push_back( DC->compileLateq(eqSigs[i], new Lateq(eqInputs[i], eqOutputs[i])) );
}
//cerr << "Documentator : end of mapCompileDocEqnSigs\n---" << endl;
}


| static void mapEvalDocEqn | ( | const vector< Tree > & | eqBoxes, |
| const Tree & | env, | ||
| vector< Tree > & | evalEqBoxes | ||
| ) | [static] |
step 1. Evaluate boxes.
Evaluate every doc <equation> (evaluation replaces abstractions by symbolic boxes).
| [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().
{
//cerr << "###\n# Documentator : mapEvalDocEqn" << endl;
for ( vector<Tree>::const_iterator eq=eqBoxes.begin(); eq < eqBoxes.end(); eq++)
{
evalEqBoxes.push_back(evaldocexpr( *eq, env ));
}
//cerr << "Documentator : end of mapEvalDocEqn\n---" << endl;
}


| static void mapGetEqName | ( | const vector< Tree > & | evalEqBoxes, |
| vector< string > & | eqNames | ||
| ) | [static] |
step 2. Get boxes name.
Get name if exists, else create one, and store it.
| [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().
{
//cerr << "###\n# Documentator : mapGetEqName" << endl;
int i = 1;
for( vector<Tree>::const_iterator eq = evalEqBoxes.begin(); eq < evalEqBoxes.end(); eq++, i++ ) {
Tree id;
string s;
int n,m; getBoxType(*eq, &n, &m); // eq name only for bd without inputs
if ( n==0 && getDefNameProperty(*eq, id) ) {
s = tree2str(id);
}
else {
s = calcNumberedName("doceqn-", i);
}
eqNames.push_back( s ) ;
}
//cerr << "Documentator : end of mapGetEqName\n---" << endl;
}


| static void mapPrepareEqSig | ( | const vector< Tree > & | evalEqBoxes, |
| vector< int > & | eqInputs, | ||
| vector< int > & | eqOutputs, | ||
| vector< Tree > & | eqSigs | ||
| ) | [static] |
step 4&5. Propagate and prepare signals.
Propagate and prepare every doc <equation>.
Call boxPropagateSig, deBruijn2Sym, simplify, and privatise.
| [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().
{
//cerr << "###\n# Documentator : mapPrepareEqSig" << endl;
for( vector<Tree>::const_iterator eq = evalEqBoxes.begin(); eq < evalEqBoxes.end(); eq++ ) {
int numInputs, numOutputs;
getBoxInputsAndOutputs(*eq, numInputs, numOutputs);
//cerr << numInputs <<" ins and " << numOutputs <<" outs" << endl;
eqInputs.push_back(numInputs);
eqOutputs.push_back(numOutputs);
Tree lsig1 = boxPropagateSig( nil, *eq , makeSigInputList(numInputs) );
//cerr << "output signals are : " << endl; printSignal(lsig1, stderr);
Tree lsig2 = deBruijn2Sym(lsig1);
Tree lsig3 = simplify(lsig2);
//Tree lsig4 = privatise(lsig3); ///< Un-share tables with multiple writers
Tree lsig4 = docTableConvertion(lsig3);
eqSigs.push_back(lsig4);
}
//cerr << "Documentator : end of mapPrepareEqSig\n---" << endl;
}


| static void mapSetSigNickname | ( | const vector< string > & | eqNicknames, |
| const vector< int > & | eqInputs, | ||
| const vector< Tree > & | eqSigs | ||
| ) | [static] |
step 6. Set signals nicknames.
Set signals nicknames.
Do nothing for the moment !
| [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().
{
//cerr << "###\n# Documentator : mapSetSigNickname" << endl;
// Do nothing for the moment...
// for( unsigned int i=0; i < eqSigs.size(); i++ ) {
// if (eqInputs[i] == 0) // Only "generators" should be finally named with user equation (nick)name.
// setSigListNickName(eqSigs[i], eqNicknames[i]);
// }
//cerr << "Documentator : end of mapSetSigNickname\n---" << endl;
}

| static int mkchdir | ( | const char * | dirname | ) | [static] |
Create a new directory in the current one, then 'cd' into this new directory.
Definition at line 1005 of file doc.cpp.
References FAUST_PATH_MAX, and gCurrentDir.
Referenced by printDoc().
{
char buffer[FAUST_PATH_MAX];
gCurrentDir = getcwd (buffer, FAUST_PATH_MAX);
if ( gCurrentDir.c_str() != 0) {
int status = mkdir(dirname, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
if (status == 0 || errno == EEXIST) {
if (chdir(dirname) == 0) {
return 0;
}
}
}
perror("mkchdir");
exit(errno);
}

| 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().
{
istream* file;
getCurrentDir(); // Save the current directory.
//cerr << "Documentator : openArchFile : Opening input file '" << filename << "'" << endl;
if ( (file = open_arch_stream(filename.c_str())) ) {
//cerr << "Documentator : openArchFile : Opening '" << filename << "'" << endl;
} else {
cerr << "ERROR : can't open architecture file " << filename << endl;
exit(1);
}
cholddir(); // Return to current directory.
return file;
}


| 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.
| [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(), gExpandedDefList, mapCompileDocEqnSigs(), mapEvalDocEqn(), mapGetEqName(), mapPrepareEqSig(), and mapSetSigNickname().
Referenced by printdoccontent().
{
vector<Tree> eqBoxes; collectDocEqns( docBoxes, eqBoxes );
if(! eqBoxes.empty() ) {
vector<Tree> evalEqBoxes; mapEvalDocEqn( eqBoxes, gExpandedDefList, evalEqBoxes );
vector<string> eqNames; mapGetEqName( evalEqBoxes, eqNames );
vector<string> eqNicknames; calcEqnsNicknames( eqNames, eqNicknames );
vector<int> eqInputs;
vector<int> eqOutputs;
vector<Tree> eqSigs; mapPrepareEqSig( evalEqBoxes, eqInputs, eqOutputs, eqSigs );
mapSetSigNickname( eqNicknames, eqInputs, eqSigs );
Tree superEqList; collectEqSigs( eqSigs, superEqList );
DocCompiler* DC = new DocCompiler(0, 0);
annotateSuperList( DC, superEqList );
//calcAndSetLtqNames( superEqList ); ///< step 9. (directly in 10.)
mapCompileDocEqnSigs( eqSigs, eqInputs, eqOutputs, DC, docCompiledEqnsVector );
}
}


| 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.
| [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, gReader, SourceReader::listSrcFiles(), loadTranslationFile(), makedir(), mkchdir(), openArchFile(), printdoccontent(), printfaustdocstamp(), printlatexfooter(), printlatexheader(), and subst().
Referenced by main().
{
gDocDevSuffix = docdev;
//cerr << "Documentator : printDoc : gFaustDirectory = '" << gFaustDirectory << "'" << endl;
//cerr << "Documentator : printDoc : gFaustSuperDirectory = '" << gFaustSuperDirectory << "'" << endl;
//cerr << "Documentator : printDoc : gFaustSuperSuperDirectory = '" << gFaustSuperSuperDirectory << "'" << endl;
//cerr << "Documentator : printDoc : gCurrentDir = '" << gCurrentDir << "'" << endl;
makedir(projname); // create a top directory to store files
string svgTopDir = subst("$0/svg", projname);
makedir(svgTopDir.c_str()); // create a directory to store svg-* subdirectories.
string cppdir = subst("$0/cpp", projname);
makedir(cppdir.c_str()); // create a cpp directory.
string pdfdir = subst("$0/pdf", projname);
makedir(pdfdir.c_str()); // create a pdf directory.
/* Copy all Faust source files into an 'src' sub-directory. */
vector<string> pathnames = gReader.listSrcFiles();
copyFaustSources(projname, pathnames);
string texdir = subst("$0/tex", projname);
mkchdir(texdir.c_str()); // create a directory and move into.
ofstream docout(subst("$0.$1", gDocName, docdev).c_str());
cholddir(); // return to current directory
loadTranslationFile(gDocLang);
if (gDocVector.empty()) { declareAutoDoc(); }
printfaustdocstamp(faustversion, docout);
istream* latexheader = openArchFile(gLatexheaderfilename);
printlatexheader(*latexheader, faustversion, docout);
printdoccontent(svgTopDir.c_str(), gDocVector, faustversion, docout);
printlatexfooter(docout);
}


| static void printdocCodeSlices | ( | const string & | code, |
| ostream & | docout | ||
| ) | [static] |
Print faust code inside a listing environment.
| [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().
{
if ( ! code.empty() ) {
docout << endl << "\\begin{lstlisting}[numbers=none, frame=none, basicstyle=\\small\\ttfamily, backgroundcolor=\\color{yobg}]" << endl;
docout << code << endl;
docout << "\\end{lstlisting}" << endl << endl;
}
}

| 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).
| [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().
{
//cerr << endl << "Documentator : printdoccontent : " << docVector.size() << " <mdoc> tags read." << endl;
vector<Lateq*> docCompiledEqnsVector;
prepareDocEqns( docVector, docCompiledEqnsVector );
vector<Lateq*>::iterator eqn_it = docCompiledEqnsVector.begin();
int dgmIndex = 1;
vector<string> docMasterCodeMap;
docMasterCodeMap = docCodeSlicer(gMasterDocument, docMasterCodeMap);
vector<Tree>::const_iterator doc;
vector<string>::const_iterator code;
code = docMasterCodeMap.begin();
if(doesFileBeginWithCode(gMasterDocument) && (! docMasterCodeMap.empty()) && gLstDistributedSwitch ) {
printdocCodeSlices(*code, docout);
code++;
}
for (doc=docVector.begin(); doc<docVector.end(); doc++, code++) {
Tree L = reverse(*doc);
//cerr << "Entering into <mdoc> parsing..." << endl;
while (isList(L)) {
Tree expr;
if ( isDocEqn(hd(L), expr) ) {
printDocEqn(*eqn_it++, docout);
}
else if ( isDocDgm(hd(L), expr) ) {
printDocDgm(expr, svgTopDir, docout, dgmIndex++);
}
else if ( isDocMtd(hd(L), expr) ) {
printDocMetadata(expr, docout);
}
else if ( isDocTxt(hd(L)) ) {
docout << *hd(L)->branch(0); // Directly print registered doc text.
}
else if ( isDocNtc(hd(L)) ) {
printDocNotice(faustversion, docout);
}
else if ( isDocLst(hd(L)) ) {
printfaustlistings(docout);
}
else {
cerr << "ERROR : " << *hd(L) << " is not a valid documentation type." << endl;
}
L = tl(L);
}
//cerr << " ...end of <mdoc> parsing." << endl;
if ( code != docMasterCodeMap.end() && gLstDistributedSwitch ) {
printdocCodeSlices(*code, docout);
}
}
}


| static void printDocDgm | ( | const Tree | expr, |
| const char * | svgTopDir, | ||
| ostream & | docout, | ||
| int | i | ||
| ) | [static] |
Doc diagrams handling.
Three steps :
| [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. |
Definition at line 847 of file doc.cpp.
References drawSchema(), evaldocexpr(), gDocMathStringMap, gDocNoticeFlagMap, gErrorCount, gExpandedDefList, legalFileName(), MAXIDCHARS, and subst().
Referenced by printdoccontent().
{
Tree docdgm = evaldocexpr(expr, gExpandedDefList);
if (gErrorCount > 0) {
cerr << "Total of " << gErrorCount << " errors during evaluation of : diagram docdgm = " << boxpp(docdgm) << ";\n";
exit(1);
}
char dgmid[MAXIDCHARS+1];
sprintf(dgmid, "%02d", i);
string thisdgmdir = subst("$0/svg-$1", svgTopDir, dgmid);
//cerr << "Documentator : printDocDgm : drawSchema in '" << gCurrentDir << "/" << thisdgmdir << "'" << endl;
drawSchema( docdgm, thisdgmdir.c_str(), "svg" );
char temp[1024];
const string dgmfilename = legalFileName(docdgm, 1024, temp);
//docout << "figure \\ref{figure" << i << "}";
docout << "\\begin{figure}[ht!]" << endl;
docout << "\t\\centering" << endl;
docout << "\t\\includegraphics[width=\\textwidth]{" << subst("../svg/svg-$0/", dgmid) << dgmfilename << "}" << endl;
docout << "\t\\caption{" << gDocMathStringMap["dgmcaption"] << " \\texttt{" << dgmfilename << "}}" << endl;
docout << "\t\\label{figure" << i << "}" << endl;
docout << "\\end{figure}" << endl << endl;
gDocNoticeFlagMap["nameconflicts"] = true;
gDocNoticeFlagMap["svgdir"] = true;
}


| static void printDocEqn | ( | Lateq * | ltq, |
| ostream & | docout | ||
| ) | [static] |
Print doc equations, following the Lateq::println method.
| [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().
{
ltq->println(docout);
//cerr << "Documentator : printDocEqn : "; ltq->println(cerr); cerr << endl;
}


| 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.
| [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().
{
if (gMetaDataSet.count(expr)) {
string sep = "";
set<Tree> mset = gMetaDataSet[expr];
for (set<Tree>::iterator j = mset.begin(); j != mset.end(); j++) {
docout << sep << rmExternalDoubleQuotes(tree2str(*j));
sep = ", ";
}
}
}


| static void printfaustdocstamp | ( | const string & | faustversion, |
| ostream & | docout | ||
| ) | [static] |
Print a "doc stamp" in the LaTeX document :
| [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().
{
char datebuf [150];
strftime (datebuf, 150, "%c", getCompilationDate());
docout << "%% This documentation was generated with Faust version " << faustversion << endl;
docout << "%% " << datebuf << endl;
docout << "%% http://faust.grame.fr" << endl << endl;
}


| 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.
| [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().
{
string s;
ifstream src;
//cerr << "Documentator : printfaustlisting : Opening file '" << faustfile << "'" << endl;
src.open(faustfile.c_str(), ifstream::in);
docout << endl << "\\bigskip\\bigskip" << endl;
docout << "\\begin{lstlisting}[caption=\\texttt{" << filebasename(faustfile.c_str()) << "}]" << endl;
bool isInsideDoc = false;
if (faustfile != "" && src.good()) {
while(getline(src, s)) {
size_t foundopendoc = s.find("<mdoc>");
if (foundopendoc != string::npos && gStripDocSwitch) isInsideDoc = true;
if (isInsideDoc == false)
docout << s << endl;
size_t foundclosedoc = s.find("</mdoc>");
if (foundclosedoc != string::npos && gStripDocSwitch) isInsideDoc = false;
}
} else {
cerr << "ERROR : can't open faust source file " << faustfile << endl;
exit(1);
}
docout << "\\end{lstlisting}" << endl << endl;
}


| static void printfaustlistings | ( | ostream & | docout | ) | [static] |
Print listings of each Faust code ".dsp" files, calling the 'printfaustlisting' function.
| [out] | docout | The LaTeX output file to print into. |
Definition at line 336 of file doc.cpp.
References gLstDependenciesSwitch, gMasterDocument, gReader, SourceReader::listSrcFiles(), and printfaustlisting().
Referenced by printdoccontent().
{
if (gLstDependenciesSwitch) {
vector<string> pathnames = gReader.listSrcFiles();
for (unsigned int i=0; i< pathnames.size(); i++) {
printfaustlisting(pathnames[i], docout);
}
} else {
printfaustlisting(gMasterDocument, docout);
}
}


| static void printlatexfooter | ( | ostream & | docout | ) | [static] |
Print the static LaTeX footer.
| [out] | docout | The LaTeX output file to print into. |
Definition at line 394 of file doc.cpp.
Referenced by printDoc().
{
docout << endl << "\\end{document}" << endl << endl;
}

| static void printlatexheader | ( | istream & | latexheader, |
| const string & | faustversion, | ||
| ostream & | docout | ||
| ) | [static] |
Print a static LaTeX header.
| [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().
{
string s;
while(getline(latexheader, s)) docout << s << endl;
docout << "\\newcommand{\\faustfilename}{" << gMasterDocument << "}" << endl;
docout << "\\newcommand{\\faustdocdir}{" << gMasterName << "-mdoc}" << endl;
docout << "\\newcommand{\\faustprogname}{" << gMasterName << "}" << endl;
docout << "\\newcommand{\\faustversion}{" << faustversion << "}" << endl;
char datebuf [150];
strftime (datebuf, 150, "%B %d, %Y", getCompilationDate());
docout << "\\newcommand{\\faustdocdate}{" << datebuf << "}" << endl;
docout << endl << "\\begin{document}" << endl;
}


| 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().
{
size_t i = s.find_first_not_of("\"");
size_t j = s.find_last_not_of("\"");
if ( (i != string::npos) & (j != string::npos) ) {
return s.substr(i, 1+j-i);
} else {
return "";
}
}

Definition at line 193 of file doc.cpp.
Referenced by docDgm(), and isDocDgm().
Definition at line 189 of file doc.cpp.
Referenced by docEqn(), and isDocEqn().
Definition at line 201 of file doc.cpp.
Referenced by docLst(), and isDocLst().
Definition at line 205 of file doc.cpp.
Referenced by docMtd(), and isDocMtd().
Definition at line 197 of file doc.cpp.
Referenced by docNtc(), and isDocNtc().
Definition at line 175 of file doc.cpp.
Referenced by docTxt(), and isDocTxt().
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().
| bool gDetailsSwitch |
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 |
Definition at line 51 of file lateq.cpp.
Referenced by importDocStrings(), Lateq::makeItemTitle(), Lateq::makeSigDomain(), Lateq::makeSignamesList(), DocCompiler::prepareBinaryUI(), DocCompiler::prepareIntervallicUI(), printDocDgm(), Lateq::printHierarchy(), Lateq::println(), and storePair().
| 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.
Referenced by main(), prepareDocEqns(), and printDocDgm().
| string gFaustDirectory |
Definition at line 103 of file main.cpp.
Referenced by fopensearch(), initFaustDirectories(), and open_arch_stream().
| string gFaustSuperDirectory |
Definition at line 102 of file main.cpp.
Referenced by fopensearch(), initFaustDirectories(), and open_arch_stream().
| string gFaustSuperSuperDirectory |
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().
| bool gLstDependenciesSwitch = true |
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 |
| string gMasterDocument |
Definition at line 104 of file main.cpp.
Referenced by declareMetadata(), initFaustDirectories(), main(), ScalarCompiler::prepare(), printdoccontent(), printfaustlistings(), and printlatexheader().
| string gMasterName |
Definition at line 106 of file main.cpp.
Referenced by initFaustDirectories(), and printlatexheader().
| map<Tree, set<Tree> > gMetaDataSet |
Definition at line 91 of file main.cpp.
Referenced by declareAutoDoc(), declareMetadata(), main(), printDocMetadata(), printheader(), Klass::println(), and Klass::printMetadata().
Definition at line 89 of file main.cpp.
Referenced by main(), printDoc(), and printfaustlistings().
| bool gStripDocSwitch |
Definition at line 123 of file main.cpp.
Referenced by printfaustlisting(), process_cmdline(), and yyparse().
1.8.0