|
FAUST compiler
0.9.9.6b8
|
00001 /************************************************************************ 00002 ************************************************************************ 00003 FAUST compiler 00004 Copyright (C) 2003-2004 GRAME, Centre National de Creation Musicale 00005 --------------------------------------------------------------------- 00006 This program is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 2 of the License, or 00009 (at your option) any later version. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program; if not, write to the Free Software 00018 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00019 ************************************************************************ 00020 ************************************************************************/ 00021 00022 00023 #include <iostream> 00024 #include <string> 00025 #include <set> 00026 #include <map> 00027 #include <cstdlib> 00028 00029 #include "doc_autodoc.hh" 00030 #include "tlib.hh" 00031 #include "boxes.hh" 00032 #include "doc.hh" 00033 00034 00035 extern SourceReader gReader; 00036 extern string gDocName; 00037 extern map<Tree, set<Tree> > gMetaDataSet; 00038 extern map<string, string> gDocMetadatasStringMap; 00039 00040 map<string, string> gDocAutodocStringMap; 00041 set<string> gDocAutodocKeySet; 00042 00043 static void initDocAutodocKeySet(); 00044 00045 00046 00047 00048 /***************************************************************************** 00049 Public functions 00050 *****************************************************************************/ 00051 00052 00061 void declareAutoDoc() 00062 { 00063 Tree autodoc = nil; 00064 Tree process = boxIdent("process"); 00065 00070 autodoc = cons(docTxt("\\title{"), autodoc); 00071 if (gMetaDataSet.count(tree("name"))) { 00072 autodoc = cons(docMtd(tree("name")), autodoc); 00073 } else { 00074 autodoc = cons(docTxt(gDocName.c_str()), autodoc); 00075 } 00076 autodoc = cons(docTxt("}\n"), autodoc); 00077 00080 if (gMetaDataSet.count(tree("author"))) { 00081 autodoc = cons(docTxt("\\author{"), autodoc); 00082 autodoc = cons(docMtd(tree("author")), autodoc); 00083 autodoc = cons(docTxt("}\n"), autodoc); 00084 } 00085 00088 autodoc = cons(docTxt("\\date{"), autodoc); 00089 if (gMetaDataSet.count(tree("date"))) { 00090 autodoc = cons(docMtd(tree("date")), autodoc); 00091 } else { 00092 autodoc = cons(docTxt("\\today"), autodoc); 00093 } 00094 autodoc = cons(docTxt("}\n"), autodoc); 00095 00097 autodoc = cons(docTxt("\\maketitle\n"), autodoc); 00098 00099 00101 if (! gMetaDataSet.empty()) { 00102 autodoc = cons(docTxt("\\begin{tabular}{ll}\n"), autodoc); 00103 autodoc = cons(docTxt("\t\\hline\n"), autodoc); 00104 for (map<Tree, set<Tree> >::iterator i = gMetaDataSet.begin(); i != gMetaDataSet.end(); i++) { 00105 string mtdkey = tree2str(i->first); 00106 string mtdTranslatedKey = gDocMetadatasStringMap[mtdkey]; 00107 if (mtdTranslatedKey.empty()) { 00108 mtdTranslatedKey = mtdkey; 00109 } 00110 autodoc = cons(docTxt("\t\\textbf{"), autodoc); 00111 autodoc = cons(docTxt(mtdTranslatedKey.c_str()), autodoc); 00112 autodoc = cons(docTxt("} & "), autodoc); 00113 autodoc = cons(docMtd(tree(mtdkey.c_str())), autodoc); 00114 autodoc = cons(docTxt(" \\\\\n"), autodoc); 00115 } 00116 autodoc = cons(docTxt("\t\\hline\n"), autodoc); 00117 autodoc = cons(docTxt("\\end{tabular}\n"), autodoc); 00118 autodoc = cons(docTxt("\\bigskip\n"), autodoc); 00119 } 00120 00121 00124 string autoPresentationTxt = "\n\\bigskip\n" + gDocAutodocStringMap["thisdoc"] + "\n\n"; 00125 autodoc = cons(docTxt(autoPresentationTxt.c_str()), autodoc); 00126 00127 string autoEquationTxt = "\n" + gDocAutodocStringMap["autoeqntitle"] + "\n\n"; 00128 autoEquationTxt += gDocAutodocStringMap["autoeqntext"] + "\n"; 00129 autodoc = cons(docTxt(autoEquationTxt.c_str()), autodoc); 00130 autodoc = cons(docEqn(process), autodoc); 00131 00132 string autoDiagramTxt = "\n" + gDocAutodocStringMap["autodgmtitle"] + "\n\n"; 00133 autoDiagramTxt += gDocAutodocStringMap["autodgmtext"] + "\n"; 00134 autodoc = cons(docTxt(autoDiagramTxt.c_str()), autodoc); 00135 autodoc = cons(docDgm(process), autodoc); 00136 00137 string autoNoticeTxt = "\n" + gDocAutodocStringMap["autontctitle"] + "\n\n"; 00138 // autoNoticeTxt += gDocAutodocStringMap["autontctext"] + "\n"; 00139 autodoc = cons(docTxt(autoNoticeTxt.c_str()), autodoc); 00140 autodoc = cons(docNtc(), autodoc); 00141 00142 string autoListingTxt; 00143 vector<string> pathnames = gReader.listSrcFiles(); 00144 if(pathnames.size() > 1) { 00145 autoListingTxt = "\n" + gDocAutodocStringMap["autolsttitle2"] + "\n\n"; 00146 autoListingTxt += gDocAutodocStringMap["autolsttext2"] + "\n"; 00147 } else { 00148 autoListingTxt = "\n" + gDocAutodocStringMap["autolsttitle1"] + "\n\n"; 00149 autoListingTxt += gDocAutodocStringMap["autolsttext1"] + "\n"; 00150 } 00151 autodoc = cons(docTxt(autoListingTxt.c_str()), autodoc); 00152 autodoc = cons(docLst(), autodoc); 00153 00154 declareDoc(autodoc); 00155 } 00156 00157 00161 void initDocAutodoc() 00162 { 00163 initDocAutodocKeySet(); 00164 } 00165 00166 00167 00168 /***************************************************************************** 00169 Static functions 00170 *****************************************************************************/ 00171 00172 00176 static void initDocAutodocKeySet() { 00177 00178 gDocAutodocKeySet.insert("thisdoc"); 00179 00180 gDocAutodocKeySet.insert("autoeqntitle"); 00181 gDocAutodocKeySet.insert("autoeqntext"); 00182 00183 gDocAutodocKeySet.insert("autodgmtitle"); 00184 gDocAutodocKeySet.insert("autodgmtext"); 00185 00186 gDocAutodocKeySet.insert("autontctitle"); 00187 gDocAutodocKeySet.insert("autontctext"); 00188 00189 gDocAutodocKeySet.insert("autolsttitle1"); 00190 gDocAutodocKeySet.insert("autolsttext1"); 00191 00192 gDocAutodocKeySet.insert("autolsttitle2"); 00193 gDocAutodocKeySet.insert("autolsttext2"); 00194 } 00195 00196 00200 static void printDocAutodocStringMapContent() { 00201 bool trace = false; 00202 if(trace) { 00203 cout << "gDocAutodocStringMap.size() = " << gDocAutodocStringMap.size() << endl; 00204 map<string,string>::iterator it; 00205 int i = 1; 00206 for(it = gDocAutodocStringMap.begin(); it!=gDocAutodocStringMap.end(); ++it) 00207 cout << i++ << ".\tgDocNoticeStringMap[" << it->first << "] \t= '" << it->second << "'" << endl; 00208 } 00209 } 00210
1.8.0