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"
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 | printdocheader (ostream &docout) |
Print the dynamic visible header, in a LaTeX "tabular" environment. | |
static void | printlatexheader (istream &latexheader, 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 | prepareDocEqns (const vector< Tree > &docBoxes, vector< Lateq * > &docCompiledEqnsVector) |
Caller function. | |
static void | collectDocEqns (const vector< Tree > &docBoxes, vector< Tree > &eqBoxes) |
step 0. Feed doceqnInfosVector. | |
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. | |
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) |
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 |
bool | gDetailsSwitch |
bool | gStripDocSwitch |
string | gFaustDirectory |
string | gFaustSuperDirectory |
string | gFaustSuperSuperDirectory |
string | gMasterDocument |
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 |
string | gDocLang |
Sym | DOCTXT = symbol ("DocTxt") |
Sym | DOCEQN = symbol ("DocEqn") |
Sym | DOCDGM = symbol ("DocDgm") |
Sym | DOCNTC = symbol ("DocNtc") |
Sym | DOCLST = symbol ("DocLst") |
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.
#8.
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 719 of file doc.cpp.
References DocCompiler::annotate().
Referenced by prepareDocEqns().
00720 { 00721 DC->annotate(superEqList); 00722 }
static string calcDocEqnInitial | ( | const string | s | ) | [static] |
Calculate an appropriate nickname for equations, from previous names.
The | string to parse. |
Definition at line 770 of file doc.cpp.
Referenced by calcEqnsNicknames().
00771 { 00772 string nn; 00773 if(s == "process") 00774 nn = "Y"; 00775 else if (s.substr(0,6) == "doceqn") 00776 nn = "Z"; 00777 else 00778 nn += toupper(s[0]); 00779 return nn; 00780 }
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.
[in] | eqNames | Equations names to parse. |
[out] | eqNicknames | The place to store calculated nicknames. |
Check duplicates
Definition at line 605 of file doc.cpp.
References calcDocEqnInitial().
Referenced by prepareDocEqns().
00606 { 00607 //cerr << "###\n# Documentator : calcEqnsNicknames" << endl; 00608 00609 vector<string> v; 00610 00611 for( vector<string>::const_iterator eq = eqNames.begin(); eq < eqNames.end(); eq++ ) { 00612 string init = calcDocEqnInitial(*eq); 00613 v.push_back(init); 00615 // for( vector<string>::iterator it = v.begin(); it < v.end()-1; ++it ) { 00616 // if (init == *it) { 00617 // //cerr << "!! Warning Documentator : calcEqnsNicknames : duplicates \"" << init << "\"" << endl; 00618 // } 00619 // } 00620 eqNicknames.push_back(init); 00621 } 00622 00623 // for( vector<string>::const_iterator eq = eqNames.begin(); eq < eqNames.end(); eq++ ) { 00624 // int c = 0; 00625 // c = count_if(eqNames.begin(), eqNames.end(), bind2nd(equal_to<string>(), *eq)); 00626 // if (c > 0) { 00627 // cerr << "- Duplicate nickname !! " << *eq << endl; 00628 // } else { 00629 // cerr << "(no duplicate) " << *eq << endl; 00630 // } 00631 // } 00632 00633 //cerr << "Documentator : end of calcEqnsNicknames\n---" << endl; 00634 }
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 985 of file doc.cpp.
References MAXIDCHARS, and subst().
Referenced by mapGetEqName().
00986 { 00987 char nb[MAXIDCHARS+1]; 00988 sprintf(nb, "%03d", i); 00989 return subst("$0$1", base, nb); 00990 }
static int cholddir | ( | ) | [static] |
Switch back to the previously stored current directory.
Definition at line 917 of file doc.cpp.
References gCurrentDir.
Referenced by openArchFile(), and printDoc().
00918 { 00919 if (chdir(gCurrentDir.c_str()) == 0) { 00920 return 0; 00921 } else { 00922 perror("cholddir"); 00923 exit(errno); 00924 } 00925 }
step 0. Feed doceqnInfosVector.
#0.
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 531 of file doc.cpp.
References doc, hd(), isDocEqn(), isList(), reverse(), and tl().
Referenced by prepareDocEqns().
00532 { 00533 int nbdoceqn = 0; 00534 00535 for (vector<Tree>::const_iterator doc=docBoxes.begin(); doc<docBoxes.end(); doc++) { 00536 Tree L = reverse(*doc); 00537 Tree expr; 00538 while (isList(L)) { 00539 if ( isDocEqn(hd(L), expr) ) { 00540 eqBoxes.push_back(expr); 00541 nbdoceqn++; 00542 } 00543 L = tl(L); 00544 } 00545 } 00546 //cerr << "Documentator : collectDocEqns : " << nbdoceqn << " <equation> tags found." << endl; 00547 }
step 7. Collect all signals in a superlist.
#7.
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 698 of file doc.cpp.
Referenced by prepareDocEqns().
00699 { 00700 //cerr << "###\n# Documentator : collectEqSigs" << endl; 00701 00702 superEqList = nil; 00703 00704 for( vector<Tree>::const_iterator it = eqSigs.begin(); it < eqSigs.end(); ++it ) { 00705 superEqList = cons( *it, superEqList ); 00706 } 00707 //printSignal(superEqList, stdout, 0); 00708 00709 //cerr << endl << "Documentator : end of collectEqSigs\n---" << endl; 00710 }
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 1015 of file doc.cpp.
References filebasename(), makedir(), and subst().
Referenced by printDoc().
01016 { 01017 string srcdir = subst("$0/src", projname); 01018 //cerr << "Documentator : copyFaustSources : Creating directory '" << srcdir << "'" << endl; 01019 makedir(srcdir.c_str()); // create a directory. 01020 01021 for (unsigned int i=0; i< pathnames.size(); i++) { 01022 ifstream src; 01023 ofstream dst; 01024 string faustfile = pathnames[i]; 01025 string copy = subst("$0/$1", srcdir, filebasename(faustfile.c_str())); 01026 //cerr << "Documentator : copyFaustSources : Opening input file '" << faustfile << "'" << endl; 01027 //cerr << "Documentator : copyFaustSources : Opening output file '" << copy << "'" << endl; 01028 src.open(faustfile.c_str(), ifstream::in); 01029 dst.open(copy.c_str(), ofstream::out); 01030 string s; 01031 while ( getline(src,s) ) dst << s << endl; 01032 } 01033 }
Tree docLst | ( | ) |
Tree docNtc | ( | ) |
Tree docTxt | ( | const char * | name | ) |
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 790 of file doc.cpp.
References getBoxType().
Referenced by mapPrepareEqSig().
00791 { 00792 if (!getBoxType(t, &numInputs, &numOutputs)) { 00793 cerr << "ERROR during the evaluation of t : " << boxpp(t) << endl; 00794 exit(1); 00795 } 00796 //cerr << "Documentator : " << numInputs <<" inputs and " << numOutputs <<" outputs for box : " << boxpp(t) << endl; 00797 }
static struct tm * getCompilationDate | ( | ) | [static, read] |
Definition at line 1047 of file doc.cpp.
References gCompilationDate, and initCompilationDate().
Referenced by printfaustdocstamp().
01048 { 01049 initCompilationDate(); 01050 return &gCompilationDate; 01051 }
static void getCurrentDir | ( | ) | [static] |
Get current directory and store it in gCurrentDir.
Definition at line 931 of file doc.cpp.
References FAUST_PATH_MAX, and gCurrentDir.
Referenced by openArchFile().
00932 { 00933 char buffer[FAUST_PATH_MAX]; 00934 gCurrentDir = getcwd (buffer, FAUST_PATH_MAX); 00935 }
static void initCompilationDate | ( | ) | [static] |
Definition at line 1039 of file doc.cpp.
References gCompilationDate.
Referenced by getCompilationDate().
01040 { 01041 time_t now; 01042 01043 time(&now); 01044 gCompilationDate = *localtime(&now); 01045 }
Definition at line 181 of file doc.cpp.
References isTree().
Referenced by collectDocEqns(), and printdoccontent().
bool isDocLst | ( | Tree | t | ) |
bool isDocNtc | ( | Tree | t | ) |
bool isDocTxt | ( | Tree | t0, | |
const char ** | str | |||
) |
Definition at line 168 of file doc.cpp.
References isSym(), isTree(), name(), and CTree::node().
00169 { 00170 Tree t1; Sym s; 00171 if ( isTree(t0, DOCTXT, t1) && isSym(t1->node(), &s) ) { 00172 *str = name(s); 00173 return true; 00174 } else { 00175 return false; 00176 } 00177 }
bool isDocTxt | ( | Tree | t | ) |
Definition at line 167 of file doc.cpp.
References 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 963 of file doc.cpp.
References getDefNameProperty(), and tree2str().
Referenced by printDocDgm().
00964 { 00965 Tree id; 00966 int i=0; 00967 if (getDefNameProperty(t, id)) { 00968 const char* src = tree2str(id); 00969 for (i=0; isalnum(src[i]) && i<16; i++) { 00970 dst[i] = src[i]; 00971 } 00972 } 00973 dst[i] = 0; 00974 if (strcmp(dst, "process") != 0) { 00975 // if it is not process add the hex address to make the name unique 00976 snprintf(&dst[i], n-i, "-%p", t); 00977 } 00978 return dst; 00979 }
static int makedir | ( | const char * | dirname | ) | [static] |
Create a new directory in the current one.
Definition at line 873 of file doc.cpp.
References FAUST_PATH_MAX, and gCurrentDir.
Referenced by copyFaustSources(), and printDoc().
00874 { 00875 char buffer[FAUST_PATH_MAX]; 00876 gCurrentDir = getcwd (buffer, FAUST_PATH_MAX); 00877 00878 if ( gCurrentDir.c_str() != 0) { 00879 int status = mkdir(dirname, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); 00880 if (status == 0 || errno == EEXIST) { 00881 return 0; 00882 } 00883 } 00884 perror("makedir"); 00885 exit(errno); 00886 }
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.
[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 742 of file doc.cpp.
References DocCompiler::compileLateq().
Referenced by prepareDocEqns().
00743 { 00744 //cerr << "###\n# Documentator : mapCompileDocEqnSigs" << endl; 00745 00746 for( unsigned int i=0; i < eqSigs.size(); i++ ) { 00747 00748 // docCompiledEqnsVector.push_back( DC->compileMultiSignal(*it, 0) ); 00749 docCompiledEqnsVector.push_back( DC->compileLateq(eqSigs[i], new Lateq(eqInputs[i], eqOutputs[i])) ); 00750 } 00751 00752 //cerr << "Documentator : end of mapCompileDocEqnSigs\n---" << endl; 00753 }
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).
[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 557 of file doc.cpp.
References evaldocexpr().
Referenced by prepareDocEqns().
00558 { 00559 //cerr << "###\n# Documentator : mapEvalDocEqn" << endl; 00560 00561 for ( vector<Tree>::const_iterator eq=eqBoxes.begin(); eq < eqBoxes.end(); eq++) 00562 { 00563 evalEqBoxes.push_back(evaldocexpr( *eq, env )); 00564 } 00565 //cerr << "Documentator : end of mapEvalDocEqn\n---" << endl; 00566 }
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.
[in] | evalEqBoxes | Evaluated box trees, eventually containing an equation name. |
[out] | eqNames | The place to store equations names. |
Definition at line 575 of file doc.cpp.
References calcNumberedName(), getBoxType(), getDefNameProperty(), and tree2str().
Referenced by prepareDocEqns().
00576 { 00577 //cerr << "###\n# Documentator : mapGetEqName" << endl; 00578 00579 int i = 1; 00580 for( vector<Tree>::const_iterator eq = evalEqBoxes.begin(); eq < evalEqBoxes.end(); eq++, i++ ) { 00581 Tree id; 00582 string s; 00583 int n,m; getBoxType(*eq, &n, &m); // eq name only for bd without inputs 00584 if ( n==0 && getDefNameProperty(*eq, id) ) { 00585 s = tree2str(id); 00586 } 00587 else { 00588 s = calcNumberedName("doceqn-", i); 00589 } 00590 eqNames.push_back( s ) ; 00591 } 00592 //cerr << "Documentator : end of mapGetEqName\n---" << endl; 00593 }
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.
[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 645 of file doc.cpp.
References boxPropagateSig(), deBruijn2Sym(), docTableConvertion(), getBoxInputsAndOutputs(), makeSigInputList(), nil, and simplify().
Referenced by prepareDocEqns().
00646 { 00647 //cerr << "###\n# Documentator : mapPrepareEqSig" << endl; 00648 00649 for( vector<Tree>::const_iterator eq = evalEqBoxes.begin(); eq < evalEqBoxes.end(); eq++ ) { 00650 00651 int numInputs, numOutputs; 00652 getBoxInputsAndOutputs(*eq, numInputs, numOutputs); 00653 //cerr << numInputs <<" ins and " << numOutputs <<" outs" << endl; 00654 eqInputs.push_back(numInputs); 00655 eqOutputs.push_back(numOutputs); 00656 00657 Tree lsig1 = boxPropagateSig( nil, *eq , makeSigInputList(numInputs) ); 00658 //cerr << "output signals are : " << endl; printSignal(lsig1, stderr); 00659 00660 Tree lsig2 = deBruijn2Sym(lsig1); 00661 Tree lsig3 = simplify(lsig2); 00662 //Tree lsig4 = privatise(lsig3); ///< Un-share tables with multiple writers 00663 Tree lsig4 = docTableConvertion(lsig3); 00664 00665 00666 eqSigs.push_back(lsig4); 00667 } 00668 //cerr << "Documentator : end of mapPrepareEqSig\n---" << endl; 00669 }
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 !
[in] | eqNicknames | Contains previously calculated nicknames. |
[out] | eqSigs | The signals to tag with a NICKNAMEPROPERTY. |
Definition at line 679 of file doc.cpp.
Referenced by prepareDocEqns().
00680 { 00681 //cerr << "###\n# Documentator : mapSetSigNickname" << endl; 00682 00683 // Do nothing for the moment... 00684 // for( unsigned int i=0; i < eqSigs.size(); i++ ) { 00685 // if (eqInputs[i] == 0) // Only "generators" should be finally named with user equation (nick)name. 00686 // setSigListNickName(eqSigs[i], eqNicknames[i]); 00687 // } 00688 //cerr << "Documentator : end of mapSetSigNickname\n---" << endl; 00689 }
static int mkchdir | ( | const char * | dirname | ) | [static] |
Create a new directory in the current one, then 'cd' into this new directory.
Definition at line 896 of file doc.cpp.
References FAUST_PATH_MAX, and gCurrentDir.
Referenced by printDoc().
00897 { 00898 char buffer[FAUST_PATH_MAX]; 00899 gCurrentDir = getcwd (buffer, FAUST_PATH_MAX); 00900 00901 if ( gCurrentDir.c_str() != 0) { 00902 int status = mkdir(dirname, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); 00903 if (status == 0 || errno == EEXIST) { 00904 if (chdir(dirname) == 0) { 00905 return 0; 00906 } 00907 } 00908 } 00909 perror("mkchdir"); 00910 exit(errno); 00911 }
static istream * openArchFile | ( | const string & | filename | ) | [static] |
Open architecture file.
Definition at line 941 of file doc.cpp.
References cholddir(), getCurrentDir(), and open_arch_stream().
Referenced by printDoc().
00942 { 00943 istream* file; 00944 getCurrentDir(); // Save the current directory. 00945 //cerr << "Documentator : openArchFile : Opening input file '" << filename << "'" << endl; 00946 if ( (file = open_arch_stream(filename.c_str())) ) { 00947 //cerr << "Documentator : openArchFile : Opening '" << filename << "'" << endl; 00948 } else { 00949 cerr << "ERROR : can't open architecture file " << filename << endl; 00950 exit(1); 00951 } 00952 cholddir(); // Return to current directory. 00953 return file; 00954 }
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 doceqnInfosVector.
< 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 505 of file doc.cpp.
References annotateSuperList(), calcEqnsNicknames(), collectDocEqns(), collectEqSigs(), mapCompileDocEqnSigs(), mapEvalDocEqn(), mapGetEqName(), mapPrepareEqSig(), and mapSetSigNickname().
Referenced by printdoccontent().
00506 { 00507 vector<Tree> eqBoxes; collectDocEqns( docBoxes, eqBoxes ); 00508 vector<Tree> evalEqBoxes; mapEvalDocEqn( eqBoxes, gExpandedDefList, evalEqBoxes ); 00509 vector<string> eqNames; mapGetEqName( evalEqBoxes, eqNames ); 00510 vector<string> eqNicknames; calcEqnsNicknames( eqNames, eqNicknames ); 00511 00512 vector<int> eqInputs; 00513 vector<int> eqOutputs; 00514 vector<Tree> eqSigs; mapPrepareEqSig( evalEqBoxes, eqInputs, eqOutputs, eqSigs ); 00515 mapSetSigNickname( eqNicknames, eqInputs, eqSigs ); 00516 Tree superEqList; collectEqSigs( eqSigs, superEqList ); 00517 00518 DocCompiler* DC = new DocCompiler(0, 0); 00519 annotateSuperList( DC, superEqList ); 00520 //calcAndSetLtqNames( superEqList ); ///< step 9. (directly in 10.) 00521 mapCompileDocEqnSigs( eqSigs, eqInputs, eqOutputs, DC, docCompiledEqnsVector ); 00522 }
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).
< Dynamic visible header (maketitle).
< Generate math contents (main stuff!).
< Static LaTeX footer.
Definition at line 216 of file doc.cpp.
References cholddir(), copyFaustSources(), declareAutoDoc(), gDocDevSuffix, gDocLang, gDocName, gDocVector, gLatexheaderfilename, SourceReader::listSrcFiles(), loadTranslationFile(), makedir(), mkchdir(), openArchFile(), printdoccontent(), printdocheader(), printfaustdocstamp(), printlatexfooter(), printlatexheader(), and subst().
Referenced by main().
00217 { 00218 gDocDevSuffix = docdev; 00219 00221 //cerr << "Documentator : printDoc : gFaustDirectory = '" << gFaustDirectory << "'" << endl; 00222 //cerr << "Documentator : printDoc : gFaustSuperDirectory = '" << gFaustSuperDirectory << "'" << endl; 00223 //cerr << "Documentator : printDoc : gFaustSuperSuperDirectory = '" << gFaustSuperSuperDirectory << "'" << endl; 00224 //cerr << "Documentator : printDoc : gCurrentDir = '" << gCurrentDir << "'" << endl; 00225 00226 makedir(projname); // create a top directory to store files 00227 00228 string svgTopDir = subst("$0/svg", projname); 00229 makedir(svgTopDir.c_str()); // create a directory to store svg-* subdirectories. 00230 00231 string cppdir = subst("$0/cpp", projname); 00232 makedir(cppdir.c_str()); // create a cpp directory. 00233 00234 string pdfdir = subst("$0/pdf", projname); 00235 makedir(pdfdir.c_str()); // create a pdf directory. 00236 00237 /* Copy all Faust source files into an 'src' sub-directory. */ 00238 vector<string> pathnames = gReader.listSrcFiles(); 00239 copyFaustSources(projname, pathnames); 00240 00241 string texdir = subst("$0/tex", projname); 00242 mkchdir(texdir.c_str()); // create a directory and move into. 00243 00245 ofstream docout(subst("$0.$1", gDocName, docdev).c_str()); 00246 cholddir(); // return to current directory 00247 00249 loadTranslationFile(gDocLang); 00250 00252 if (gDocVector.empty()) { declareAutoDoc(); } 00253 00255 printfaustdocstamp(faustversion, docout); 00256 istream* latexheader = openArchFile(gLatexheaderfilename); 00257 printlatexheader(*latexheader, docout); 00258 printdocheader(docout); 00259 printdoccontent(svgTopDir.c_str(), gDocVector, faustversion, docout); 00260 printlatexfooter(docout); 00261 00262 }
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 445 of file doc.cpp.
References CTree::branch(), doc, hd(), isDocDgm(), isDocEqn(), isDocLst(), isDocNtc(), isDocTxt(), isList(), prepareDocEqns(), printDocDgm(), printDocEqn(), printDocNotice(), printfaustlistings(), reverse(), and tl().
Referenced by printDoc().
00446 { 00447 //cerr << endl << "Documentator : printdoccontent : " << docVector.size() << " <mdoc> tags read." << endl; 00448 00450 vector<Lateq*> docCompiledEqnsVector; 00451 prepareDocEqns( docVector, docCompiledEqnsVector ); 00452 00453 vector<Lateq*>::iterator eqn_it = docCompiledEqnsVector.begin(); 00454 int i = 1; 00455 00457 for (vector<Tree>::const_iterator doc=docVector.begin(); doc<docVector.end(); doc++) { 00458 00459 Tree L = reverse(*doc); 00460 //cerr << "Entering into <mdoc> parsing..." << endl; 00461 00463 while (isList(L)) { 00464 Tree expr; 00465 if ( isDocEqn(hd(L), expr) ) { 00466 printDocEqn(*eqn_it++, docout); 00467 } 00468 else if ( isDocDgm(hd(L), expr) ) { 00469 printDocDgm(expr, svgTopDir, docout, i++); 00470 } 00471 else if ( isDocTxt(hd(L)) ) { 00472 docout << *hd(L)->branch(0) << endl; // Directly print registered doc text. 00473 } 00474 else if ( isDocNtc(hd(L)) ) { 00475 printDocNotice(faustversion, docout); 00476 } 00477 else if ( isDocLst(hd(L)) ) { 00478 printfaustlistings(docout); 00479 } 00480 else { 00481 cerr << "ERROR : " << *hd(L) << " is not a valid documentation type." << endl; 00482 } 00483 L = tl(L); 00484 } 00485 //cerr << " ...end of <mdoc> parsing." << endl; 00486 } 00487 }
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
[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 829 of file doc.cpp.
References drawSchema(), evaldocexpr(), gDocNoticeFlagMap, gErrorCount, legalFileName(), MAXIDCHARS, and subst().
Referenced by printdoccontent().
00830 { 00832 Tree docdgm = evaldocexpr(expr, gExpandedDefList); 00833 if (gErrorCount > 0) { 00834 cerr << "Total of " << gErrorCount << " errors during evaluation of : diagram docdgm = " << boxpp(docdgm) << ";\n"; 00835 exit(1); 00836 } 00837 00842 char dgmid[MAXIDCHARS+1]; 00843 sprintf(dgmid, "%02d", i); 00844 string thisdgmdir = subst("$0/svg-$1", svgTopDir, dgmid); 00845 //cerr << "Documentator : printDocDgm : drawSchema in '" << gCurrentDir << "/" << thisdgmdir << "'" << endl; 00846 00847 drawSchema( docdgm, thisdgmdir.c_str(), "svg" ); 00848 00850 char temp[1024]; 00851 const string dgmfilename = legalFileName(docdgm, 1024, temp); 00852 //docout << "figure \\ref{figure" << i << "}"; 00853 docout << "\\begin{figure}[ht!]" << endl; 00854 docout << "\t\\centering" << endl; 00855 docout << "\t\\includegraphics[width=\\textwidth]{" << subst("../svg/svg-$0/", dgmid) << dgmfilename << "}" << endl; 00856 docout << "\t\\caption{block-diagram of \\texttt{" << dgmfilename << "}}" << endl; 00857 docout << "\t\\label{figure" << i << "}" << endl; 00858 docout << "\\end{figure}" << endl << endl; 00859 00861 gDocNoticeFlagMap["nameconflicts"] = true; 00862 gDocNoticeFlagMap["svgdir"] = true; 00863 }
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 806 of file doc.cpp.
References Lateq::println().
Referenced by printdoccontent().
00807 { 00808 ltq->println(docout); 00809 //cerr << "Documentator : printDocEqn : "; ltq->println(cerr); cerr << endl; 00810 }
static void printdocheader | ( | ostream & | docout | ) | [static] |
Print the dynamic visible header, in a LaTeX "tabular" environment.
[out] | docout | The LaTeX output file to print into. |
< Default title.
< Default author.
Definition at line 287 of file doc.cpp.
References gDocMetadatasStringMap, gMetaDataSet, rmExternalDoubleQuotes(), tree(), tree2str(), and unquote().
Referenced by printDoc().
00288 { 00289 /* Defines the metadata we want to print as comments at the begin of the LaTeX file. */ 00290 set<Tree> selectedKeys; 00291 selectedKeys.insert(tree("name")); 00292 selectedKeys.insert(tree("author")); 00293 selectedKeys.insert(tree("copyright")); 00294 selectedKeys.insert(tree("license")); 00295 selectedKeys.insert(tree("version")); 00296 00297 string title = "Documentation"; 00298 if (gMetaDataSet.count(tree("name"))) { 00299 title = unquote( tree2str(*(gMetaDataSet[tree("name")].begin())) ); 00300 } 00301 docout << "\\title{" << title << "}" << endl; 00302 00303 string author = "(anonymous)"; 00304 if (gMetaDataSet.count(tree("author"))) { 00305 author = unquote( tree2str(*(gMetaDataSet[tree("author")].begin())) ); 00306 docout << "\\author{" << author << "}" << endl; 00307 } 00308 00309 docout << "\\date{\\today}" << endl << endl; 00310 docout << "\\maketitle" << endl << endl; 00311 00312 00313 if (! gMetaDataSet.empty()) { 00314 docout << "\\begin{tabular}{ll}" << endl; 00315 docout << "\t\\hline" << endl; 00316 for (map<Tree, set<Tree> >::iterator i = gMetaDataSet.begin(); i != gMetaDataSet.end(); i++) { 00317 if (selectedKeys.count(i->first)) { 00318 //docout << "\t\\textbf{" << *(i->first); 00319 docout << "\t\\textbf{" << gDocMetadatasStringMap[tree2str(i->first)]; 00320 const char* sep = "} & "; 00321 for (set<Tree>::iterator j = i->second.begin(); j != i->second.end(); j++) { 00322 docout << sep << rmExternalDoubleQuotes(tree2str(*j)); 00323 sep = ", "; 00324 } 00325 const char* sep2 = "\\\\"; 00326 docout << sep2 << endl; 00327 } 00328 } 00329 docout << "\t\\hline\\\\" << endl; 00330 docout << "\\end{tabular}" << endl; 00331 docout << "\\bigskip" << endl << endl; 00332 } 00333 }
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 413 of file doc.cpp.
References getCompilationDate().
Referenced by printDoc().
00414 { 00415 char datebuf [150]; 00416 strftime (datebuf, 150, "%c", getCompilationDate()); 00417 00418 docout << "%% This documentation was generated with Faust version " << faustversion << endl; 00419 docout << "%% " << datebuf << endl; 00420 docout << "%% http://faust.grame.fr" << endl << endl; 00421 }
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 360 of file doc.cpp.
References filebasename(), and gStripDocSwitch.
Referenced by printfaustlistings().
00361 { 00362 string s; 00363 ifstream src; 00364 00365 //cerr << "Documentator : printfaustlisting : Opening file '" << faustfile << "'" << endl; 00366 src.open(faustfile.c_str(), ifstream::in); 00367 00368 docout << endl << "\\bigskip\\bigskip" << endl; 00369 docout << "\\begin{lstlisting}[caption=\\texttt{" << filebasename(faustfile.c_str()) << "}]" << endl; 00370 00371 bool isInsideDoc = false; 00372 00373 if (faustfile != "" && src.good()) { 00374 while(getline(src, s)) { 00375 size_t foundopendoc = s.find("<mdoc>"); 00376 if (foundopendoc != string::npos && gStripDocSwitch) isInsideDoc = true; 00377 00378 if (isInsideDoc == false) 00379 docout << s << endl; 00380 00381 size_t foundclosedoc = s.find("</mdoc>"); 00382 if (foundclosedoc != string::npos && gStripDocSwitch) isInsideDoc = false; 00383 } 00384 } else { 00385 cerr << "ERROR : can't open faust source file " << faustfile << endl; 00386 exit(1); 00387 } 00388 00389 docout << "\\end{lstlisting}" << endl << endl; 00390 }
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 342 of file doc.cpp.
References SourceReader::listSrcFiles(), and printfaustlisting().
Referenced by printdoccontent().
00343 { 00344 vector<string> pathnames = gReader.listSrcFiles(); 00345 00346 /* Listings printing. */ 00347 for (unsigned int i=0; i< pathnames.size(); i++) { 00348 printfaustlisting(pathnames[i], docout); 00349 } 00350 }
static void printlatexfooter | ( | ostream & | docout | ) | [static] |
Print the static LaTeX footer.
[out] | docout | The LaTeX output file to print into. |
Definition at line 398 of file doc.cpp.
Referenced by printDoc().
static void printlatexheader | ( | istream & | latexheader, | |
ostream & | docout | |||
) | [static] |
Print a static LaTeX header.
[in] | latexheader | The file containing the static part of the LaTeX header. |
[out] | docout | The LaTeX output file to print into. |
Definition at line 276 of file doc.cpp.
Referenced by printDoc().
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 996 of file doc.cpp.
Referenced by printdocheader().
00997 { 00998 size_t i = s.find_first_not_of("\""); 00999 size_t j = s.find_last_not_of("\""); 01000 01001 if ( (i != string::npos) & (j != string::npos) ) { 01002 return s.substr(i, 1+j-i); 01003 } else { 01004 return ""; 01005 } 01006 }
struct tm gCompilationDate [static] |
Definition at line 110 of file doc.cpp.
Referenced by getCompilationDate(), and initCompilationDate().
string gCurrentDir [static] |
Room to save current directory name.
Definition at line 105 of file doc.cpp.
Referenced by cholddir(), getCurrentDir(), makedir(), and mkchdir().
bool gDetailsSwitch |
Definition at line 110 of file main.cpp.
Referenced by main(), and process_cmdline().
const char* gDocDevSuffix [static] |
".tex" (or .??? - used to choose output device).
Definition at line 104 of file doc.cpp.
Referenced by printDoc().
string gDocLang |
Definition at line 113 of file doc.cpp.
Referenced by printDoc(), and process_cmdline().
map<string, string> gDocMetadatasStringMap |
Definition at line 35 of file doc_metadatas.cpp.
Referenced by importDocStrings(), printdocheader(), and storePair().
string gDocName |
Contains the filename for out documentation.
Definition at line 103 of file main.cpp.
Referenced by initFaustDirectories(), and printDoc().
vector<Tree> gDocVector |
Contains <mdoc> parsed trees: DOCTXT, DOCEQN, DOCDGM.
Definition at line 108 of file doc.cpp.
Referenced by declareDoc(), and printDoc().
string gFaustDirectory |
Definition at line 99 of file main.cpp.
Referenced by fopensearch(), initFaustDirectories(), and open_arch_stream().
string gFaustSuperDirectory |
Definition at line 98 of file main.cpp.
Referenced by fopensearch(), initFaustDirectories(), and open_arch_stream().
string gFaustSuperSuperDirectory |
Definition at line 97 of file main.cpp.
Referenced by fopensearch(), initFaustDirectories(), and open_arch_stream().
const string gLatexheaderfilename = "latexheader.tex" [static] |
Definition at line 106 of file doc.cpp.
Referenced by printDoc().
string gMasterDocument |
Definition at line 100 of file main.cpp.
Referenced by declareMetadata(), initFaustDirectories(), and main().
map<Tree, set<Tree> > gMetaDataSet |
Definition at line 87 of file main.cpp.
Referenced by declareMetadata(), main(), printdocheader(), printheader(), Klass::println(), and Klass::printMetadata().
bool gStripDocSwitch |
Definition at line 117 of file main.cpp.
Referenced by printfaustlisting(), and process_cmdline().