| @@ -39,6 +39,7 @@ · 38 unmodified lines |
| 39 | 39 | #include "util_string.h" |
| 40 | 40 | |
| 41 | 41 | #include <string> |
| 42 | +#include <sstream> |
| 42 | 43 | #include <fstream> |
| 43 | 44 | #include <algorithm> |
| 44 | 45 | using namespace std; |
| @@ -192,7 +193,8 @@ DLL_QUERY ckdoc_query( Chuck_DL_Query * QUERY ) · 147 unmodified lines |
| 192 | 193 | // outputToDir |
| 193 | 194 | func = make_new_mfun( "int", "outputToDir", CKDoc_outputToDir ); |
| 194 | 195 | func->add_arg( "string", "path" ); |
| 195 | | − func->doc = "Generate everything as files into the output directory"; |
| 196 | + func->add_arg( "string", "indexTitle" ); |
| 197 | + func->doc = "Generate everything as files into the output directory."; |
| 196 | 198 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 197 | 199 | |
| 198 | 200 | // end the class import |
| @@ -208,17 +210,6 @@ error: · 9 unmodified lines |
| 208 | 210 | |
| 209 | 211 | |
| 210 | 212 | |
| 211 | | −//----------------------------------------------------------------------------- |
| 212 | | −// begin CKDoc implemention |
| 213 | | −//----------------------------------------------------------------------------- |
| 214 | | −std::string type2url( const std::string & type ) |
| 215 | | −{ |
| 216 | | − return "[type2url NOT IMPLEMENTED]"; |
| 217 | | −} |
| 218 | | − |
| 219 | | − |
| 220 | | − |
| 221 | | − |
| 222 | 213 | //----------------------------------------------------------------------------- |
| 223 | 214 | // name: struct CKDocGroup | 1.5.0.0 (ge, spencer) added |
| 224 | 215 | // desc: structure for a doc group e.g., "UGens" |
| @@ -238,6 +229,37 @@ struct CKDocGroup · 13 unmodified lines |
| 238 | 229 | |
| 239 | 230 | |
| 240 | 231 | |
| 232 | +//----------------------------------------------------------------------------- |
| 233 | +// name: type2url() |
| 234 | +// desc: convert type name to URL, using groups to detemine the file for each |
| 235 | +//----------------------------------------------------------------------------- |
| 236 | +string type2url( const string & type, const vector<CKDocGroup *> & groups ) |
| 237 | +{ |
| 238 | + // search |
| 239 | + for( t_CKINT i = 0; i < groups.size(); i++ ) |
| 240 | + { |
| 241 | + for( t_CKINT j = 0; j < groups[i]->types.size(); j++ ) |
| 242 | + { |
| 243 | + // check |
| 244 | + if( groups[i]->types[j] == NULL ) continue; |
| 245 | + // compare |
| 246 | + if( type == groups[i]->types[j]->name ) |
| 247 | + { |
| 248 | + // file + location within file: basically: 'group.html#type' |
| 249 | + return groups[i]->shortName + ".html#" + type; |
| 250 | + } |
| 251 | + } |
| 252 | + } |
| 253 | + |
| 254 | + // TODO: make a list of default classes on chuck website to link to |
| 255 | + // return "[type2url NOT IMPLEMENTED]"; |
| 256 | + return ""; |
| 257 | +} |
| 258 | + |
| 259 | + |
| 260 | + |
| 261 | + |
| 262 | + |
| 241 | 263 | //----------------------------------------------------------------------------- |
| 242 | 264 | // name: class CKDocHTMLOutput | 1.5.0.0 (ge, spencer) added |
| 243 | 265 | // desc: HTML output (based on Spencer's ckdoc) |
| @@ -257,12 +279,13 @@ public: · 13 unmodified lines |
| 257 | 279 | // get the env |
| 258 | 280 | m_env_ref = vm != NULL ? vm->env() : NULL; |
| 259 | 281 | } |
| 260 | | − |
| 261 | 282 | // file extension |
| 262 | 283 | virtual string fileExtension() const { return ".html"; } |
| 284 | + // render HTML index |
| 285 | + virtual string renderIndex( const string & indexTitle, const vector<CKDocGroup *> & groups ); |
| 263 | 286 | |
| 264 | 287 | public: |
| 265 | | − void begin( const std::string & title ) |
| 288 | + void begin( const string & title ) |
| 266 | 289 | { |
| 267 | 290 | // trim |
| 268 | 291 | m_title = trim(title); |
| @@ -323,9 +346,10 @@ public: · 54 unmodified lines |
| 323 | 346 | m_outputStr += "</div>\n"; |
| 324 | 347 | } |
| 325 | 348 | |
| 326 | | − void begin_classes() |
| 349 | + void begin_classes( CKDocGroup * group ) |
| 327 | 350 | { |
| 328 | 351 | m_outputStr += "<div class=\"classes\">\n"; |
| 352 | + m_outputStr += "<p class=\"group_desc\">" + group->desc + "</p>\n"; |
| 329 | 353 | } |
| 330 | 354 | |
| 331 | 355 | void end_classes() |
| @@ -333,7 +357,7 @@ public: · 1 unmodified line |
| 333 | 357 | m_outputStr += "</div>\n"; |
| 334 | 358 | } |
| 335 | 359 | |
| 336 | | − void begin_class(Chuck_Type * type) |
| 360 | + void begin_class(Chuck_Type * type, const vector<CKDocGroup *> & groups ) |
| 337 | 361 | { |
| 338 | 362 | m_outputStr += "<a name=\"" + type->name + "\" /><div class=\"class\">\n"; |
| 339 | 363 | m_outputStr += "<h2 class=\"class_title\" name=\"" + type->name + "\">" + type->name + "</h2>\n"; |
| @@ -341,11 +365,16 @@ public: · 1 unmodified line |
| 341 | 365 | // type heirarchy |
| 342 | 366 | Chuck_Type * parent = type->parent; |
| 343 | 367 | // check if there is a parent class |
| 344 | | − if( parent != NULL ) m_outputStr += "<h4 class=\"class_hierarchy\">"; |
| 368 | + if( parent != NULL ) |
| 369 | + { |
| 370 | + m_outputStr += "<h4>"; |
| 371 | + m_outputStr += "<span class=\"class_inherits\">inherits</span> "; |
| 372 | + // m_outputStr += "<h4 class=\"class_hierarchy\">"; |
| 373 | + } |
| 345 | 374 | // iterate over parents |
| 346 | 375 | while( parent != NULL ) |
| 347 | 376 | { |
| 348 | | − m_outputStr += ": <a href=\"" + type2url(parent->name) |
| 377 | + m_outputStr += ": <a href=\"" + type2url(parent->name, groups) |
| 349 | 378 | + "\" class=\"" + css_class_for_type(m_env_ref, parent) |
| 350 | 379 | + "\">" + parent->name + "</a> ", |
| 351 | 380 | // go up the inheritance chain |
| @@ -356,11 +385,7 @@ public: · 4 unmodified lines |
| 356 | 385 | |
| 357 | 386 | if(type->doc.size() > 0) |
| 358 | 387 | { |
| 359 | | − std::string doc; |
| 360 | | − // if( m_doc_text_filter ) |
| 361 | | − // doc = m_doc_text_filter->filter(type->doc); |
| 362 | | − // else |
| 363 | | − doc = type->doc; |
| 388 | + std::string doc = capitalize(type->doc); |
| 364 | 389 | m_outputStr += "<p class=\"class_description\">" + doc + "<p>\n"; |
| 365 | 390 | } |
| 366 | 391 | else |
| @@ -447,7 +472,7 @@ public: · 80 unmodified lines |
| 447 | 472 | m_outputStr += "<span class=\"membername\">" + var->name + "</span></p>"; |
| 448 | 473 | |
| 449 | 474 | if(var->doc.size() > 0) |
| 450 | | − m_outputStr += "<p class=\"member_description\">" + var->doc + "</p>\n"; |
| 475 | + m_outputStr += "<p class=\"member_description\">" + capitalize(var->doc) + "</p>\n"; |
| 451 | 476 | else |
| 452 | 477 | m_outputStr += "<p class=\"empty_member_description\">No description available</p>\n"; |
| 453 | 478 | |
| @@ -466,13 +491,13 @@ public: · 12 unmodified lines |
| 466 | 491 | for(int i = 0; i < var->type->array_depth; i++) |
| 467 | 492 | m_outputStr += "[]"; |
| 468 | 493 | } |
| 469 | | − m_outputStr += "</span>"; |
| 494 | + m_outputStr += "</span> "; |
| 470 | 495 | |
| 471 | 496 | // function name |
| 472 | 497 | m_outputStr += "<span class=\"membername\">" + var->name + "</span></p>"; |
| 473 | 498 | |
| 474 | 499 | if(var->doc.size() > 0) |
| 475 | | − m_outputStr += "<p class=\"member_description\">" + var->doc + "</p>\n"; |
| 500 | + m_outputStr += "<p class=\"member_description\">" + capitalize(var->doc) + "</p>\n"; |
| 476 | 501 | else |
| 477 | 502 | m_outputStr += "<p class=\"empty_member_description\">No description available</p>\n"; |
| 478 | 503 | |
| @@ -506,7 +531,7 @@ public: · 27 unmodified lines |
| 506 | 531 | m_outputStr += ")</p>\n"; |
| 507 | 532 | |
| 508 | 533 | if(m_func->doc.size() > 0) |
| 509 | | − m_outputStr += "<p class=\"member_description\">" + m_func->doc + "</p>\n"; |
| 534 | + m_outputStr += "<p class=\"member_description\">" + capitalize(m_func->doc) + "</p>\n"; |
| 510 | 535 | else |
| 511 | 536 | m_outputStr += "<p class=\"empty_member_description\">No description available</p>\n"; |
| 512 | 537 | |
| @@ -542,7 +567,7 @@ public: · 29 unmodified lines |
| 542 | 567 | m_outputStr += ")</p>\n"; |
| 543 | 568 | |
| 544 | 569 | if(m_func->doc.size() > 0) |
| 545 | | − m_outputStr += "<p class=\"member_description\">" + m_func->doc + "</p>\n"; |
| 570 | + m_outputStr += "<p class=\"member_description\">" + capitalize(m_func->doc) + "</p>\n"; |
| 546 | 571 | else |
| 547 | 572 | m_outputStr += "<p class=\"empty_member_description\">No description available</p>\n"; |
| 548 | 573 | |
| @@ -596,17 +621,73 @@ public: · 47 unmodified lines |
| 596 | 621 | static std::string css_class_for_type( Chuck_Env * env, Chuck_Type * type ) |
| 597 | 622 | { |
| 598 | 623 | if( isprim(env, type) || isvoid(env, type) || (type->array_depth && isprim(env, type->array_type)) ) |
| 599 | | − return "ckdoc_typename ckdoc_primitive_type"; |
| 624 | + return "ckdoc_typename ckdoc_type_primitive"; |
| 600 | 625 | else if(isugen(type)) |
| 601 | | − return "ckdoc_typename ckdoc_ugen_type"; |
| 626 | + return "ckdoc_typename ckdoc_type_ugen"; |
| 602 | 627 | else |
| 603 | | − return "ckdoc_typename ckdoc_object_type"; |
| 628 | + return "ckdoc_typename ckdoc_type_object"; |
| 604 | 629 | } |
| 605 | 630 | }; |
| 606 | 631 | |
| 607 | 632 | |
| 608 | 633 | |
| 609 | 634 | |
| 635 | +//----------------------------------------------------------------------------- |
| 636 | +// name: renderIndex() |
| 637 | +// desc: render HTML index |
| 638 | +//----------------------------------------------------------------------------- |
| 639 | +string CKDocHTMLOutput::renderIndex( const string & title, const vector<CKDocGroup *> & groups ) |
| 640 | +{ |
| 641 | + // output string stream |
| 642 | + ostringstream sout; |
| 643 | + |
| 644 | + // output index header |
| 645 | + sout << "<html>\n<head>\n"; |
| 646 | + sout << "<title>" << title << "</title>\n"; |
| 647 | + sout << "<link rel=\"stylesheet\" type=\"text/css\" href=\"ckdoc.css\" />\n"; |
| 648 | + sout << "<link rel=\"stylesheet\" type=\"text/css\" href=\"class.css\" />\n"; |
| 649 | + sout << "</head>\n"; |
| 650 | + sout << "<body>\n"; |
| 651 | + sout << "<div id=\"title\">\n"; |
| 652 | + sout << "<div class=\"titleL\"><h1>" << title << "</h1></div>\n"; |
| 653 | + sout << "<div class=\"titleR\"><h1> </h1></div>\n"; |
| 654 | + sout << "</div>\n"; |
| 655 | + sout << "<div id=\"body\">\n"; |
| 656 | + |
| 657 | + // loop over groups |
| 658 | + for( t_CKINT i = 0; i < groups.size(); i++ ) |
| 659 | + { |
| 660 | + CKDocGroup * group = groups[i]; |
| 661 | + sout << "<div class=\"index_group\">\n"; |
| 662 | + sout << "<div class=\"index_group_title\">\n"; |
| 663 | + sout << "<h2><a href=\"" << group->shortName << ".html\">" << group->name << "</a></h2>\n"; |
| 664 | + sout << "<p class=\"index_group_desc\">" << group->desc << "</p>\n"; |
| 665 | + sout << "</div>\n"; |
| 666 | + sout << "<div class=\"index_group_classes\">\n"; |
| 667 | + sout << "<p>\n"; |
| 668 | + |
| 669 | + for( t_CKINT j = 0; j < group->types.size(); j++ ) |
| 670 | + { |
| 671 | + Chuck_Type * type = group->types[j]; |
| 672 | + if( !type ) continue; |
| 673 | + string cssClass = css_class_for_type( m_env_ref, type ); |
| 674 | + // TODO: check for array_depth |
| 675 | + sout << "<a href=\"" << group->shortName << ".html#" << type->name << "\" class=\"" << cssClass << "\">" << type->name << "</a>\n"; |
| 676 | + } |
| 677 | + sout << "</p>\n"; |
| 678 | + sout << "</div>\n"; |
| 679 | + sout << "<div class=\"clear\"></div>\n"; |
| 680 | + sout << "</div>\n"; |
| 681 | + } |
| 682 | + sout << "</div>\n"; |
| 683 | + sout << "</body>\n</html>\n"; |
| 684 | + |
| 685 | + // return the string literal |
| 686 | + return sout.str(); |
| 687 | +}; |
| 688 | + |
| 689 | + |
| 690 | + |
| 610 | 691 | //----------------------------------------------------------------------------- |
| 611 | 692 | // name: CKDoc() |
| 612 | 693 | // desc: constructor |
| @@ -848,10 +929,12 @@ string CKDoc::getExamplesRoot() const · 235 unmodified lines |
| 848 | 929 | // name: genIndex() |
| 849 | 930 | // desc: generate top-level index file; return as string |
| 850 | 931 | //----------------------------------------------------------------------------- |
| 851 | | −string CKDoc::genIndex() |
| 932 | +string CKDoc::genIndex( const string & title ) |
| 852 | 933 | { |
| 853 | | − // return the string literal |
| 854 | | − return ""; |
| 934 | + // check |
| 935 | + if( !m_output ) return ""; |
| 936 | + // generate index |
| 937 | + return m_output->renderIndex( title, m_groups ); |
| 855 | 938 | } |
| 856 | 939 | |
| 857 | 940 | |
| @@ -896,7 +979,7 @@ void CKDoc::genGroups( vector<string> & results ) · 38 unmodified lines |
| 896 | 979 | for( t_CKINT i = 0; i < m_groups.size(); i++ ) |
| 897 | 980 | { |
| 898 | 981 | // generate each group |
| 899 | | − results[i] = genGroup( m_groups[i], FALSE ); |
| 982 | + results[i] = genGroup( m_groups[i], TRUE ); |
| 900 | 983 | } |
| 901 | 984 | } |
| 902 | 985 | |
| @@ -951,7 +1034,7 @@ string CKDoc::genGroup( CKDocGroup * group, t_CKBOOL clearOutput ) · 48 unmodified lines |
| 951 | 1034 | } |
| 952 | 1035 | |
| 953 | 1036 | // begin type contents |
| 954 | | − output->begin_classes(); |
| 1037 | + output->begin_classes( group ); |
| 955 | 1038 | |
| 956 | 1039 | // iterate |
| 957 | 1040 | for( vector<Chuck_Type *>::const_iterator t = group->types.begin(); t != group->types.end(); t++ ) |
| @@ -991,7 +1074,7 @@ string CKDoc::genType( Chuck_Type * type, t_CKBOOL clearOutput ) · 33 unmodified lines |
| 991 | 1074 | if( clearOutput ) output->clear(); |
| 992 | 1075 | |
| 993 | 1076 | // begin the type |
| 994 | | − output->begin_class( type ); |
| 1077 | + output->begin_class( type, m_groups ); |
| 995 | 1078 | |
| 996 | 1079 | // output examples |
| 997 | 1080 | if( type->examples.size() ) |
| @@ -1190,7 +1273,7 @@ string CKDoc::genType( Chuck_Type * type, t_CKBOOL clearOutput ) · 192 unmodified lines |
| 1190 | 1273 | // name: outputToDir() |
| 1191 | 1274 | // desc: generate everything as files into the output directory |
| 1192 | 1275 | //----------------------------------------------------------------------------- |
| 1193 | | −t_CKBOOL CKDoc::outputToDir( const string & outputDir ) |
| 1276 | +t_CKBOOL CKDoc::outputToDir( const string & outputDir, const string & indexTitle ) |
| 1194 | 1277 | { |
| 1195 | 1278 | // groups content |
| 1196 | 1279 | vector<string> groupOutput; |
| @@ -1204,7 +1287,7 @@ t_CKBOOL CKDoc::outputToDir( const string & outputDir ) · 7 unmodified lines |
| 1204 | 1287 | m_output->clear(); |
| 1205 | 1288 | |
| 1206 | 1289 | // gen index |
| 1207 | | − if( !outputToFile( path + "index" + m_output->fileExtension(), genIndex() ) ) goto error; |
| 1290 | + if( !outputToFile( path + "index" + m_output->fileExtension(), genIndex( indexTitle ) ) ) goto error; |
| 1208 | 1291 | // gen CSS |
| 1209 | 1292 | if( !outputToFile( path + "ckdoc.css", genCSS() ) ) goto error; |
| 1210 | 1293 | // gen groups |
| @@ -1503,8 +1586,13 @@ CK_DLL_MFUN( CKDoc_outputToDir ) · 292 unmodified lines |
| 1503 | 1586 | { |
| 1504 | 1587 | CKDoc * ckdoc = (CKDoc *)OBJ_MEMBER_UINT(SELF, CKDoc_offset_data); |
| 1505 | 1588 | Chuck_String * path = GET_NEXT_STRING(ARGS); |
| 1589 | + Chuck_String * indexTitle = GET_NEXT_STRING(ARGS); |
| 1506 | 1590 | // the path as c++ string |
| 1507 | 1591 | string thePath; |
| 1592 | + string theTitle; |
| 1593 | + |
| 1594 | + // check |
| 1595 | + theTitle = indexTitle != NULL ? indexTitle->str() : ""; |
| 1508 | 1596 | |
| 1509 | 1597 | // check if null |
| 1510 | 1598 | if( path == NULL ) { |
| @@ -1515,7 +1603,7 @@ CK_DLL_MFUN( CKDoc_outputToDir ) · 4 unmodified lines |
| 1515 | 1603 | } |
| 1516 | 1604 | |
| 1517 | 1605 | // output |
| 1518 | | − ckdoc->outputToDir( thePath ); |
| 1606 | + ckdoc->outputToDir( thePath, theTitle ); |
| 1519 | 1607 | } |
| 1520 | 1608 | |
| 1521 | 1609 | |
| @@ -1564,6 +1652,15 @@ string CKDoc::m_ckdocCSS = "\ · 42 unmodified lines |
| 1564 | 1652 | margin-right: 0.5em;\n\ |
| 1565 | 1653 | line-height: 1.5em;\n\ |
| 1566 | 1654 | }\n\ |
| 1655 | + .index_group_desc\n\ |
| 1656 | + {\n\ |
| 1657 | + color:#555;\n\ |
| 1658 | + }\n\ |
| 1659 | + \n\ |
| 1660 | + .group_desc\n\ |
| 1661 | + {\n\ |
| 1662 | + color:#000;\n\ |
| 1663 | + }\n\ |
| 1567 | 1664 | \n\ |
| 1568 | 1665 | .index_group_title a { color: black; }\n\ |
| 1569 | 1666 | \n\ |
| @@ -1612,7 +1709,7 @@ string CKDoc::m_ckdocCSS = "\ · 42 unmodified lines |
| 1612 | 1709 | background-color: #eee;\n\ |
| 1613 | 1710 | padding: 0.25em 0.5em 1em 0.75em;\n\ |
| 1614 | 1711 | margin: 0;\n\ |
| 1615 | | − width: 6em;\n\ |
| 1712 | + width: 9.5em;\n\ |
| 1616 | 1713 | }\n\ |
| 1617 | 1714 | \n\ |
| 1618 | 1715 | .toc_class\n\ |
| @@ -1625,7 +1722,7 @@ string CKDoc::m_ckdocCSS = "\ · 6 unmodified lines |
| 1625 | 1722 | .classes\n\ |
| 1626 | 1723 | {\n\ |
| 1627 | 1724 | clear: right;\n\ |
| 1628 | | − margin-left: 9em;\n\ |
| 1725 | + margin-left: 12em;\n\ |
| 1629 | 1726 | margin-right: 0em;\n\ |
| 1630 | 1727 | }\n\ |
| 1631 | 1728 | \n\ |
| @@ -1640,12 +1737,16 @@ string CKDoc::m_ckdocCSS = "\ · 8 unmodified lines |
| 1640 | 1737 | font-family: Menlo, Monaco, Courier;\n\ |
| 1641 | 1738 | font-size: 18px;\n\ |
| 1642 | 1739 | }\n\ |
| 1740 | + .class_inherits\n\ |
| 1741 | + {\n\ |
| 1742 | + font-weight: normal;\n\ |
| 1743 | + }\n\ |
| 1643 | 1744 | \n\ |
| 1644 | 1745 | .class_hierarchy\n\ |
| 1645 | 1746 | {\n\ |
| 1646 | 1747 | font-family: Menlo, Monaco, Courier;\n\ |
| 1647 | 1748 | font-size: 14px;\n\ |
| 1648 | | − margin-right: 4em;\n\ |
| 1749 | + /* margin-right: 4em; */ \n\ |
| 1649 | 1750 | }\n\ |
| 1650 | 1751 | \n\ |
| 1651 | 1752 | .class_section_header\n\ |