History

ckdoc generate index.html plus several enhancements (spencer + ge)

Ge Wang committed 3 years ago

Commit ff084df1 parent cd9bf567 files · +217 −63Browse files

Unified · Split

7 files
  1. src/core/chuck_type.cpp +0 −14
  2. src/core/ulib_doc.cpp +144 −43
  3. src/core/ulib_doc.h +6 −4
  4. src/core/util_string.cpp +18 −0
  5. src/core/util_string.h +2 −0
  6. src/scripts/ckdoc/test-all.ck +22 −2
  7. src/scripts/ckdoc/test-class.ck +25 −0
src/core/chuck_type.cpp+0−14
@@ -7132,20 +7132,6 @@ static bool comp_value( Chuck_Value * a, Chuck_Value * b ) · 7131 unmodified lines
7132 else return a->name > b->name;7132 else return a->name > b->name;
7133}7133}
7134 7134
7135//-----------------------------------------------------------------------------
7136// capitalize first character
7137//-----------------------------------------------------------------------------
7138static string capitalize( const string & s )
7139{
7140 // copy
7141 string retval = s;
7142 // if not empty and first character is a lower-case letter
7143 if( retval.length() > 0 && retval[0] >= 'a' && retval[0] <= 'z' )
7144 retval[0] -= 32;
7145 // done
7146 return retval;
7147}
7148
7149 7135
7150 7136
7151 7137
src/core/ulib_doc.cpp+144−43
@@ -39,6 +39,7 @@ · 38 unmodified lines
39#include "util_string.h"39#include "util_string.h"
40 40
41#include <string>41#include <string>
42#include <sstream>
42#include <fstream>43#include <fstream>
43#include <algorithm>44#include <algorithm>
44using namespace std;45using namespace std;
@@ -192,7 +193,8 @@ DLL_QUERY ckdoc_query( Chuck_DL_Query * QUERY ) · 147 unmodified lines
192 // outputToDir193 // outputToDir
193 func = make_new_mfun( "int", "outputToDir", CKDoc_outputToDir );194 func = make_new_mfun( "int", "outputToDir", CKDoc_outputToDir );
194 func->add_arg( "string", "path" );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 if( !type_engine_import_mfun( env, func ) ) goto error;198 if( !type_engine_import_mfun( env, func ) ) goto error;
197 199
198 // end the class import200 // end the class import
@@ -208,17 +210,6 @@ error: · 9 unmodified lines
208 210
209 211
210 212
211//-----------------------------------------------------------------------------
212// begin CKDoc implemention
213//-----------------------------------------------------------------------------
214std::string type2url( const std::string & type )
215{
216 return "[type2url NOT IMPLEMENTED]";
217}
218
219
220
221
222//-----------------------------------------------------------------------------213//-----------------------------------------------------------------------------
223// name: struct CKDocGroup | 1.5.0.0 (ge, spencer) added214// name: struct CKDocGroup | 1.5.0.0 (ge, spencer) added
224// desc: structure for a doc group e.g., "UGens"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//-----------------------------------------------------------------------------
236string 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// name: class CKDocHTMLOutput | 1.5.0.0 (ge, spencer) added264// name: class CKDocHTMLOutput | 1.5.0.0 (ge, spencer) added
243// desc: HTML output (based on Spencer's ckdoc)265// desc: HTML output (based on Spencer's ckdoc)
@@ -257,12 +279,13 @@ public: · 13 unmodified lines
257 // get the env279 // get the env
258 m_env_ref = vm != NULL ? vm->env() : NULL;280 m_env_ref = vm != NULL ? vm->env() : NULL;
259 }281 }
260
261 // file extension282 // file extension
262 virtual string fileExtension() const { return ".html"; }283 virtual string fileExtension() const { return ".html"; }
284 // render HTML index
285 virtual string renderIndex( const string & indexTitle, const vector<CKDocGroup *> & groups );
263 286
264public:287public:
265 void begin( const std::string & title )288 void begin( const string & title )
266 {289 {
267 // trim290 // trim
268 m_title = trim(title);291 m_title = trim(title);
@@ -323,9 +346,10 @@ public: · 54 unmodified lines
323 m_outputStr += "</div>\n";346 m_outputStr += "</div>\n";
324 }347 }
325 348
326 void begin_classes()349 void begin_classes( CKDocGroup * group )
327 {350 {
328 m_outputStr += "<div class=\"classes\">\n";351 m_outputStr += "<div class=\"classes\">\n";
352 m_outputStr += "<p class=\"group_desc\">" + group->desc + "</p>\n";
329 }353 }
330 354
331 void end_classes()355 void end_classes()
@@ -333,7 +357,7 @@ public: · 1 unmodified line
333 m_outputStr += "</div>\n";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 m_outputStr += "<a name=\"" + type->name + "\" /><div class=\"class\">\n";362 m_outputStr += "<a name=\"" + type->name + "\" /><div class=\"class\">\n";
339 m_outputStr += "<h2 class=\"class_title\" name=\"" + type->name + "\">" + type->name + "</h2>\n";363 m_outputStr += "<h2 class=\"class_title\" name=\"" + type->name + "\">" + type->name + "</h2>\n";
@@ -341,11 +365,16 @@ public: · 1 unmodified line
341 // type heirarchy365 // type heirarchy
342 Chuck_Type * parent = type->parent;366 Chuck_Type * parent = type->parent;
343 // check if there is a parent class367 // 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 // iterate over parents374 // iterate over parents
346 while( parent != NULL )375 while( parent != NULL )
347 {376 {
348 m_outputStr += ": <a href=\"" + type2url(parent->name)377 m_outputStr += ": <a href=\"" + type2url(parent->name, groups)
349 + "\" class=\"" + css_class_for_type(m_env_ref, parent)378 + "\" class=\"" + css_class_for_type(m_env_ref, parent)
350 + "\">" + parent->name + "</a> ",379 + "\">" + parent->name + "</a> ",
351 // go up the inheritance chain380 // go up the inheritance chain
@@ -356,11 +385,7 @@ public: · 4 unmodified lines
356 385
357 if(type->doc.size() > 0)386 if(type->doc.size() > 0)
358 {387 {
359 std::string doc;388 std::string doc = capitalize(type->doc);
360 // if( m_doc_text_filter )
361 // doc = m_doc_text_filter->filter(type->doc);
362 // else
363 doc = type->doc;
364 m_outputStr += "<p class=\"class_description\">" + doc + "<p>\n";389 m_outputStr += "<p class=\"class_description\">" + doc + "<p>\n";
365 }390 }
366 else391 else
@@ -447,7 +472,7 @@ public: · 80 unmodified lines
447 m_outputStr += "<span class=\"membername\">" + var->name + "</span></p>";472 m_outputStr += "<span class=\"membername\">" + var->name + "</span></p>";
448 473
449 if(var->doc.size() > 0)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 else476 else
452 m_outputStr += "<p class=\"empty_member_description\">No description available</p>\n";477 m_outputStr += "<p class=\"empty_member_description\">No description available</p>\n";
453 478
@@ -466,13 +491,13 @@ public: · 12 unmodified lines
466 for(int i = 0; i < var->type->array_depth; i++)491 for(int i = 0; i < var->type->array_depth; i++)
467 m_outputStr += "[]";492 m_outputStr += "[]";
468 }493 }
469 m_outputStr += "</span>";494 m_outputStr += "</span> ";
470 495
471 // function name496 // function name
472 m_outputStr += "<span class=\"membername\">" + var->name + "</span></p>";497 m_outputStr += "<span class=\"membername\">" + var->name + "</span></p>";
473 498
474 if(var->doc.size() > 0)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 else501 else
477 m_outputStr += "<p class=\"empty_member_description\">No description available</p>\n";502 m_outputStr += "<p class=\"empty_member_description\">No description available</p>\n";
478 503
@@ -506,7 +531,7 @@ public: · 27 unmodified lines
506 m_outputStr += ")</p>\n";531 m_outputStr += ")</p>\n";
507 532
508 if(m_func->doc.size() > 0)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 else535 else
511 m_outputStr += "<p class=\"empty_member_description\">No description available</p>\n";536 m_outputStr += "<p class=\"empty_member_description\">No description available</p>\n";
512 537
@@ -542,7 +567,7 @@ public: · 29 unmodified lines
542 m_outputStr += ")</p>\n";567 m_outputStr += ")</p>\n";
543 568
544 if(m_func->doc.size() > 0)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 else571 else
547 m_outputStr += "<p class=\"empty_member_description\">No description available</p>\n";572 m_outputStr += "<p class=\"empty_member_description\">No description available</p>\n";
548 573
@@ -596,17 +621,73 @@ public: · 47 unmodified lines
596 static std::string css_class_for_type( Chuck_Env * env, Chuck_Type * type )621 static std::string css_class_for_type( Chuck_Env * env, Chuck_Type * type )
597 {622 {
598 if( isprim(env, type) || isvoid(env, type) || (type->array_depth && isprim(env, type->array_type)) )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 else if(isugen(type))625 else if(isugen(type))
601 return "ckdoc_typename ckdoc_ugen_type";626 return "ckdoc_typename ckdoc_type_ugen";
602 else627 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//-----------------------------------------------------------------------------
639string 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>&nbsp;</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// name: CKDoc()692// name: CKDoc()
612// desc: constructor693// desc: constructor
@@ -848,10 +929,12 @@ string CKDoc::getExamplesRoot() const · 235 unmodified lines
848// name: genIndex()929// name: genIndex()
849// desc: generate top-level index file; return as string930// desc: generate top-level index file; return as string
850//-----------------------------------------------------------------------------931//-----------------------------------------------------------------------------
851string CKDoc::genIndex()932string CKDoc::genIndex( const string & title )
852{933{
853 // return the string literal934 // check
854 return "";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 for( t_CKINT i = 0; i < m_groups.size(); i++ )979 for( t_CKINT i = 0; i < m_groups.size(); i++ )
897 {980 {
898 // generate each group981 // 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 // begin type contents1036 // begin type contents
954 output->begin_classes();1037 output->begin_classes( group );
955 1038
956 // iterate1039 // iterate
957 for( vector<Chuck_Type *>::const_iterator t = group->types.begin(); t != group->types.end(); t++ )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 if( clearOutput ) output->clear();1074 if( clearOutput ) output->clear();
992 1075
993 // begin the type1076 // begin the type
994 output->begin_class( type );1077 output->begin_class( type, m_groups );
995 1078
996 // output examples1079 // output examples
997 if( type->examples.size() )1080 if( type->examples.size() )
@@ -1190,7 +1273,7 @@ string CKDoc::genType( Chuck_Type * type, t_CKBOOL clearOutput ) · 192 unmodified lines
1190// name: outputToDir()1273// name: outputToDir()
1191// desc: generate everything as files into the output directory1274// desc: generate everything as files into the output directory
1192//-----------------------------------------------------------------------------1275//-----------------------------------------------------------------------------
1193t_CKBOOL CKDoc::outputToDir( const string & outputDir )1276t_CKBOOL CKDoc::outputToDir( const string & outputDir, const string & indexTitle )
1194{1277{
1195 // groups content1278 // groups content
1196 vector<string> groupOutput;1279 vector<string> groupOutput;
@@ -1204,7 +1287,7 @@ t_CKBOOL CKDoc::outputToDir( const string & outputDir ) · 7 unmodified lines
1204 m_output->clear();1287 m_output->clear();
1205 1288
1206 // gen index1289 // 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 // gen CSS1291 // gen CSS
1209 if( !outputToFile( path + "ckdoc.css", genCSS() ) ) goto error;1292 if( !outputToFile( path + "ckdoc.css", genCSS() ) ) goto error;
1210 // gen groups1293 // gen groups
@@ -1503,8 +1586,13 @@ CK_DLL_MFUN( CKDoc_outputToDir ) · 292 unmodified lines
1503{1586{
1504 CKDoc * ckdoc = (CKDoc *)OBJ_MEMBER_UINT(SELF, CKDoc_offset_data);1587 CKDoc * ckdoc = (CKDoc *)OBJ_MEMBER_UINT(SELF, CKDoc_offset_data);
1505 Chuck_String * path = GET_NEXT_STRING(ARGS);1588 Chuck_String * path = GET_NEXT_STRING(ARGS);
1589 Chuck_String * indexTitle = GET_NEXT_STRING(ARGS);
1506 // the path as c++ string1590 // the path as c++ string
1507 string thePath;1591 string thePath;
1592 string theTitle;
1593
1594 // check
1595 theTitle = indexTitle != NULL ? indexTitle->str() : "";
1508 1596
1509 // check if null1597 // check if null
1510 if( path == NULL ) {1598 if( path == NULL ) {
@@ -1515,7 +1603,7 @@ CK_DLL_MFUN( CKDoc_outputToDir ) · 4 unmodified lines
1515 }1603 }
1516 1604
1517 // output1605 // 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 margin-right: 0.5em;\n\1652 margin-right: 0.5em;\n\
1565 line-height: 1.5em;\n\1653 line-height: 1.5em;\n\
1566 }\n\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\n\1664\n\
1568 .index_group_title a { color: black; }\n\1665 .index_group_title a { color: black; }\n\
1569\n\1666\n\
@@ -1612,7 +1709,7 @@ string CKDoc::m_ckdocCSS = "\ · 42 unmodified lines
1612 background-color: #eee;\n\1709 background-color: #eee;\n\
1613 padding: 0.25em 0.5em 1em 0.75em;\n\1710 padding: 0.25em 0.5em 1em 0.75em;\n\
1614 margin: 0;\n\1711 margin: 0;\n\
1615 width: 6em;\n\1712 width: 9.5em;\n\
1616 }\n\1713 }\n\
1617\n\1714\n\
1618 .toc_class\n\1715 .toc_class\n\
@@ -1625,7 +1722,7 @@ string CKDoc::m_ckdocCSS = "\ · 6 unmodified lines
1625 .classes\n\1722 .classes\n\
1626 {\n\1723 {\n\
1627 clear: right;\n\1724 clear: right;\n\
1628 margin-left: 9em;\n\1725 margin-left: 12em;\n\
1629 margin-right: 0em;\n\1726 margin-right: 0em;\n\
1630 }\n\1727 }\n\
1631\n\1728\n\
@@ -1640,12 +1737,16 @@ string CKDoc::m_ckdocCSS = "\ · 8 unmodified lines
1640 font-family: Menlo, Monaco, Courier;\n\1737 font-family: Menlo, Monaco, Courier;\n\
1641 font-size: 18px;\n\1738 font-size: 18px;\n\
1642 }\n\1739 }\n\
1740 .class_inherits\n\
1741 {\n\
1742 font-weight: normal;\n\
1743 }\n\
1643\n\1744\n\
1644 .class_hierarchy\n\1745 .class_hierarchy\n\
1645 {\n\1746 {\n\
1646 font-family: Menlo, Monaco, Courier;\n\1747 font-family: Menlo, Monaco, Courier;\n\
1647 font-size: 14px;\n\1748 font-size: 14px;\n\
1648 margin-right: 4em;\n\1749 /* margin-right: 4em; */ \n\
1649 }\n\1750 }\n\
1650\n\1751\n\
1651 .class_section_header\n\1752 .class_section_header\n\
src/core/ulib_doc.h+6−4
@@ -69,6 +69,8 @@ public: · 68 unmodified lines
69 const std::string & str() const { return m_outputStr; }69 const std::string & str() const { return m_outputStr; }
70 // get file name: ".html", ".txt", etc.70 // get file name: ".html", ".txt", etc.
71 virtual std::string fileExtension() const { return ""; }71 virtual std::string fileExtension() const { return ""; }
72 // render index
73 virtual std::string renderIndex( const std::string & indexTitle, const std::vector<CKDocGroup *> & groups ) { return ""; };
72 74
73public:75public:
74 virtual void begin(const std::string &title) = 0;76 virtual void begin(const std::string &title) = 0;
@@ -85,11 +87,11 @@ public: · 10 unmodified lines
85 virtual void end_toc() = 0;87 virtual void end_toc() = 0;
86 88
87 // classes89 // classes
88 virtual void begin_classes() = 0;90 virtual void begin_classes( CKDocGroup * group ) = 0;
89 virtual void end_classes() = 0;91 virtual void end_classes() = 0;
90 92
91 // one class93 // one class
92 virtual void begin_class( Chuck_Type * type ) = 0;94 virtual void begin_class( Chuck_Type * type, const std::vector<CKDocGroup *> & groups ) = 0;
93 95
94 // examples96 // examples
95 virtual void begin_examples() = 0;97 virtual void begin_examples() = 0;
@@ -167,9 +169,9 @@ public: · 71 unmodified lines
167 169
168public:170public:
169 // generate everything as files into the output directory171 // generate everything as files into the output directory
170 t_CKBOOL outputToDir( const std::string & outputDir );172 t_CKBOOL outputToDir( const std::string & outputDir, const std::string & indexTitle );
171 // generate top-level index file; return as string173 // generate top-level index file; return as string
172 std::string genIndex();174 std::string genIndex( const std::string & title );
173 // generate CSS; return as string175 // generate CSS; return as string
174 std::string genCSS();176 std::string genCSS();
175 // generate all added groups, return each in a separate entry177 // generate all added groups, return each in a separate entry
src/core/util_string.cpp+18−0
@@ -124,6 +124,24 @@ string toupper( const string & str ) · 123 unmodified lines
124 124
125 125
126 126
127//-----------------------------------------------------------------------------
128// name: capitalize()
129// capitalize first character
130//-----------------------------------------------------------------------------
131string capitalize( const string & s )
132{
133 // copy
134 string retval = s;
135 // if not empty and first character is a lower-case letter
136 if( retval.length() > 0 && retval[0] >= 'a' && retval[0] <= 'z' )
137 retval[0] -= 32;
138 // done
139 return retval;
140}
141
142
143
144
127//-----------------------------------------------------------------------------145//-----------------------------------------------------------------------------
128// name: trim()146// name: trim()
129// desc: ...147// desc: ...
src/core/util_string.h+2−0
@@ -53,6 +53,8 @@ std::string trim( const std::string & val ); · 52 unmodified lines
53std::string ltrim( const std::string & val );53std::string ltrim( const std::string & val );
54// rtrim54// rtrim
55std::string rtrim( const std::string & val );55std::string rtrim( const std::string & val );
56// return capitalized copy of a string
57std::string capitalize( const std::string & s );
56 58
57// argument extraction59// argument extraction
58t_CKBOOL extract_args( const std::string & token,60t_CKBOOL extract_args( const std::string & token,
src/scripts/ckdoc/test-all.ck+22−2
@@ -15,7 +15,27 @@ Type.getTypes( · 14 unmodified lines
15// instantiate15// instantiate
16CKDoc doc; // documentation orchestra16CKDoc doc; // documentation orchestra
17 17
18// set the examples root
19"https://chuck.stanford.edu/doc/examples/" => doc.examplesRoot;
20
21// add as group
22doc.addGroup( types, "Base Types (compiled in)", "base", "Base types in the ChucK" );
23
24types.clear();
25// get types currently in ChucK type system
26Type.getTypes(
27 types, // to be filled with results
28 true, // include objects
29 false, // include primitive types
30 false, // include special types (@array and @function)
31 false, // include builtin types
32 true, // include types from chugins
33 false, // include types from ck files in lib path
34 false // include user-defined classes
35);
36
18// add as group37// add as group
19doc.addGroup( types, "All", "all", "Here are some types in the ChucK VM" );38doc.addGroup( types, "Base Types (chugins)", "chugins", "ChucK Objects loaded from chugins" );
39
20// generate40// generate
21doc.outputToDir( "." );41doc.outputToDir( ".", "ChucK Class Library Reference" );
src/scripts/ckdoc/test-class.ck+25−0
@@ -0,0 +1,25 @@
1public class Foo
2{
3 /** a is an integer; nothing uses this. */
4 int a;
5 /** b is a float; nothing uses this either. */
6 float b;
7
8 /** this function does nothing. */
9 fun void bar( int x )
10 {
11 // \o/ this function does nothing" \o/
12 // => this function does nothing" <=
13 //=> this function does nothing
14 /*=> */
15 }
16}
17
18[ Foo.typeOf() ] @=> Type types[];
19
20CKDoc doc;
21
22doc.addGroup( types, "my classes!", "my", "Will this work?" );
23
24// generate
25doc.outputToDir( ".", "My Class Library" );

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t