| 1 | /*---------------------------------------------------------------------------- |
| 2 | ChucK Strongly-timed Audio Programming Language |
| 3 | Compiler, Virtual Machine, and Synthesis Engine |
| 4 | |
| 5 | Copyright (c) 2003 Ge Wang and Perry R. Cook. All rights reserved. |
| 6 | http://chuck.stanford.edu/ |
| 7 | http://chuck.cs.princeton.edu/ |
| 8 | |
| 9 | This program is free software; you can redistribute it and/or modify |
| 10 | it under the dual-license terms of EITHER the MIT License OR the GNU |
| 11 | General Public License (the latter as published by the Free Software |
| 12 | Foundation; either version 2 of the License or, at your option, any |
| 13 | later version). |
| 14 | |
| 15 | This program is distributed in the hope that it will be useful and/or |
| 16 | interesting, but WITHOUT ANY WARRANTY; without even the implied warranty |
| 17 | of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | MIT Licence and/or the GNU General Public License for details. |
| 19 | |
| 20 | You should have received a copy of the MIT License and the GNU General |
| 21 | Public License (GPL) along with this program; a copy of the GPL can also |
| 22 | be obtained by writing to the Free Software Foundation, Inc., 59 Temple |
| 23 | Place, Suite 330, Boston, MA 02111-1307 U.S.A. |
| 24 | -----------------------------------------------------------------------------*/ |
| 25 | |
| 26 | //----------------------------------------------------------------------------- |
| 27 | // file: ulib_machine.cpp |
| 28 | // desc: class library for 'Machine' |
| 29 | // |
| 30 | // author: Ge Wang ([email protected] | [email protected]) |
| 31 | // date: Spring 2004 |
| 32 | //----------------------------------------------------------------------------- |
| 33 | #include "ulib_doc.h" |
| 34 | #include "chuck.h" |
| 35 | #include "chuck_type.h" |
| 36 | #include "chuck_vm.h" |
| 37 | #include "chuck_instr.h" |
| 38 | #include "chuck_compile.h" |
| 39 | #include "chuck_errmsg.h" |
| 40 | #include "util_string.h" |
| 41 | |
| 42 | #include <string> |
| 43 | #include <sstream> |
| 44 | #include <fstream> |
| 45 | #include <algorithm> |
| 46 | using namespace std; |
| 47 | |
| 48 | // 1.5.0.0 ((ge, spencer) | added |
| 49 | CK_DLL_CTOR( CKDoc_ctor ); |
| 50 | CK_DLL_DTOR( CKDoc_dtor ); |
| 51 | CK_DLL_MFUN( CKDoc_addGroup_str ); |
| 52 | CK_DLL_MFUN( CKDoc_addGroup_type ); |
| 53 | CK_DLL_MFUN( CKDoc_addGroup_ext ); |
| 54 | CK_DLL_MFUN( CKDoc_numGroups ); |
| 55 | CK_DLL_MFUN( CKDoc_clearGroup ); |
| 56 | CK_DLL_CTRL( CKDoc_examplesRoot_set ); |
| 57 | CK_DLL_CGET( CKDoc_examplesRoot_get ); |
| 58 | CK_DLL_CTRL( CKDoc_outputFormat_set ); |
| 59 | CK_DLL_CGET( CKDoc_outputFormat_get ); |
| 60 | CK_DLL_MFUN( CKDoc_sort_set ); |
| 61 | CK_DLL_MFUN( CKDoc_sort_get ); |
| 62 | CK_DLL_MFUN( CKDoc_genIndex ); |
| 63 | CK_DLL_MFUN( CKDoc_genCSS ); |
| 64 | CK_DLL_MFUN( CKDoc_genGroups ); |
| 65 | CK_DLL_MFUN( CKDoc_genType_type ); |
| 66 | CK_DLL_MFUN( CKDoc_genType_str ); |
| 67 | CK_DLL_MFUN( CKDoc_outputToDir ); |
| 68 | CK_DLL_SFUN( CKDoc_set_describe ); |
| 69 | CK_DLL_SFUN( CKDoc_get_describe ); |
| 70 | // offset |
| 71 | static t_CKUINT CKDoc_offset_data = 0; |
| 72 | |
| 73 | // static initialization |
| 74 | t_CKINT const CKDoc::FORMAT_NONE = 0; |
| 75 | t_CKINT const CKDoc::FORMAT_HTML = 1; |
| 76 | t_CKINT const CKDoc::FORMAT_TEXT = 2; |
| 77 | t_CKINT const CKDoc::FORMAT_MARKDOWN = 3; |
| 78 | t_CKINT const CKDoc::FORMAT_JSON = 4; |
| 79 | |
| 80 | |
| 81 | |
| 82 | |
| 83 | //----------------------------------------------------------------------------- |
| 84 | // name: ckdoc_query() |
| 85 | // desc: add class for ckdoc documentation generator | 1.5.0.0 (ge, spencer, terry) |
| 86 | //----------------------------------------------------------------------------- |
| 87 | DLL_QUERY ckdoc_query( Chuck_DL_Query * QUERY ) |
| 88 | { |
| 89 | // get environment reference |
| 90 | Chuck_Env * env = QUERY->env(); |
| 91 | // set module name |
| 92 | QUERY->setname( QUERY, "CKDoc" ); |
| 93 | |
| 94 | // function |
| 95 | Chuck_DL_Func * func = NULL; |
| 96 | // documentation string |
| 97 | std::string doc; |
| 98 | |
| 99 | //--------------------------------------------------------------------- |
| 100 | // init as class |
| 101 | // 1.5.0.0 added by spencer and ge |
| 102 | //--------------------------------------------------------------------- |
| 103 | // doc string |
| 104 | doc = "A ChucK documentation generator. Based on Spencer Salazar's ckdoc utility."; |
| 105 | |
| 106 | // begin class definition |
| 107 | if( !type_engine_import_class_begin( env, "CKDoc", "Object", env->global(), CKDoc_ctor, CKDoc_dtor, doc.c_str() ) ) |
| 108 | return FALSE; |
| 109 | |
| 110 | // data offset |
| 111 | CKDoc_offset_data = type_engine_import_mvar( env, "int", "@CKDoc_data", FALSE ); |
| 112 | if( CKDoc_offset_data == CK_INVALID_OFFSET ) goto error; |
| 113 | |
| 114 | // const static variables, for format selection, e.g., with CKDoc.HTML or CKDoc.TEXT |
| 115 | if( !type_engine_import_svar( env, "int", "NONE", TRUE, (t_CKUINT)&CKDoc::FORMAT_NONE, "no output format." ) ) goto error; |
| 116 | if( !type_engine_import_svar( env, "int", "HTML", TRUE, (t_CKUINT)&CKDoc::FORMAT_HTML, "output HTML format." ) ) goto error; |
| 117 | if( !type_engine_import_svar( env, "int", "TEXT", TRUE, (t_CKUINT)&CKDoc::FORMAT_TEXT, "output TEXT format (not implemented)." ) ) goto error; |
| 118 | if( !type_engine_import_svar( env, "int", "MARKDOWN", TRUE, (t_CKUINT)&CKDoc::FORMAT_MARKDOWN, "output MARKDOWN format (not implemented)." ) ) goto error; |
| 119 | if( !type_engine_import_svar( env, "int", "JSON", TRUE, (t_CKUINT)&CKDoc::FORMAT_JSON, "output JSON format (not implemented)." ) ) goto error; |
| 120 | |
| 121 | // addGroup (by types) |
| 122 | func = make_new_mfun( "void", "addGroup", CKDoc_addGroup_type ); |
| 123 | func->add_arg( "Type[]", "types" ); |
| 124 | func->add_arg( "string", "name" ); |
| 125 | func->add_arg( "string", "shortName" ); |
| 126 | func->add_arg( "string", "description" ); |
| 127 | func->doc = "Add a group of types to be documented, including group 'name', a 'shortName' to be used for any files, and a group 'description'."; |
| 128 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 129 | |
| 130 | // addGroup (by names) |
| 131 | func = make_new_mfun( "void", "addGroup", CKDoc_addGroup_str ); |
| 132 | func->add_arg( "string[]", "typeNames" ); |
| 133 | func->add_arg( "string", "name" ); |
| 134 | func->add_arg( "string", "shortName" ); |
| 135 | func->add_arg( "string", "description" ); |
| 136 | func->doc = "Add a group of types (by type name) to be documented, including group 'name', a 'shortName' to be used for any files, and a group 'description'."; |
| 137 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 138 | |
| 139 | // addGroupExternal | 1.5.2.4 (ge) added |
| 140 | func = make_new_mfun( "void", "addGroupExternal", CKDoc_addGroup_ext ); |
| 141 | func->add_arg( "string", "name" ); |
| 142 | func->add_arg( "string", "URL" ); |
| 143 | func->add_arg( "string", "description" ); |
| 144 | func->add_arg( "string", "longDesc" ); |
| 145 | func->doc = "Add a group documention at an external URL location"; |
| 146 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 147 | |
| 148 | // numGroups |
| 149 | func = make_new_mfun( "int", "numGroups", CKDoc_numGroups ); |
| 150 | func->doc = "Get the number of groups added."; |
| 151 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 152 | |
| 153 | // clear |
| 154 | func = make_new_mfun( "void", "clear", CKDoc_clearGroup ); |
| 155 | func->doc = "Clear all added groups."; |
| 156 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 157 | |
| 158 | // examplesRoot |
| 159 | func = make_new_mfun( "string", "examplesRoot", CKDoc_examplesRoot_set ); |
| 160 | func->add_arg( "string", "path" ); |
| 161 | func->doc = "Set the examples directory root path; returns what was set."; |
| 162 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 163 | |
| 164 | // examplesRoot |
| 165 | func = make_new_mfun( "string", "examplesRoot", CKDoc_examplesRoot_get ); |
| 166 | func->doc = "Get the current examples directory root path."; |
| 167 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 168 | |
| 169 | // outputFormat |
| 170 | func = make_new_mfun( "int", "outputFormat", CKDoc_outputFormat_set ); |
| 171 | func->add_arg( "int", "which" ); |
| 172 | func->doc = "Set which output format to use; see CKDoc.HTML, CKDoc.TEXT, CKDoc.MARKDOWN, CKDoc.JSON."; |
| 173 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 174 | |
| 175 | // CKDoc_outputFormat_set |
| 176 | func = make_new_mfun( "int", "outputFormat", CKDoc_outputFormat_get ); |
| 177 | func->doc = "Set which output format is selected; see CKDoc.HTML, CKDoc.TEXT, CKDoc.MARKDOWN, CKDoc.JSON."; |
| 178 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 179 | |
| 180 | // CKDoc toggle sort | 1.5.2.5 (@kellyyyyyyyyyyyyyyyy @azaday) |
| 181 | func = make_new_mfun( "int", "sort", CKDoc_sort_set ); |
| 182 | func->add_arg( "int", "toggle" ); |
| 183 | func->doc = "Enable or disable alphabetical sorting of functions and variables."; |
| 184 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 185 | |
| 186 | // CKDoc get sort status | 1.5.2.5 (@kellyyyyyyyyyyyyyyyy @azaday) |
| 187 | func = make_new_mfun( "int", "sort", CKDoc_sort_get ); |
| 188 | func->doc = "Get the current status of alphabetical sorting."; |
| 189 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 190 | |
| 191 | // genIndex |
| 192 | func = make_new_mfun( "string", "genIndex", CKDoc_genIndex ); |
| 193 | func->add_arg( "string", "indexTitle" ); |
| 194 | func->doc = "Generate top-level index; return as string."; |
| 195 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 196 | |
| 197 | // genCSS |
| 198 | func = make_new_mfun( "string", "genCSS", CKDoc_genCSS ); |
| 199 | func->doc = "Generate CSS; return as string."; |
| 200 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 201 | |
| 202 | // genGroups |
| 203 | func = make_new_mfun( "void", "genGroups", CKDoc_genGroups ); |
| 204 | func->add_arg( "string[]", "results" ); |
| 205 | func->doc = "Generate documentation for all added groups, return each in a separate entry"; |
| 206 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 207 | |
| 208 | // genType |
| 209 | func = make_new_mfun( "string", "genType", CKDoc_genType_type ); |
| 210 | func->add_arg( "Type", "type" ); |
| 211 | func->doc = "Generate documentation for a single Type."; |
| 212 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 213 | |
| 214 | // genType |
| 215 | func = make_new_mfun( "string", "genType", CKDoc_genType_str ); |
| 216 | func->add_arg( "string", "typeName" ); |
| 217 | func->doc = "Generate documentation for a single Type (by name)."; |
| 218 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 219 | |
| 220 | // outputToDir |
| 221 | func = make_new_mfun( "int", "outputToDir", CKDoc_outputToDir ); |
| 222 | func->add_arg( "string", "path" ); |
| 223 | func->add_arg( "string", "indexTitle" ); |
| 224 | func->doc = "Generate everything as files into the output directory."; |
| 225 | if( !type_engine_import_mfun( env, func ) ) goto error; |
| 226 | |
| 227 | // // describe |
| 228 | // func = make_new_sfun( "int", "describe", CKDoc_set_describe ); |
| 229 | // func->add_arg( "Object", "target" ); |
| 230 | // func->add_arg( "string", "description" ); |
| 231 | // func->doc = "Associate a description with `target`, which must be either a Type (i.e., a class) or a function. Returns true on sucess; returns false if target is neither a class nor function, or if describe() was called on a target without sufficient permission to update its description."; |
| 232 | // if( !type_engine_import_sfun( env, func ) ) goto error; |
| 233 | |
| 234 | // describe |
| 235 | func = make_new_sfun( "string", "describe", CKDoc_get_describe ); |
| 236 | func->add_arg( "Object", "target" ); |
| 237 | func->doc = "Returns the description associated with `target`, which must be either a Type (i.e., a class) or a function."; |
| 238 | if( !type_engine_import_sfun( env, func ) ) goto error; |
| 239 | |
| 240 | // end the class import |
| 241 | type_engine_import_class_end( env ); |
| 242 | |
| 243 | return true; |
| 244 | |
| 245 | error: |
| 246 | |
| 247 | return false; |
| 248 | } |
| 249 | |
| 250 | |
| 251 | |
| 252 | |
| 253 | //----------------------------------------------------------------------------- |
| 254 | // name: struct CKDocGroup | 1.5.0.0 (ge, spencer) added |
| 255 | // desc: structure for a doc group e.g., "UGens" |
| 256 | //----------------------------------------------------------------------------- |
| 257 | struct CKDocGroup |
| 258 | { |
| 259 | // types in the group |
| 260 | vector<Chuck_Type *> types; |
| 261 | // name of the group |
| 262 | string name; |
| 263 | // short name of the group (used for filenames and such) |
| 264 | string shortName; |
| 265 | // description of the group |
| 266 | string desc; |
| 267 | // long description (for groups that point to external CKDoc) | 1.5.2.4 (ge) added |
| 268 | string longDesc; |
| 269 | }; |
| 270 | |
| 271 | |
| 272 | |
| 273 | |
| 274 | //----------------------------------------------------------------------------- |
| 275 | // name: type2url() |
| 276 | // desc: convert type name to URL, using groups to detemine the file for each |
| 277 | //----------------------------------------------------------------------------- |
| 278 | string type2url( const string & type, const vector<CKDocGroup *> & groups ) |
| 279 | { |
| 280 | // search |
| 281 | for( t_CKINT i = 0; i < groups.size(); i++ ) |
| 282 | { |
| 283 | for( t_CKINT j = 0; j < groups[i]->types.size(); j++ ) |
| 284 | { |
| 285 | // check |
| 286 | if( groups[i]->types[j] == NULL ) continue; |
| 287 | // compare |
| 288 | if( type == groups[i]->types[j]->base_name ) |
| 289 | { |
| 290 | // file + location within file: basically: 'group.html#type' |
| 291 | return groups[i]->shortName + ".html#" + type; |
| 292 | } |
| 293 | } |
| 294 | } |
| 295 | |
| 296 | // TODO: make a list of default classes on chuck website to link to |
| 297 | // return "[type2url NOT IMPLEMENTED]"; |
| 298 | return ""; |
| 299 | } |
| 300 | |
| 301 | |
| 302 | |
| 303 | |
| 304 | //----------------------------------------------------------------------------- |
| 305 | // name: class CKDocJSONOutput | 1.5.2.5 (terry feng) added |
| 306 | // desc: JSON output |
| 307 | //----------------------------------------------------------------------------- |
| 308 | class CKDocJSONOutput : public CKDocOutput |
| 309 | { |
| 310 | private: |
| 311 | Chuck_Func * m_func; |
| 312 | std::string m_title; |
| 313 | Chuck_VM * m_vm_ref; |
| 314 | Chuck_Env * m_env_ref; |
| 315 | vector< pair<string, string> > m_args; |
| 316 | |
| 317 | public: |
| 318 | CKDocJSONOutput( Chuck_VM * vm ) : m_func(NULL), m_vm_ref(vm) |
| 319 | { |
| 320 | // get the env |
| 321 | m_env_ref = vm != NULL ? vm->env() : NULL; |
| 322 | } |
| 323 | // file extension |
| 324 | virtual string fileExtension() const { return ".json"; } |
| 325 | // render JSON index |
| 326 | virtual string renderIndex( const string & indexTitle, const vector<CKDocGroup *> & groups ) |
| 327 | { |
| 328 | ostringstream sout; |
| 329 | sout << "{\n"; |
| 330 | |
| 331 | for( t_CKINT i = 0; i < groups.size(); ++i ) |
| 332 | { |
| 333 | sout << " \"" << groups[i]->name << "\": [\n"; |
| 334 | for( t_CKINT j = 0; j < groups[i]->types.size(); ++j ) |
| 335 | { |
| 336 | sout << " \"" << groups[i]->types[j]->base_name << "\""; |
| 337 | if(j < groups[i]->types.size() - 1) |
| 338 | { |
| 339 | sout << ","; |
| 340 | } |
| 341 | sout << "\n"; |
| 342 | } |
| 343 | sout << " ]"; |
| 344 | if(i < groups.size() - 1) |
| 345 | { |
| 346 | sout << ","; |
| 347 | } |
| 348 | sout << "\n"; |
| 349 | } |
| 350 | sout << "}\n"; |
| 351 | return sout.str(); |
| 352 | } |
| 353 | |
| 354 | public: |
| 355 | void begin( const string & title ) |
| 356 | { |
| 357 | m_title = trim(title); |
| 358 | // check length |
| 359 | if( m_title.length() == 0 ) m_title = ""; |
| 360 | // string to return |
| 361 | m_outputStr += "{\n"; |
| 362 | m_outputStr += " \"title\": \"" + m_title + "\",\n"; |
| 363 | m_outputStr += " \"groups\": [\n"; |
| 364 | } |
| 365 | void heading() { } |
| 366 | void end() { m_outputStr += " ]\n}\n"; } |
| 367 | void title(const std::string &_title) { } |
| 368 | void begin_body() { } |
| 369 | void end_body() |
| 370 | { removeTrailingComma(m_outputStr); } |
| 371 | void begin_toc() { } |
| 372 | void toc_class(Chuck_Type * type) { } |
| 373 | void end_toc() { } |
| 374 | void begin_classes( CKDocGroup * group ) { } |
| 375 | void end_classes() { } |
| 376 | void begin_class(Chuck_Type * type, const vector<CKDocGroup *> & groups) |
| 377 | { |
| 378 | m_outputStr += " {\n"; |
| 379 | m_outputStr += " \"name\": \"" + type->base_name + "\",\n"; |
| 380 | m_outputStr += " \"description\": \"" + jsonStringify(capitalize_and_periodize(type->doc)) + "\",\n"; |
| 381 | |
| 382 | // type heirarchy, iterate through parents |
| 383 | Chuck_Type * parent = type->parent_type; |
| 384 | // check if there is a parent class |
| 385 | if( parent != NULL ) |
| 386 | { |
| 387 | m_outputStr += " \"inherits\": ["; |
| 388 | } |
| 389 | while( parent != NULL ) |
| 390 | { |
| 391 | m_outputStr += "\"" + parent->base_name + "\""; |
| 392 | parent = parent->parent_type; |
| 393 | if( parent != NULL ) |
| 394 | { |
| 395 | m_outputStr += ", "; |
| 396 | } |
| 397 | } |
| 398 | if( type->parent_type != NULL ) m_outputStr += "],\n"; |
| 399 | } |
| 400 | |
| 401 | void end_class() { |
| 402 | removeTrailingComma(m_outputStr); |
| 403 | m_outputStr += " },\n"; |
| 404 | } |
| 405 | void begin_examples() { |
| 406 | m_outputStr += " \"examples\": [\n"; |
| 407 | } |
| 408 | void end_examples() { |
| 409 | removeTrailingComma(m_outputStr); |
| 410 | m_outputStr += " ],\n"; |
| 411 | } |
| 412 | void begin_static_member_vars() { |
| 413 | m_outputStr += " \"static member variables\": [\n"; |
| 414 | } |
| 415 | void end_static_member_vars() { |
| 416 | removeTrailingComma(m_outputStr); |
| 417 | m_outputStr += " ],\n"; |
| 418 | } |
| 419 | void begin_member_vars() { |
| 420 | m_outputStr += " \"member variables\": [\n"; |
| 421 | } |
| 422 | void end_member_vars() { |
| 423 | removeTrailingComma(m_outputStr); |
| 424 | m_outputStr += " ],\n"; |
| 425 | } |
| 426 | void begin_static_member_funcs() { |
| 427 | m_outputStr += " \"static member functions\": [\n"; |
| 428 | } |
| 429 | void end_static_member_funcs() { |
| 430 | removeTrailingComma(m_outputStr); |
| 431 | m_outputStr += " ],\n"; |
| 432 | } |
| 433 | void begin_ctors() { |
| 434 | m_outputStr += " \"constructors\": [\n"; |
| 435 | } |
| 436 | void end_ctors() { |
| 437 | removeTrailingComma(m_outputStr); |
| 438 | m_outputStr += " ],\n"; |
| 439 | } |
| 440 | void begin_dtor() { } |
| 441 | void begin_member_funcs() { |
| 442 | m_outputStr += " \"member functions\": [\n"; |
| 443 | } |
| 444 | void end_member_funcs() { |
| 445 | removeTrailingComma(m_outputStr); |
| 446 | m_outputStr += " ],\n"; |
| 447 | } |
| 448 | void example(const std::string &name, const std::string &url) |
| 449 | { |
| 450 | // remove the "../" |
| 451 | m_outputStr += " \"" + EXAMPLES_URL_BASE + url.substr(3) + "\",\n"; |
| 452 | } |
| 453 | |
| 454 | void static_member_var(Chuck_Value * var) |
| 455 | { |
| 456 | m_outputStr += " {\n"; |
| 457 | m_outputStr += " \"name\": \"" + var->name + "\",\n"; |
| 458 | m_outputStr += " \"type\": \"" + var->type->base_name + array_depth_to_brackets(var->type->array_depth) + "\",\n"; |
| 459 | m_outputStr += " \"description\": \"" + jsonStringify(capitalize_and_periodize(var->doc)) + "\"\n"; |
| 460 | m_outputStr += " },\n"; |
| 461 | } |
| 462 | |
| 463 | void member_var(Chuck_Value * var) |
| 464 | { |
| 465 | m_outputStr += " {\n"; |
| 466 | m_outputStr += " \"name\": \"" + var->name + "\",\n"; |
| 467 | m_outputStr += " \"type\": \"" + var->type->base_name + array_depth_to_brackets(var->type->array_depth) + "\",\n"; |
| 468 | m_outputStr += " \"description\": \"" + jsonStringify(capitalize_and_periodize(var->doc)) + "\"\n"; |
| 469 | m_outputStr += " },\n"; |
| 470 | } |
| 471 | |
| 472 | void begin_static_member_func(Chuck_Func * func) |
| 473 | { |
| 474 | // begin |
| 475 | m_outputStr += " {\n"; |
| 476 | // function name |
| 477 | m_outputStr += " \"static member function\": \"" + func->base_name + "\",\n"; |
| 478 | // return type |
| 479 | string ret_type = func->def()->ret_type->base_name; |
| 480 | string ret_brackets = func->def() && func->def()->ret_type->array_depth ? array_depth_to_brackets(func->def()->ret_type->array_depth) : ""; |
| 481 | m_outputStr += " \"return type\": \"" + ret_type + ret_brackets + "\",\n"; |
| 482 | // save for end_ctor() |
| 483 | m_func = func; |
| 484 | // clear func arg list |
| 485 | m_args.clear(); |
| 486 | } |
| 487 | |
| 488 | void end_static_member_func() |
| 489 | { |
| 490 | // verify |
| 491 | if( !m_func ) return; |
| 492 | // output constructor arguments |
| 493 | if (m_args.empty()) |
| 494 | { |
| 495 | m_outputStr += " \"arguments\": [],\n"; |
| 496 | } |
| 497 | else |
| 498 | { |
| 499 | m_outputStr += " \"arguments\": [\n"; |
| 500 | for (vector< pair<std::string, std::string> >::iterator arg_it = m_args.begin(); arg_it != m_args.end(); ++arg_it) |
| 501 | { |
| 502 | m_outputStr += " {\n"; |
| 503 | m_outputStr += " \"type\": \"" + arg_it->first + "\",\n"; |
| 504 | m_outputStr += " \"name\": \"" + arg_it->second + "\"\n"; |
| 505 | m_outputStr += " },\n"; |
| 506 | } |
| 507 | removeTrailingComma(m_outputStr); |
| 508 | m_outputStr += " ],\n"; |
| 509 | } |
| 510 | // description |
| 511 | m_outputStr += " \"description\": \"" + jsonStringify(capitalize_and_periodize(m_func->doc)) + "\"\n"; |
| 512 | // finish output |
| 513 | m_outputStr += " },\n"; |
| 514 | // zero out |
| 515 | m_func = NULL; |
| 516 | } |
| 517 | |
| 518 | void begin_member_func(Chuck_Func * func) |
| 519 | { |
| 520 | // begin |
| 521 | m_outputStr += " {\n"; |
| 522 | // function name |
| 523 | m_outputStr += " \"member function\": \"" + func->base_name + "\",\n"; |
| 524 | // return type |
| 525 | string ret_type = func->def()->ret_type->base_name; |
| 526 | string ret_brackets = func->def() && func->def()->ret_type->array_depth ? array_depth_to_brackets(func->def()->ret_type->array_depth) : ""; |
| 527 | m_outputStr += " \"return type\": \"" + ret_type + ret_brackets + "\",\n"; |
| 528 | // save for end_member_func() |
| 529 | m_func = func; |
| 530 | // clear func arg list |
| 531 | m_args.clear(); |
| 532 | } |
| 533 | |
| 534 | void end_member_func() |
| 535 | { |
| 536 | // verify |
| 537 | if( !m_func ) return; |
| 538 | // output constructor arguments |
| 539 | if (m_args.empty()) |
| 540 | { |
| 541 | m_outputStr += " \"arguments\": [],\n"; |
| 542 | } |
| 543 | else |
| 544 | { |
| 545 | m_outputStr += " \"arguments\": [\n"; |
| 546 | for (vector< pair<std::string, std::string> >::iterator arg_it = m_args.begin(); arg_it != m_args.end(); ++arg_it) |
| 547 | { |
| 548 | m_outputStr += " {\n"; |
| 549 | m_outputStr += " \"type\": \"" + arg_it->first + "\",\n"; |
| 550 | m_outputStr += " \"name\": \"" + arg_it->second + "\"\n"; |
| 551 | m_outputStr += " },\n"; |
| 552 | } |
| 553 | removeTrailingComma(m_outputStr); |
| 554 | m_outputStr += " ],\n"; |
| 555 | } |
| 556 | // description |
| 557 | m_outputStr += " \"description\": \"" + jsonStringify(capitalize_and_periodize(m_func->doc)) + "\"\n"; |
| 558 | // finish output |
| 559 | m_outputStr += " },\n"; |
| 560 | // zero out |
| 561 | m_func = NULL; |
| 562 | } |
| 563 | |
| 564 | void begin_ctor( Chuck_Func * func ) |
| 565 | { |
| 566 | // begin |
| 567 | m_outputStr += " {\n"; |
| 568 | // function name |
| 569 | m_outputStr += " \"constructor\": \"" + func->base_name + "\",\n"; |
| 570 | // save for end_ctor() |
| 571 | m_func = func; |
| 572 | // clear func arg list |
| 573 | m_args.clear(); |
| 574 | } |
| 575 | |
| 576 | void end_ctor() |
| 577 | { |
| 578 | // verify |
| 579 | if( !m_func ) return; |
| 580 | // output constructor arguments |
| 581 | if (m_args.empty()) |
| 582 | { |
| 583 | m_outputStr += " \"arguments\": [],\n"; |
| 584 | } |
| 585 | else |
| 586 | { |
| 587 | m_outputStr += " \"arguments\": [\n"; |
| 588 | for (vector< pair<std::string, std::string> >::iterator arg_it = m_args.begin(); arg_it != m_args.end(); ++arg_it) |
| 589 | { |
| 590 | m_outputStr += " {\n"; |
| 591 | m_outputStr += " \"type\": \"" + arg_it->first + "\",\n"; |
| 592 | m_outputStr += " \"name\": \"" + arg_it->second + "\"\n"; |
| 593 | m_outputStr += " },\n"; |
| 594 | } |
| 595 | removeTrailingComma(m_outputStr); |
| 596 | m_outputStr += " ],\n"; |
| 597 | } |
| 598 | // description |
| 599 | m_outputStr += " \"description\": \"" + jsonStringify(capitalize_and_periodize(m_func->doc)) + "\"\n"; |
| 600 | // finish output |
| 601 | m_outputStr += " },\n"; |
| 602 | // zero out |
| 603 | m_func = NULL; |
| 604 | } |
| 605 | |
| 606 | void func_arg( a_Arg_List arg ) |
| 607 | { |
| 608 | // argument type |
| 609 | string arg_type = arg->type->base_name; |
| 610 | string arg_brackets = arg->type->array_depth ? array_depth_to_brackets(arg->type->array_depth) : ""; |
| 611 | string type = arg_type + arg_brackets; |
| 612 | // argument name |
| 613 | string name = varnameclean(S_name(arg->var_decl->xid)); |
| 614 | |
| 615 | m_args.push_back(make_pair(type, name)); |
| 616 | } |
| 617 | |
| 618 | public: |
| 619 | // compute array_depth and return brackets string |
| 620 | static string array_depth_to_brackets( int depth ) |
| 621 | { |
| 622 | string brackets = ""; |
| 623 | for( int i = 0; i < depth; i++ ) |
| 624 | { |
| 625 | brackets += "[]"; |
| 626 | } |
| 627 | return brackets; |
| 628 | } |
| 629 | |
| 630 | // remove brackets from varname |
| 631 | static std::string varnameclean( std::string vn ) |
| 632 | { |
| 633 | // strip [] |
| 634 | vn.erase(std::remove(vn.begin(), vn.end(), '['), vn.end()); |
| 635 | vn.erase(std::remove(vn.begin(), vn.end(), ']'), vn.end()); |
| 636 | return vn; |
| 637 | } |
| 638 | |
| 639 | // make valid JSON string |
| 640 | static std::string jsonStringify( const std::string & str ) |
| 641 | { |
| 642 | // copy |
| 643 | string jsonStr = string(str); |
| 644 | // convert b-slash to double b-slash |
| 645 | replaceAll(jsonStr, std::string("\\"), string("\\\\")); |
| 646 | // convert quotes |
| 647 | replaceAll(jsonStr, std::string("\""), string("\\\"")); |
| 648 | // convert newlines to spaces |
| 649 | replace(jsonStr.begin(), jsonStr.end(), '\n', ' '); |
| 650 | // remove double spaces |
| 651 | replaceAll(jsonStr, std::string(" "), string(" ")); |
| 652 | return jsonStr; |
| 653 | } |
| 654 | |
| 655 | // replace string `from` instances with `to` |
| 656 | static void replaceAll( std::string & str, const std::string & from, const std::string & to ) { |
| 657 | if (from.empty()) return; |
| 658 | size_t pos = 0; |
| 659 | while ((pos = str.find(from, pos)) != std::string::npos) |
| 660 | { |
| 661 | str.replace(pos, from.length(), to); |
| 662 | pos += to.length(); |
| 663 | } |
| 664 | } |
| 665 | |
| 666 | // remove trailing comma if present |
| 667 | static void removeTrailingComma( std::string & str ) |
| 668 | { |
| 669 | // if last or second to last character is a comma, remove it |
| 670 | // accounts for the possibility of a comma followed by a newline |
| 671 | if (str[str.length() - 1] == ',') |
| 672 | { |
| 673 | str.erase(str.length() - 1, 1); |
| 674 | } |
| 675 | else if (str[str.length() - 2] == ',') |
| 676 | { |
| 677 | str.erase(str.length() - 2, 1); |
| 678 | } |
| 679 | } |
| 680 | }; |
| 681 | |
| 682 | |
| 683 | //----------------------------------------------------------------------------- |
| 684 | // name: class CKDocHTMLOutput | 1.5.0.0 (ge, spencer) added |
| 685 | // desc: HTML output (based on Spencer's ckdoc) |
| 686 | //----------------------------------------------------------------------------- |
| 687 | class CKDocHTMLOutput : public CKDocOutput |
| 688 | { |
| 689 | private: |
| 690 | Chuck_Func * m_func; |
| 691 | std::string m_title; |
| 692 | Chuck_VM * m_vm_ref; |
| 693 | Chuck_Env * m_env_ref; |
| 694 | |
| 695 | public: |
| 696 | CKDocHTMLOutput( Chuck_VM * vm ) |
| 697 | : m_func(NULL), m_vm_ref(vm) |
| 698 | { |
| 699 | // get the env |
| 700 | m_env_ref = vm != NULL ? vm->env() : NULL; |
| 701 | } |
| 702 | // file extension |
| 703 | virtual string fileExtension() const { return ".html"; } |
| 704 | // render HTML index |
| 705 | virtual string renderIndex( const string & indexTitle, const vector<CKDocGroup *> & groups ); |
| 706 | |
| 707 | public: |
| 708 | void begin( const string & title ) |
| 709 | { |
| 710 | // trim |
| 711 | m_title = trim(title); |
| 712 | // check length |
| 713 | if( m_title.length() == 0 ) m_title = " "; |
| 714 | // string to return |
| 715 | |
| 716 | m_outputStr += "<html>\n"; |
| 717 | m_outputStr += "<link rel=\"stylesheet\" type=\"text/css\" href=\"ckdoc.css\" />\n"; |
| 718 | m_outputStr += "<link rel=\"stylesheet\" type=\"text/css\" href=\"class.css\" />\n"; |
| 719 | m_outputStr += "<title>" + m_title + "</title>\n"; |
| 720 | m_outputStr += "<body>\n"; |
| 721 | } |
| 722 | |
| 723 | void heading() |
| 724 | { |
| 725 | m_outputStr += "<a name=\"top\"/>\n"; |
| 726 | m_outputStr += "<div id=\"title\">\n"; |
| 727 | m_outputStr += "<div class=\"titleL\">\n"; |
| 728 | m_outputStr += "<div style=\"display: flex; align-items: center;\">"; |
| 729 | m_outputStr += "<div class=\"inline titlelogo\"><a href=\"https://chuck.stanford.edu/\" target=\"_blank\"><img src=\"https://chuck.stanford.edu/doc/images/chuck-logo2023w.png\" /> </div>"; |
| 730 | m_outputStr += "<div class=\"inline\"><h1><a href=\"./\">ChucK Class Library Reference</a></h1></div>\n"; |
| 731 | m_outputStr += "<div class=\"inline gray\"><h1> <span style=\"color:black\">/</span> " + m_title + "</h1></div>\n"; |
| 732 | m_outputStr += "</div>\n"; |
| 733 | m_outputStr += "</div>\n"; |
| 734 | m_outputStr += "</div>\n"; // #title |
| 735 | } |
| 736 | |
| 737 | void end() |
| 738 | { |
| 739 | m_outputStr += "</html>\n"; |
| 740 | } |
| 741 | |
| 742 | void title(const std::string &_title) |
| 743 | { |
| 744 | } |
| 745 | |
| 746 | void begin_body() |
| 747 | { |
| 748 | m_outputStr += "<div id=\"body\">\n"; |
| 749 | } |
| 750 | |
| 751 | void end_body() |
| 752 | { |
| 753 | m_outputStr += "</div>\n"; // #body |
| 754 | m_outputStr += "</body>\n"; |
| 755 | } |
| 756 | |
| 757 | void begin_toc() |
| 758 | { |
| 759 | m_outputStr += "<div class=\"toc\"><a id=\"toc\"/>\n"; |
| 760 | } |
| 761 | |
| 762 | void toc_class(Chuck_Type * type) |
| 763 | { |
| 764 | m_outputStr += "<p class=\"toc_class\"><a href=\"#" + type->base_name |
| 765 | + "\" class=\"" + css_class_for_type(m_env_ref, type) |
| 766 | + "\">" + type->base_name + "</a></p>\n"; |
| 767 | } |
| 768 | |
| 769 | void end_toc() |
| 770 | { |
| 771 | m_outputStr += "</div>\n"; |
| 772 | } |
| 773 | |
| 774 | void begin_classes( CKDocGroup * group ) |
| 775 | { |
| 776 | m_outputStr += "<div class=\"classes\">\n"; |
| 777 | m_outputStr += "<p class=\"group_desc\">" + group->desc + "</p>\n"; |
| 778 | } |
| 779 | |
| 780 | void end_classes() |
| 781 | { |
| 782 | m_outputStr += "</div>\n"; |
| 783 | } |
| 784 | |
| 785 | void begin_class(Chuck_Type * type, const vector<CKDocGroup *> & groups ) |
| 786 | { |
| 787 | m_outputStr += "<a name=\"" + type->base_name + "\" /><div class=\"class\">\n"; |
| 788 | m_outputStr += "<h2 class=\"class_title\" name=\"" + type->base_name + "\">" + type->base_name + "</h2>\n"; |
| 789 | |
| 790 | // type heirarchy |
| 791 | Chuck_Type * parent = type->parent_type; |
| 792 | // check if there is a parent class |
| 793 | if( parent != NULL ) |
| 794 | { |
| 795 | m_outputStr += "<h4>"; |
| 796 | m_outputStr += "<span class=\"class_inherits\">inherits</span> "; |
| 797 | // m_outputStr += "<h4 class=\"class_hierarchy\">"; |
| 798 | } |
| 799 | // iterate over parents |
| 800 | while( parent != NULL ) |
| 801 | { |
| 802 | m_outputStr += ": <a href=\"" + type2url(parent->base_name, groups) |
| 803 | + "\" class=\"" + css_class_for_type(m_env_ref, parent) |
| 804 | + "\">" + parent->base_name + "</a> ", |
| 805 | // go up the inheritance chain |
| 806 | parent = parent->parent_type; |
| 807 | } |
| 808 | // end the tag |
| 809 | if( type->parent_type != NULL ) m_outputStr += "</h4>\n"; |
| 810 | |
| 811 | if(type->doc.size() > 0) |
| 812 | { |
| 813 | std::string doc = capitalize_and_periodize(type->doc); |
| 814 | m_outputStr += "<p class=\"class_description\">" + doc + "<p>\n"; |
| 815 | } |
| 816 | else |
| 817 | m_outputStr += "<p class=\"empty_class_description\">No description available</p>\n"; |
| 818 | } |
| 819 | |
| 820 | void end_class() |
| 821 | { |
| 822 | m_outputStr += "<p class=\"top_link\">[ <a href=\"#top\">top</a> ]</p>\n"; |
| 823 | m_outputStr += "</div>\n<hr />\n"; |
| 824 | } |
| 825 | |
| 826 | void begin_examples() |
| 827 | { |
| 828 | m_outputStr += "<h3 class=\"class_section_header\">examples</h3><div class=\"examples\"><ul>\n"; |
| 829 | } |
| 830 | |
| 831 | void end_examples() |
| 832 | { |
| 833 | m_outputStr += "</ul></div>\n"; |
| 834 | } |
| 835 | |
| 836 | void begin_static_member_vars() |
| 837 | { |
| 838 | m_outputStr += "<h3 class=\"class_section_header\">static member variables</h3>\n<div class=\"members\">\n"; |
| 839 | } |
| 840 | |
| 841 | void end_static_member_vars() |
| 842 | { |
| 843 | m_outputStr += "</div>\n"; |
| 844 | } |
| 845 | |
| 846 | void begin_member_vars() |
| 847 | { |
| 848 | m_outputStr += "<h3 class=\"class_section_header\">member variables</h3>\n<div class=\"members\">\n"; |
| 849 | } |
| 850 | |
| 851 | void end_member_vars() |
| 852 | { |
| 853 | m_outputStr += "</div>\n"; |
| 854 | } |
| 855 | |
| 856 | void begin_static_member_funcs() |
| 857 | { |
| 858 | m_outputStr += "<h3 class=\"class_section_header\">static member functions</h3>\n<div class=\"members\">\n"; |
| 859 | } |
| 860 | |
| 861 | void end_static_member_funcs() |
| 862 | { |
| 863 | m_outputStr += "</div>\n"; |
| 864 | } |
| 865 | |
| 866 | void begin_ctors() // 1.5.2.0 |
| 867 | { |
| 868 | m_outputStr += "<h3 class=\"class_section_header\">constructors</h3>\n<div class=\"members\">\n"; |
| 869 | } |
| 870 | |
| 871 | void end_ctors() // 1.5.2.5 |
| 872 | { |
| 873 | m_outputStr += "</div>\n"; |
| 874 | } |
| 875 | |
| 876 | void begin_dtor() // 1.5.2.0 |
| 877 | { |
| 878 | m_outputStr += "<h3 class=\"class_section_header\">destructor</h3>\n<div class=\"members\">\n"; |
| 879 | } |
| 880 | |
| 881 | void begin_member_funcs() |
| 882 | { |
| 883 | m_outputStr += "<h3 class=\"class_section_header\">member functions</h3>\n<div class=\"members\">\n"; |
| 884 | } |
| 885 | |
| 886 | void end_member_funcs() |
| 887 | { |
| 888 | m_outputStr += "</div>\n"; |
| 889 | } |
| 890 | |
| 891 | void example(const std::string &name, const std::string &url) |
| 892 | { |
| 893 | m_outputStr += "<li><a target=\"_blank\" href=\"" + url + "\">" + name + "</a></li>\n"; |
| 894 | } |
| 895 | |
| 896 | void static_member_var(Chuck_Value * var) |
| 897 | { |
| 898 | m_outputStr += "<div class=\"member\">\n<p class=\"member_declaration\"><span class=\"" |
| 899 | + css_class_for_type(m_env_ref, var->type) + "\">" |
| 900 | + var->type->base_name; |
| 901 | // check array depth |
| 902 | if( var->type->array_depth ) |
| 903 | { |
| 904 | m_outputStr += "</span>"; |
| 905 | m_outputStr += "<span class=\"typename\">"; |
| 906 | for(int i = 0; i < var->type->array_depth; i++) |
| 907 | m_outputStr += "[]"; |
| 908 | } |
| 909 | m_outputStr += "</span> "; |
| 910 | |
| 911 | // function name |
| 912 | m_outputStr += "<span class=\"membername\">" + var->name + "</span></p>"; |
| 913 | |
| 914 | if(var->doc.size() > 0) |
| 915 | m_outputStr += "<p class=\"member_description\">" + capitalize_and_periodize(var->doc) + "</p>\n"; |
| 916 | else |
| 917 | m_outputStr += "<p class=\"empty_member_description\">No description available</p>\n"; |
| 918 | |
| 919 | m_outputStr += "</div>\n"; |
| 920 | } |
| 921 | |
| 922 | void member_var(Chuck_Value * var) |
| 923 | { |
| 924 | m_outputStr += "<div class=\"member\">\n<p class=\"member_declaration\"><span class=\"" |
| 925 | + css_class_for_type(m_env_ref, var->type) + "\">" + var->type->base_name; |
| 926 | // check array depth |
| 927 | if( var->type->array_depth ) |
| 928 | { |
| 929 | m_outputStr += "</span>"; |
| 930 | m_outputStr += "<span class=\"typename\">"; |
| 931 | for(int i = 0; i < var->type->array_depth; i++) |
| 932 | m_outputStr += "[]"; |
| 933 | } |
| 934 | m_outputStr += "</span> "; |
| 935 | |
| 936 | // member name |
| 937 | m_outputStr += "<span class=\"membername\">" + var->name + "</span></p>"; |
| 938 | |
| 939 | if(var->doc.size() > 0) |
| 940 | m_outputStr += "<p class=\"member_description\">" + capitalize_and_periodize(var->doc) + "</p>\n"; |
| 941 | else |
| 942 | m_outputStr += "<p class=\"empty_member_description\">No description available</p>\n"; |
| 943 | |
| 944 | m_outputStr += "</div>\n"; |
| 945 | } |
| 946 | |
| 947 | void begin_static_member_func(Chuck_Func * func) |
| 948 | { |
| 949 | // return type |
| 950 | m_outputStr += "<div class=\"member\">\n<p class=\"member_declaration\"><span class=\"" |
| 951 | + css_class_for_type(m_env_ref, func->def()->ret_type) + "\">" |
| 952 | + func->def()->ret_type->base_name; |
| 953 | // check array |
| 954 | if( func->def()->ret_type->array_depth ) |
| 955 | { |
| 956 | m_outputStr += "</span>"; |
| 957 | m_outputStr += "<span class=\"typename\">"; |
| 958 | for(int i = 0; i < func->def()->ret_type->array_depth; i++) |
| 959 | m_outputStr += "[]"; |
| 960 | } |
| 961 | m_outputStr += "</span> "; |
| 962 | |
| 963 | // function name |
| 964 | m_outputStr += "<span class=\"membername\">" + string(S_name(func->def()->name)) + "</span>("; |
| 965 | |
| 966 | // remember |
| 967 | m_func = func; |
| 968 | } |
| 969 | |
| 970 | void end_static_member_func() |
| 971 | { |
| 972 | // verify |
| 973 | if( !m_func ) return; |
| 974 | |
| 975 | // finish output string |
| 976 | m_outputStr += ")</p>\n"; |
| 977 | |
| 978 | if(m_func->doc.size() > 0) |
| 979 | m_outputStr += "<p class=\"member_description\">" + capitalize_and_periodize(m_func->doc) + "</p>\n"; |
| 980 | else |
| 981 | m_outputStr += "<p class=\"empty_member_description\">No description available</p>\n"; |
| 982 | |
| 983 | m_outputStr += "</div>\n"; |
| 984 | |
| 985 | // zero out |
| 986 | m_func = NULL; |
| 987 | } |
| 988 | |
| 989 | void begin_member_func(Chuck_Func * func) |
| 990 | { |
| 991 | // return type |
| 992 | m_outputStr += "<div class=\"member\">\n<p class=\"member_declaration\"><span class=\"" |
| 993 | + css_class_for_type( m_env_ref, func->def() ? func->def()->ret_type : NULL ) |
| 994 | + "\">" + (func->def() ? func->def()->ret_type->base_name.c_str() : "void"); |
| 995 | // check array |
| 996 | if( func->def() && func->def()->ret_type->array_depth ) |
| 997 | { |
| 998 | m_outputStr += "</span>"; |
| 999 | m_outputStr += "<span class=\"typename\">"; |
| 1000 | for(int i = 0; i < func->def()->ret_type->array_depth; i++) |
| 1001 | m_outputStr += "[]"; |
| 1002 | } |
| 1003 | m_outputStr += "</span> "; |
| 1004 | |
| 1005 | // function name |
| 1006 | m_outputStr += "<span class=\"membername\">" + func->base_name /* string(S_name(func->def()->name))*/ + "</span>("; |
| 1007 | |
| 1008 | // save for end_member_func() |
| 1009 | m_func = func; |
| 1010 | } |
| 1011 | |
| 1012 | void end_member_func() |
| 1013 | { |
| 1014 | // verify |
| 1015 | if( !m_func ) return; |
| 1016 | |
| 1017 | // finish output from before |
| 1018 | m_outputStr += ")</p>\n"; |
| 1019 | |
| 1020 | if( m_func->doc.size() > 0 ) |
| 1021 | m_outputStr += "<p class=\"member_description\">" + capitalize_and_periodize( m_func->doc ) + "</p>\n"; |
| 1022 | else |
| 1023 | m_outputStr += "<p class=\"empty_member_description\">No description available</p>\n"; |
| 1024 | |
| 1025 | // finish output |
| 1026 | m_outputStr += "</div>\n"; |
| 1027 | |
| 1028 | // zero out |
| 1029 | m_func = NULL; |
| 1030 | } |
| 1031 | |
| 1032 | void begin_ctor( Chuck_Func * func ) |
| 1033 | { |
| 1034 | // return type |
| 1035 | m_outputStr += "<div class=\"member\">\n<p class=\"member_declaration\">"; |
| 1036 | |
| 1037 | // function name |
| 1038 | m_outputStr += "<span class=\"membername\">" + func->base_name /* string(S_name(func->def()->name))*/ + "</span>("; |
| 1039 | |
| 1040 | // save for end_member_func() |
| 1041 | m_func = func; |
| 1042 | } |
| 1043 | |
| 1044 | void end_ctor() |
| 1045 | { |
| 1046 | // verify |
| 1047 | if( !m_func ) return; |
| 1048 | |
| 1049 | // finish output from before |
| 1050 | m_outputStr += ")</p>\n"; |
| 1051 | |
| 1052 | if( m_func->doc.size() > 0 ) |
| 1053 | m_outputStr += "<p class=\"member_description\">" + capitalize_and_periodize( m_func->doc ) + "</p>\n"; |
| 1054 | else if( m_func->is_ctor && (!m_func->def() || !m_func->def()->arg_list) ) // default ctor? |
| 1055 | m_outputStr += "<p class=\"member_description\">" + capitalize_and_periodize( "Default constructor for " + m_func->base_name ) + "</p>\n"; |
| 1056 | else |
| 1057 | m_outputStr += "<p class=\"empty_member_description\">No description available</p>\n"; |
| 1058 | |
| 1059 | // finish output |
| 1060 | m_outputStr += "</div>\n"; |
| 1061 | |
| 1062 | // zero out |
| 1063 | m_func = NULL; |
| 1064 | } |
| 1065 | |
| 1066 | void func_arg(a_Arg_List arg) |
| 1067 | { |
| 1068 | // argument type |
| 1069 | m_outputStr += "<span class=\"" + css_class_for_type(m_env_ref, arg->type) + "\">" + arg->type->base_name; |
| 1070 | // check array |
| 1071 | if( arg->type->array_depth ) |
| 1072 | { |
| 1073 | m_outputStr += "</span>"; |
| 1074 | m_outputStr += "<span class=\"typename\">"; |
| 1075 | for(int i = 0; i < arg->type->array_depth; i++) |
| 1076 | m_outputStr += "[]"; |
| 1077 | } |
| 1078 | m_outputStr += "</span> "; |
| 1079 | |
| 1080 | // argument name |
| 1081 | std::string varname = varnameclean(S_name(arg->var_decl->xid)); |
| 1082 | m_outputStr += varname; |
| 1083 | |
| 1084 | if(arg->next != NULL) |
| 1085 | m_outputStr += ", "; |
| 1086 | } |
| 1087 | |
| 1088 | public: |
| 1089 | static bool isugen( Chuck_Type *type ) { return type->ugen_info != NULL; } |
| 1090 | |
| 1091 | static std::string varnameclean( std::string vn ) |
| 1092 | { |
| 1093 | // strip [] |
| 1094 | vn.erase(std::remove(vn.begin(), vn.end(), '['), vn.end()); |
| 1095 | vn.erase(std::remove(vn.begin(), vn.end(), ']'), vn.end()); |
| 1096 | return vn; |
| 1097 | } |
| 1098 | |
| 1099 | static std::string cssclean( std::string s ) |
| 1100 | { |
| 1101 | for(int i = 0; i < s.length(); i++) |
| 1102 | { |
| 1103 | if(!isalnum(s[i])) s[i] = '_'; |
| 1104 | } |
| 1105 | return s; |
| 1106 | } |
| 1107 | |
| 1108 | static std::string css_class_for_type( Chuck_Env * env, Chuck_Type * type ) |
| 1109 | { |
| 1110 | if( !type || isprim(env, type) || isvoid(env, type) || (type->array_depth && isprim(env, type->array_type)) ) |
| 1111 | return "ckdoc_typename ckdoc_type_primitive"; |
| 1112 | else if(isugen(type)) |
| 1113 | return "ckdoc_typename ckdoc_type_ugen"; |
| 1114 | else |
| 1115 | return "ckdoc_typename ckdoc_type_object"; |
| 1116 | } |
| 1117 | }; |
| 1118 | |
| 1119 | |
| 1120 | |
| 1121 | |
| 1122 | //----------------------------------------------------------------------------- |
| 1123 | // name: renderIndex() |
| 1124 | // desc: render HTML index |
| 1125 | //----------------------------------------------------------------------------- |
| 1126 | string CKDocHTMLOutput::renderIndex( const string & title, const vector<CKDocGroup *> & groups ) |
| 1127 | { |
| 1128 | // output string stream |
| 1129 | ostringstream sout; |
| 1130 | |
| 1131 | // output index header |
| 1132 | sout << "<html>\n<head>\n"; |
| 1133 | sout << "<title>" << title << "</title>\n"; |
| 1134 | sout << "<link rel=\"stylesheet\" type=\"text/css\" href=\"ckdoc.css\" />\n"; |
| 1135 | sout << "<link rel=\"stylesheet\" type=\"text/css\" href=\"class.css\" />\n"; |
| 1136 | |
| 1137 | sout << "<meta charset=\"utf-8\">\n"; |
| 1138 | sout << "<meta name=\"keywords\" content=\"ChucK, strongly-timed,audio, programming language, computer music, Artful Design, Stanford University, CCRMA, Princeton University, SoundLab, Ge Wang, Perry Cook, design, art, computer, music, technology, engineering, education\" />\n"; |
| 1139 | sout << "<meta property=\"og:url\" content=\"https://ccrma.stanford.edu/software/chuck/doc/reference/\" />\n"; |
| 1140 | sout << "<meta property=\"og:type\" content=\"website\" />\n"; |
| 1141 | sout << "<meta property=\"og:title\" content=\"ChucK | Class Library Reference\" />\n"; |
| 1142 | sout << "<meta property=\"og:description\" content=\"ChucK programming language core class library reference, including base types, unit generators, unit analyzers, standard libraries, and more.\" />\n"; |
| 1143 | sout << "<meta name=\"author\" content=\"ChucK Team\">\n"; |
| 1144 | sout << "<meta property=\"og:image\" content=\"https://ccrma.stanford.edu/software/chuck/doc/images/chuck-logo2023w.png\" />\n"; |
| 1145 | sout << "<meta property=\"fb:app_id\" content=\"966242223397117\" /> <!--default app id-->\n"; |
| 1146 | sout << "<link rel=\"canonical\" href=\"http://chuck.stanford.edu/doc/reference\" />\n"; |
| 1147 | |
| 1148 | sout << "</head>\n"; |
| 1149 | sout << "<body>\n"; |
| 1150 | sout << "<div id=\"title\">\n"; |
| 1151 | sout << "<div class=\"titleL\">\n"; |
| 1152 | sout << "<div style=\"display: flex; align-items: center;\">"; |
| 1153 | sout << "<div class=\"inline titlelogo\"><a href=\"https://chuck.stanford.edu/\" target=\"_blank\"><img src=\"https://chuck.stanford.edu/doc/images/chuck-logo2023w.png\" /> </div>"; |
| 1154 | sout << "<div class=\"inline\"><h1>" << title << "</h1></div>\n"; |
| 1155 | sout << "</div>\n"; |
| 1156 | sout << "</div>\n"; |
| 1157 | sout << "</div>\n"; |
| 1158 | sout << "<div id=\"body\">\n"; |
| 1159 | |
| 1160 | // loop over groups |
| 1161 | for( t_CKINT i = 0; i < groups.size(); i++ ) |
| 1162 | { |
| 1163 | CKDocGroup * group = groups[i]; |
| 1164 | // type A or B output | 1.5.2.4 (ge, azaday) added |
| 1165 | // A == normal; B == group points to external CKDoc, e.g., ChuGL |
| 1166 | t_CKBOOL typeA = group->types.size() != 0; |
| 1167 | |
| 1168 | sout << "<div class=\"index_group\">\n"; |
| 1169 | sout << "<div class=\"index_group_title\">\n"; |
| 1170 | |
| 1171 | // group name, either linking to generate page (Type A) to external page (Type B) |
| 1172 | // 1.5.2.4 (ge, azaday) add type B support |
| 1173 | if( typeA ) sout << "<h2><a href=\"" << group->shortName << ".html\">"; |
| 1174 | else sout << "<h2><a target=\"_blank\" href=\"" << group->shortName << "\">"; |
| 1175 | sout << group->name << "</a></h2>\n"; |
| 1176 | |
| 1177 | sout << "<p class=\"index_group_desc\">" << group->desc << "</p>\n"; |
| 1178 | sout << "</div>\n"; |
| 1179 | |
| 1180 | // type A == normal |
| 1181 | if( typeA ) |
| 1182 | { |
| 1183 | sout << "<div class=\"index_group_classes\">\n"; |
| 1184 | sout << "<p>\n"; |
| 1185 | for( t_CKINT j = 0; j < group->types.size(); j++ ) |
| 1186 | { |
| 1187 | Chuck_Type * type = group->types[j]; |
| 1188 | if( !type ) continue; |
| 1189 | string cssClass = css_class_for_type( m_env_ref, type ); |
| 1190 | // TODO: check for array_depth |
| 1191 | sout << "<a href=\"" << group->shortName << ".html#" << type->base_name << "\" class=\"" << cssClass << "\">" << type->base_name << "</a>\n"; |
| 1192 | } |
| 1193 | } |
| 1194 | else // type B | 1.5.2.4 (ge, azaday) added |
| 1195 | { |
| 1196 | sout << "<div class=\"index_group_external\">\n"; |
| 1197 | sout << "<p>\n"; |
| 1198 | sout << group->longDesc << "\n"; |
| 1199 | } |
| 1200 | |
| 1201 | sout << "</p>\n"; |
| 1202 | sout << "</div>\n"; |
| 1203 | sout << "<div class=\"clear\"></div>\n"; |
| 1204 | sout << "</div>\n"; |
| 1205 | } |
| 1206 | sout << "</div>\n"; |
| 1207 | sout << "</body>\n</html>\n"; |
| 1208 | |
| 1209 | // return the string literal |
| 1210 | return sout.str(); |
| 1211 | }; |
| 1212 | |
| 1213 | |
| 1214 | |
| 1215 | //----------------------------------------------------------------------------- |
| 1216 | // name: CKDoc() |
| 1217 | // desc: constructor |
| 1218 | //----------------------------------------------------------------------------- |
| 1219 | CKDoc::CKDoc( Chuck_VM * vm ) |
| 1220 | { |
| 1221 | // copy VM reference |
| 1222 | m_vm_ref = vm; |
| 1223 | // reset |
| 1224 | m_format = FORMAT_NONE; |
| 1225 | m_output = NULL; |
| 1226 | // enable alphabetical sorting by default |
| 1227 | m_sort_entries = true; |
| 1228 | |
| 1229 | // default |
| 1230 | setOutputFormat( FORMAT_HTML ); |
| 1231 | } |
| 1232 | |
| 1233 | |
| 1234 | |
| 1235 | |
| 1236 | //----------------------------------------------------------------------------- |
| 1237 | // name: ~CKDoc() |
| 1238 | // desc: destructor |
| 1239 | //----------------------------------------------------------------------------- |
| 1240 | CKDoc::~CKDoc() |
| 1241 | { |
| 1242 | // clear groups |
| 1243 | clearGroups(); |
| 1244 | // clear output generator |
| 1245 | clearOutput(); |
| 1246 | // zero out |
| 1247 | m_vm_ref = NULL; |
| 1248 | } |
| 1249 | |
| 1250 | |
| 1251 | |
| 1252 | |
| 1253 | //----------------------------------------------------------------------------- |
| 1254 | // name: clearGroups() |
| 1255 | // desc: clear all added groups |
| 1256 | //----------------------------------------------------------------------------- |
| 1257 | void CKDoc::clearGroups() |
| 1258 | { |
| 1259 | // iterate groups |
| 1260 | for( t_CKINT i = 0; i < m_groups.size(); i++ ) |
| 1261 | { |
| 1262 | // iterate over a group |
| 1263 | for( t_CKINT j = 0; j < m_groups[i]->types.size(); j++ ) |
| 1264 | { |
| 1265 | // release ref count |
| 1266 | CK_SAFE_RELEASE( m_groups[i]->types[j] ); |
| 1267 | } |
| 1268 | // deallocate the group struct |
| 1269 | CK_SAFE_DELETE( m_groups[i] ); |
| 1270 | } |
| 1271 | |
| 1272 | // clear the arrar |
| 1273 | m_groups.clear(); |
| 1274 | } |
| 1275 | |
| 1276 | |
| 1277 | |
| 1278 | |
| 1279 | //----------------------------------------------------------------------------- |
| 1280 | // name: clearOutput() |
| 1281 | // desc: clear output generator |
| 1282 | //----------------------------------------------------------------------------- |
| 1283 | void CKDoc::clearOutput() |
| 1284 | { |
| 1285 | // reste |
| 1286 | m_format = FORMAT_NONE; |
| 1287 | // deallocate |
| 1288 | CK_SAFE_DELETE( m_output ); |
| 1289 | } |
| 1290 | |
| 1291 | |
| 1292 | |
| 1293 | |
| 1294 | //----------------------------------------------------------------------------- |
| 1295 | // name: addGroup() |
| 1296 | // add a group of types to document |
| 1297 | //----------------------------------------------------------------------------- |
| 1298 | t_CKBOOL CKDoc::addGroup( const vector<Chuck_Type *> & types, const string & name, |
| 1299 | const string & shortName, const string & description ) |
| 1300 | { |
| 1301 | // trim |
| 1302 | string shortNameTrim = trim(shortName); |
| 1303 | // check for empty string; shortName is needed as filename for outputToDir() |
| 1304 | if( shortNameTrim == "" ) |
| 1305 | { |
| 1306 | EM_error3( "[CKDoc.addGroup()]: 'shortName' parameter cannot be empty" ); |
| 1307 | return FALSE; |
| 1308 | } |
| 1309 | // check for conflicts |
| 1310 | for( t_CKINT i = 0; i < m_groups.size(); i++ ) |
| 1311 | { |
| 1312 | if( shortNameTrim == m_groups[i]->shortName ) |
| 1313 | { |
| 1314 | EM_error3( "[CKDoc.addGroup()]: duplicate shortName found: '%s'...", shortNameTrim.c_str() ); |
| 1315 | return FALSE; |
| 1316 | } |
| 1317 | } |
| 1318 | |
| 1319 | // allocate group |
| 1320 | CKDocGroup * group = new CKDocGroup(); |
| 1321 | // check |
| 1322 | if( !group ) |
| 1323 | { |
| 1324 | EM_error3( "[CKDoc.addGroup()]: could not allocate new memory...bailing out" ); |
| 1325 | return FALSE; |
| 1326 | } |
| 1327 | // copy |
| 1328 | group->name = trim(name); |
| 1329 | group->shortName = shortNameTrim; |
| 1330 | group->desc = trim(description); |
| 1331 | // iterate |
| 1332 | for( t_CKINT i = 0; i < types.size(); i++ ) |
| 1333 | { |
| 1334 | // filter out NULL elements |
| 1335 | if( types[i] == NULL ) continue; |
| 1336 | |
| 1337 | // ref count |
| 1338 | CK_SAFE_ADD_REF( types[i] ); |
| 1339 | // append |
| 1340 | group->types.push_back( types[i] ); |
| 1341 | } |
| 1342 | // add to groups |
| 1343 | m_groups.push_back( group ); |
| 1344 | |
| 1345 | return TRUE; |
| 1346 | } |
| 1347 | |
| 1348 | |
| 1349 | |
| 1350 | |
| 1351 | //----------------------------------------------------------------------------- |
| 1352 | // name: addGroupExt() | 1.5.2.4 (ge) added |
| 1353 | // desc: add an external group to document |
| 1354 | //----------------------------------------------------------------------------- |
| 1355 | t_CKBOOL CKDoc::addGroupExt( const string & name, const string & URL, |
| 1356 | const string & desc, const string & longDesc ) |
| 1357 | { |
| 1358 | // allocate group |
| 1359 | CKDocGroup * group = new CKDocGroup(); |
| 1360 | // check |
| 1361 | if( !group ) |
| 1362 | { |
| 1363 | EM_error3( "[CKDoc.addGroup()]: could not allocate new memory...bailing out" ); |
| 1364 | return FALSE; |
| 1365 | } |
| 1366 | |
| 1367 | // copy |
| 1368 | group->name = trim(name); |
| 1369 | group->shortName = trim(URL); |
| 1370 | group->desc = trim(desc); |
| 1371 | group->longDesc = trim(longDesc); |
| 1372 | |
| 1373 | // add to groups |
| 1374 | m_groups.push_back( group ); |
| 1375 | |
| 1376 | return TRUE; |
| 1377 | } |
| 1378 | |
| 1379 | |
| 1380 | |
| 1381 | //----------------------------------------------------------------------------- |
| 1382 | // name: numGroups() |
| 1383 | // desc: get number of groups |
| 1384 | //----------------------------------------------------------------------------- |
| 1385 | t_CKINT CKDoc::numGroups() const |
| 1386 | { return m_groups.size(); } |
| 1387 | |
| 1388 | |
| 1389 | |
| 1390 | |
| 1391 | //----------------------------------------------------------------------------- |
| 1392 | // name: setOutputFormat() |
| 1393 | // desc: set output format: CKDoc.HTML, CKDoc.TEXT, CKDoc.MARKDOWN, CKDoc.JSON |
| 1394 | //----------------------------------------------------------------------------- |
| 1395 | t_CKBOOL CKDoc::setOutputFormat( t_CKINT which ) |
| 1396 | { |
| 1397 | // clear output |
| 1398 | clearOutput(); |
| 1399 | // format names |
| 1400 | const char * formats[] = { "NONE", "HTML", "TEXT", "MARKDOWN", "JSON" }; |
| 1401 | |
| 1402 | // copy for now |
| 1403 | m_format = which; |
| 1404 | // check |
| 1405 | switch( which ) |
| 1406 | { |
| 1407 | // currently supported |
| 1408 | case FORMAT_NONE: break; |
| 1409 | case FORMAT_HTML: |
| 1410 | m_output = new CKDocHTMLOutput( m_vm_ref ); |
| 1411 | break; |
| 1412 | case FORMAT_JSON: |
| 1413 | m_output = new CKDocJSONOutput( m_vm_ref ); |
| 1414 | break; |
| 1415 | |
| 1416 | // currently unsupported |
| 1417 | case FORMAT_TEXT: |
| 1418 | case FORMAT_MARKDOWN: |
| 1419 | EM_error3( "[CKDoc]: unsupported format '%s'...", formats[which] ); |
| 1420 | goto error; |
| 1421 | break; |
| 1422 | |
| 1423 | // unrecognized |
| 1424 | default: |
| 1425 | EM_error3( "[CKDoc]: unrecognized format ID '%i'...", which ); |
| 1426 | goto error; |
| 1427 | } |
| 1428 | |
| 1429 | return TRUE; |
| 1430 | |
| 1431 | error: |
| 1432 | // set to none |
| 1433 | m_format = FORMAT_NONE; |
| 1434 | // return false |
| 1435 | return FALSE; |
| 1436 | } |
| 1437 | |
| 1438 | |
| 1439 | |
| 1440 | |
| 1441 | //----------------------------------------------------------------------------- |
| 1442 | // name: getOutputFormat() |
| 1443 | // desc: get output format |
| 1444 | //----------------------------------------------------------------------------- |
| 1445 | t_CKINT CKDoc::getOutputFormat() const |
| 1446 | { |
| 1447 | return m_format; |
| 1448 | } |
| 1449 | |
| 1450 | |
| 1451 | |
| 1452 | |
| 1453 | //----------------------------------------------------------------------------- |
| 1454 | // name: setExamplesRoot() |
| 1455 | // desc: set base examples root path |
| 1456 | //----------------------------------------------------------------------------- |
| 1457 | void CKDoc::setExamplesRoot( const string & path ) |
| 1458 | { |
| 1459 | // set |
| 1460 | m_examplesRoot = path; |
| 1461 | // trim |
| 1462 | m_examplesRoot = trim( m_examplesRoot ); |
| 1463 | // process |
| 1464 | if( m_examplesRoot.length() == 0 ) |
| 1465 | { m_examplesRoot = "./"; } |
| 1466 | // check for trailing / |
| 1467 | if( m_examplesRoot[m_examplesRoot.length()-1] != '/' ) |
| 1468 | { m_examplesRoot += "/"; } |
| 1469 | } |
| 1470 | |
| 1471 | |
| 1472 | |
| 1473 | |
| 1474 | //----------------------------------------------------------------------------- |
| 1475 | // name: getExamplesRoot() |
| 1476 | // desc: get base examples root path |
| 1477 | //----------------------------------------------------------------------------- |
| 1478 | string CKDoc::getExamplesRoot() const |
| 1479 | { |
| 1480 | // set |
| 1481 | return m_examplesRoot; |
| 1482 | } |
| 1483 | |
| 1484 | |
| 1485 | |
| 1486 | |
| 1487 | //----------------------------------------------------------------------------- |
| 1488 | // name: genIndex() |
| 1489 | // desc: generate top-level index file; return as string |
| 1490 | //----------------------------------------------------------------------------- |
| 1491 | string CKDoc::genIndex( const string & title ) |
| 1492 | { |
| 1493 | // check |
| 1494 | if( !m_output ) return ""; |
| 1495 | // generate index |
| 1496 | return m_output->renderIndex( title, m_groups ); |
| 1497 | } |
| 1498 | |
| 1499 | |
| 1500 | |
| 1501 | |
| 1502 | //----------------------------------------------------------------------------- |
| 1503 | // name: genCSS() |
| 1504 | // desc: generate CSS; return as string |
| 1505 | //----------------------------------------------------------------------------- |
| 1506 | string CKDoc::genCSS() |
| 1507 | { |
| 1508 | // return the string literal |
| 1509 | return m_ckdocCSS; |
| 1510 | } |
| 1511 | |
| 1512 | |
| 1513 | |
| 1514 | |
| 1515 | //----------------------------------------------------------------------------- |
| 1516 | // name: genGroups() |
| 1517 | // desc: generate all added groups, return each in a separate entry |
| 1518 | //----------------------------------------------------------------------------- |
| 1519 | void CKDoc::genGroups( vector<string> & results ) |
| 1520 | { |
| 1521 | // clear results array |
| 1522 | results.clear(); |
| 1523 | // set the size |
| 1524 | results.resize( m_groups.size() ); |
| 1525 | |
| 1526 | // iterate over added groups |
| 1527 | for( t_CKINT i = 0; i < m_groups.size(); i++ ) |
| 1528 | { |
| 1529 | // generate each group |
| 1530 | results[i] = genGroup( m_groups[i], TRUE ); |
| 1531 | } |
| 1532 | } |
| 1533 | |
| 1534 | |
| 1535 | |
| 1536 | |
| 1537 | //----------------------------------------------------------------------------- |
| 1538 | // name: genGroup() |
| 1539 | // desc: generate documentation for a group |
| 1540 | //----------------------------------------------------------------------------- |
| 1541 | string CKDoc::genGroup( CKDocGroup * group, t_CKBOOL clearOutput ) |
| 1542 | { |
| 1543 | // check |
| 1544 | if( m_output == NULL ) return "[NO OUTPUT FORMAT SELECTED (genGroup)]"; |
| 1545 | |
| 1546 | bool do_toc = true; |
| 1547 | bool do_heading = true; |
| 1548 | list<string> type_args; |
| 1549 | |
| 1550 | // the output |
| 1551 | CKDocOutput * output = m_output; |
| 1552 | // clear output |
| 1553 | if( clearOutput ) output->clear(); |
| 1554 | |
| 1555 | // output group title |
| 1556 | output->begin( group->name ); |
| 1557 | // do heading |
| 1558 | if( do_heading ) output->heading(); |
| 1559 | |
| 1560 | // begin output body |
| 1561 | output->begin_body(); |
| 1562 | |
| 1563 | // table of contents |
| 1564 | if( do_toc ) |
| 1565 | { |
| 1566 | // begin TOC |
| 1567 | output->begin_toc(); |
| 1568 | |
| 1569 | // iterate |
| 1570 | for( vector<Chuck_Type *>::const_iterator t = group->types.begin(); t != group->types.end(); t++ ) |
| 1571 | { |
| 1572 | // get the current type |
| 1573 | Chuck_Type * type = *t; |
| 1574 | // skip |
| 1575 | // if( skip(type->base_name) ) continue; |
| 1576 | // output the type in TOC |
| 1577 | output->toc_class( type ); |
| 1578 | } |
| 1579 | |
| 1580 | // end TOC |
| 1581 | output->end_toc(); |
| 1582 | } |
| 1583 | |
| 1584 | // begin type contents |
| 1585 | output->begin_classes( group ); |
| 1586 | |
| 1587 | // iterate |
| 1588 | for( vector<Chuck_Type *>::const_iterator t = group->types.begin(); t != group->types.end(); t++ ) |
| 1589 | { |
| 1590 | // skip |
| 1591 | // if( skip(type->base_name) ) continue; |
| 1592 | // gen type, don't clear output |
| 1593 | genType( *t, FALSE ); |
| 1594 | } |
| 1595 | |
| 1596 | // end types |
| 1597 | output->end_classes(); |
| 1598 | // end file |
| 1599 | output->end_body(); |
| 1600 | // end output |
| 1601 | output->end(); |
| 1602 | |
| 1603 | // return output string |
| 1604 | return output->str(); |
| 1605 | } |
| 1606 | |
| 1607 | |
| 1608 | |
| 1609 | |
| 1610 | //----------------------------------------------------------------------------- |
| 1611 | // name: genType() |
| 1612 | // desc: generate documentation for a single Type |
| 1613 | //----------------------------------------------------------------------------- |
| 1614 | string CKDoc::genType( Chuck_Type * type, t_CKBOOL clearOutput ) |
| 1615 | { |
| 1616 | // check |
| 1617 | if( m_output == NULL ) return "[NO OUTPUT FORMAT SELECTED (getType)]"; |
| 1618 | |
| 1619 | // the output |
| 1620 | CKDocOutput * output = m_output; |
| 1621 | // clear it |
| 1622 | if( clearOutput ) output->clear(); |
| 1623 | |
| 1624 | // begin the type |
| 1625 | output->begin_class( type, m_groups ); |
| 1626 | |
| 1627 | // output examples |
| 1628 | if( type->examples.size() ) |
| 1629 | { |
| 1630 | // begin examples |
| 1631 | output->begin_examples(); |
| 1632 | |
| 1633 | // iterate over examples |
| 1634 | for( vector<string>::iterator _ex = type->examples.begin(); _ex != type->examples.end(); _ex++ ) |
| 1635 | { |
| 1636 | string ex = *_ex; |
| 1637 | string name; |
| 1638 | string url; |
| 1639 | |
| 1640 | // test for absolute vs. relative URL |
| 1641 | if( ex.find("http://") == 0 || ex.find("https://") == 0 ) |
| 1642 | { |
| 1643 | // absolute URL |
| 1644 | url = ex; |
| 1645 | // find the example name without path |
| 1646 | std::basic_string<char>::size_type pos = ex.rfind('/'); |
| 1647 | if( pos != string::npos ) |
| 1648 | name = string(ex, pos+1); |
| 1649 | else |
| 1650 | name = ex; |
| 1651 | } |
| 1652 | else |
| 1653 | { |
| 1654 | // relative URL |
| 1655 | url = m_examplesRoot + ex; |
| 1656 | name = ex; |
| 1657 | } |
| 1658 | // output examples |
| 1659 | output->example(name, url); |
| 1660 | } |
| 1661 | |
| 1662 | // done with examples |
| 1663 | output->end_examples(); |
| 1664 | } |
| 1665 | |
| 1666 | // check type info |
| 1667 | if( type->nspc ) |
| 1668 | { |
| 1669 | // get functions |
| 1670 | vector<Chuck_Func *> funcs; |
| 1671 | type->nspc->get_funcs( funcs ); |
| 1672 | // get values |
| 1673 | vector<Chuck_Value *> vars; |
| 1674 | type->nspc->get_values( vars ); |
| 1675 | // function names |
| 1676 | map<string, int> func_names; |
| 1677 | |
| 1678 | // member and static functions and values |
| 1679 | vector<Chuck_Func *> ctors; |
| 1680 | Chuck_Func * dtor = NULL; |
| 1681 | vector<Chuck_Func *> mfuncs; |
| 1682 | vector<Chuck_Func *> sfuncs; |
| 1683 | vector<Chuck_Value *> mvars; |
| 1684 | vector<Chuck_Value *> svars; |
| 1685 | // fprintf(stderr, "### %lu vars\n", vars.size()); |
| 1686 | |
| 1687 | // iterate through values |
| 1688 | for( vector<Chuck_Value *>::iterator v = vars.begin(); v != vars.end(); v++ ) |
| 1689 | { |
| 1690 | // the value |
| 1691 | Chuck_Value * value = *v; |
| 1692 | |
| 1693 | // check |
| 1694 | if(value == NULL) continue; |
| 1695 | // zero length name |
| 1696 | if( value->name.length() == 0 ) |
| 1697 | continue; |
| 1698 | // special internal values |
| 1699 | if( value->name.size() && value->name[0] == '@' ) |
| 1700 | continue; |
| 1701 | // value is a function |
| 1702 | if( isa( value->type, value->type->env()->ckt_function ) ) |
| 1703 | continue; |
| 1704 | // check if should skip | 1.5.4.5 (ge) |
| 1705 | if( CKDoc::shouldSkip(value) ) continue; |
| 1706 | |
| 1707 | // static or instance? |
| 1708 | if( value->is_static ) svars.push_back( value ); |
| 1709 | else mvars.push_back( value ); |
| 1710 | } |
| 1711 | |
| 1712 | // iterate over functions |
| 1713 | for( vector<Chuck_Func *>::iterator f = funcs.begin(); f != funcs.end(); f++ ) |
| 1714 | { |
| 1715 | // the function |
| 1716 | Chuck_Func * func = *f; |
| 1717 | |
| 1718 | // check |
| 1719 | if( func == NULL ) continue; |
| 1720 | // check if should skip | 1.5.4.5 (ge) |
| 1721 | if( CKDoc::shouldSkip(func) ) continue; |
| 1722 | |
| 1723 | // if already seen (overloaded?) |
| 1724 | if( func_names.count(func->name) ) continue; |
| 1725 | // first one |
| 1726 | func_names[func->name] = 1; |
| 1727 | // static or instance? |
| 1728 | if( func->is_static ) sfuncs.push_back(func); |
| 1729 | else |
| 1730 | { |
| 1731 | // constructor? |
| 1732 | if( func->is_ctor ) ctors.push_back(func); |
| 1733 | // destructor? |
| 1734 | else if( func->is_dtor ) dtor = func; |
| 1735 | // other member function? |
| 1736 | else mfuncs.push_back(func); |
| 1737 | } |
| 1738 | } |
| 1739 | |
| 1740 | // sort | 1.5.2.5 (@kellyyyyyyyyyyyyyyyy @azaday) added check |
| 1741 | if( m_sort_entries ) |
| 1742 | { |
| 1743 | sort( svars.begin(), svars.end(), ck_comp_value ); |
| 1744 | sort( mvars.begin(), mvars.end(), ck_comp_value ); |
| 1745 | sort( sfuncs.begin(), sfuncs.end(), ck_comp_func ); |
| 1746 | sort( mfuncs.begin(), mfuncs.end(), ck_comp_func ); |
| 1747 | sort( ctors.begin(), ctors.end(), ck_comp_func_args ); |
| 1748 | } |
| 1749 | |
| 1750 | // whether to potentially insert a default constructor | 1.5.2.0 |
| 1751 | t_CKBOOL insertDefaultCtor = type_engine_has_implicit_def_ctor( type ); |
| 1752 | |
| 1753 | // constructors | 1.5.2.0 (ge) added |
| 1754 | if( ctors.size() || insertDefaultCtor ) |
| 1755 | { |
| 1756 | // begin constructors |
| 1757 | output->begin_ctors(); |
| 1758 | |
| 1759 | // add default constructor, if non-explicitly specified |
| 1760 | if( ((ctors.size() == 0 || (ctors.size() && ctors[0]->def()->arg_list))) && insertDefaultCtor ) |
| 1761 | { |
| 1762 | Chuck_Func ftemp; |
| 1763 | ftemp.base_name = type->base_name; |
| 1764 | ftemp.doc = "default constructor for " + type->base_name; |
| 1765 | // begin the func |
| 1766 | output->begin_ctor( &ftemp ); |
| 1767 | // but don't use the args |
| 1768 | output->end_ctor(); |
| 1769 | } |
| 1770 | |
| 1771 | // iterate |
| 1772 | for( vector<Chuck_Func *>::iterator f = ctors.begin(); f != ctors.end(); f++ ) |
| 1773 | { |
| 1774 | // the func |
| 1775 | Chuck_Func * func = *f; |
| 1776 | // begin the func |
| 1777 | output->begin_ctor(func); |
| 1778 | // argument list |
| 1779 | a_Arg_List args = func->def()->arg_list; |
| 1780 | while(args != NULL) |
| 1781 | { |
| 1782 | // output argument |
| 1783 | output->func_arg(args); |
| 1784 | args = args->next; |
| 1785 | } |
| 1786 | // end the constructor |
| 1787 | output->end_ctor(); |
| 1788 | } |
| 1789 | |
| 1790 | // end member functions |
| 1791 | output->end_ctors(); |
| 1792 | } |
| 1793 | |
| 1794 | // destructor | 1.5.2.0 (ge) added but not added |
| 1795 | // if( dtor ) |
| 1796 | // { |
| 1797 | // // begin member functions |
| 1798 | // output->begin_dtor(); |
| 1799 | // // begin the func | no args |
| 1800 | // output->begin_member_func(dtor); |
| 1801 | // // end the func |
| 1802 | // output->end_member_func(); |
| 1803 | // // end member functions |
| 1804 | // output->end_member_funcs(); |
| 1805 | // } |
| 1806 | |
| 1807 | // member functions |
| 1808 | if( mfuncs.size() ) |
| 1809 | { |
| 1810 | // begin member functions |
| 1811 | output->begin_member_funcs(); |
| 1812 | // iterate |
| 1813 | for( vector<Chuck_Func *>::iterator f = mfuncs.begin(); f != mfuncs.end(); f++ ) |
| 1814 | { |
| 1815 | // the func |
| 1816 | Chuck_Func * func = *f; |
| 1817 | // begin the func |
| 1818 | output->begin_member_func(func); |
| 1819 | // argument list |
| 1820 | a_Arg_List args = func->def()->arg_list; |
| 1821 | while(args != NULL) |
| 1822 | { |
| 1823 | // output argument |
| 1824 | output->func_arg(args); |
| 1825 | args = args->next; |
| 1826 | } |
| 1827 | // end the func |
| 1828 | output->end_member_func(); |
| 1829 | } |
| 1830 | // end member functions |
| 1831 | output->end_member_funcs(); |
| 1832 | } |
| 1833 | |
| 1834 | // static functions |
| 1835 | if( sfuncs.size() ) |
| 1836 | { |
| 1837 | // begin static functions |
| 1838 | output->begin_static_member_funcs(); |
| 1839 | // iterate |
| 1840 | for( vector<Chuck_Func *>::iterator f = sfuncs.begin(); f != sfuncs.end(); f++ ) |
| 1841 | { |
| 1842 | // the func |
| 1843 | Chuck_Func * func = *f; |
| 1844 | // begin output |
| 1845 | output->begin_static_member_func(func); |
| 1846 | // argument list |
| 1847 | a_Arg_List args = func->def()->arg_list; |
| 1848 | while(args != NULL) |
| 1849 | { |
| 1850 | // output argument |
| 1851 | output->func_arg( args ); |
| 1852 | args = args->next; |
| 1853 | } |
| 1854 | // end output |
| 1855 | output->end_static_member_func(); |
| 1856 | } |
| 1857 | // end static functions |
| 1858 | output->end_static_member_funcs(); |
| 1859 | } |
| 1860 | |
| 1861 | // member vars |
| 1862 | if( mvars.size() ) |
| 1863 | { |
| 1864 | // start |
| 1865 | output->begin_member_vars(); |
| 1866 | // iterate |
| 1867 | for( vector<Chuck_Value *>::iterator v = mvars.begin(); v != mvars.end(); v++ ) |
| 1868 | output->member_var(*v); |
| 1869 | // end |
| 1870 | output->end_member_vars(); |
| 1871 | } |
| 1872 | |
| 1873 | // static vars |
| 1874 | if( svars.size() ) |
| 1875 | { |
| 1876 | // start output |
| 1877 | output->begin_static_member_vars(); |
| 1878 | // iterate |
| 1879 | for( vector<Chuck_Value *>::iterator v = svars.begin(); v != svars.end(); v++ ) |
| 1880 | output->static_member_var(*v); |
| 1881 | // end output |
| 1882 | output->end_static_member_vars(); |
| 1883 | } |
| 1884 | } |
| 1885 | // end the type |
| 1886 | output->end_class(); |
| 1887 | |
| 1888 | // return result |
| 1889 | return output->str(); |
| 1890 | } |
| 1891 | |
| 1892 | |
| 1893 | |
| 1894 | |
| 1895 | #define CKDOC_HIDDEN_STRING "(hidden)" |
| 1896 | //----------------------------------------------------------------------------- |
| 1897 | // name: shouldSkip() |
| 1898 | // desc: whether to skip an entry in the final output | 1.5.4.5 (ge) added |
| 1899 | //----------------------------------------------------------------------------- |
| 1900 | t_CKBOOL CKDoc::shouldSkip( const std::string & docStr ) |
| 1901 | { |
| 1902 | return docStr.find( CKDOC_HIDDEN_STRING ) != std::string::npos; |
| 1903 | } |
| 1904 | |
| 1905 | |
| 1906 | |
| 1907 | |
| 1908 | //----------------------------------------------------------------------------- |
| 1909 | // name: shouldSkip() |
| 1910 | // desc: whether to skip a function in the final output | 1.5.4.5 (ge) added |
| 1911 | //----------------------------------------------------------------------------- |
| 1912 | t_CKBOOL CKDoc::shouldSkip( const Chuck_Func * func ) |
| 1913 | { |
| 1914 | if( !func ) return TRUE; |
| 1915 | return func->doc.find( CKDOC_HIDDEN_STRING ) != std::string::npos; |
| 1916 | } |
| 1917 | |
| 1918 | |
| 1919 | |
| 1920 | |
| 1921 | //----------------------------------------------------------------------------- |
| 1922 | // name: shouldSkip() |
| 1923 | // desc: whether to skip an entry in the final output | 1.5.4.5 (ge) added |
| 1924 | //----------------------------------------------------------------------------- |
| 1925 | t_CKBOOL CKDoc::shouldSkip( const Chuck_Value * var ) |
| 1926 | { |
| 1927 | if( !var ) return TRUE; |
| 1928 | return var->doc.find( CKDOC_HIDDEN_STRING ) != std::string::npos; |
| 1929 | } |
| 1930 | |
| 1931 | |
| 1932 | |
| 1933 | |
| 1934 | //----------------------------------------------------------------------------- |
| 1935 | // name: outputToDir() |
| 1936 | // desc: generate everything as files into the output directory |
| 1937 | //----------------------------------------------------------------------------- |
| 1938 | t_CKBOOL CKDoc::outputToDir( const string & outputDir, const string & indexTitle ) |
| 1939 | { |
| 1940 | // groups content |
| 1941 | vector<string> groupOutput; |
| 1942 | // trim |
| 1943 | string path = trim( outputDir ); |
| 1944 | // process |
| 1945 | if( path.length() == 0 ) { path = "./"; } |
| 1946 | // check for trailing / |
| 1947 | if( path[path.length()-1] != '/' ) { path += "/"; } |
| 1948 | // clear output |
| 1949 | m_output->clear(); |
| 1950 | |
| 1951 | // gen index |
| 1952 | if( !outputToFile( path + "index" + m_output->fileExtension(), genIndex( indexTitle ) ) ) goto error; |
| 1953 | |
| 1954 | // if format is HTML |
| 1955 | if( getOutputFormat() == FORMAT_HTML ) |
| 1956 | { |
| 1957 | // gen CSS |
| 1958 | if( !outputToFile( path + "ckdoc.css", genCSS() ) ) goto error; |
| 1959 | } |
| 1960 | |
| 1961 | // gen groups |
| 1962 | genGroups( groupOutput ); |
| 1963 | |
| 1964 | // for each group |
| 1965 | for( t_CKINT i = 0; i < m_groups.size(); i++ ) |
| 1966 | { |
| 1967 | // check if Type A or Type B | 1.5.2.4 (ge) added check to distinguish group type |
| 1968 | if( m_groups[i]->types.size() ) |
| 1969 | { |
| 1970 | // not external, output new file |
| 1971 | if( !outputToFile( path + m_groups[i]->shortName + m_output->fileExtension(), groupOutput[i] ) ) |
| 1972 | goto error; |
| 1973 | } |
| 1974 | } |
| 1975 | |
| 1976 | // done |
| 1977 | return TRUE; |
| 1978 | |
| 1979 | error: |
| 1980 | // error |
| 1981 | EM_error3( "CKDoc: error encountered in outputToDir(...); bailing out..." ); |
| 1982 | return FALSE; |
| 1983 | } |
| 1984 | |
| 1985 | |
| 1986 | |
| 1987 | |
| 1988 | //----------------------------------------------------------------------------- |
| 1989 | // name: outputToFile() |
| 1990 | // desc: write string to file |
| 1991 | //----------------------------------------------------------------------------- |
| 1992 | t_CKBOOL CKDoc::outputToFile( const std::string & filename, const std::string & content ) |
| 1993 | { |
| 1994 | // open file |
| 1995 | ofstream fout( filename ); |
| 1996 | // if not good |
| 1997 | if( !fout.good() ) |
| 1998 | { |
| 1999 | EM_error3( "CKDoc: cannot open file '%s' for output...", filename.c_str() ); |
| 2000 | return FALSE; |
| 2001 | } |
| 2002 | // write |
| 2003 | fout << content; |
| 2004 | // done |
| 2005 | fout.close(); |
| 2006 | // success |
| 2007 | return TRUE; |
| 2008 | } |
| 2009 | |
| 2010 | |
| 2011 | |
| 2012 | |
| 2013 | //----------------------------------------------------------------------------- |
| 2014 | // CKDoc implementation |
| 2015 | //----------------------------------------------------------------------------- |
| 2016 | CK_DLL_CTOR( CKDoc_ctor ) |
| 2017 | { |
| 2018 | CKDoc * ckdoc = new CKDoc(VM); |
| 2019 | OBJ_MEMBER_UINT( SELF, CKDoc_offset_data ) = (t_CKUINT)ckdoc; |
| 2020 | } |
| 2021 | |
| 2022 | CK_DLL_DTOR( CKDoc_dtor ) |
| 2023 | { |
| 2024 | CKDoc * ckdoc = (CKDoc *)OBJ_MEMBER_UINT( SELF, CKDoc_offset_data ); |
| 2025 | CK_SAFE_DELETE( ckdoc ); |
| 2026 | OBJ_MEMBER_UINT( SELF, CKDoc_offset_data ) = 0; |
| 2027 | } |
| 2028 | |
| 2029 | CK_DLL_MFUN( CKDoc_addGroup_type ) |
| 2030 | { |
| 2031 | CKDoc * ckdoc = (CKDoc *)OBJ_MEMBER_UINT(SELF, CKDoc_offset_data); |
| 2032 | Chuck_ArrayInt * typeArray = (Chuck_ArrayInt *)GET_NEXT_OBJECT(ARGS); |
| 2033 | Chuck_String * groupName = GET_NEXT_STRING(ARGS); |
| 2034 | Chuck_String * shortName = GET_NEXT_STRING(ARGS); |
| 2035 | Chuck_String * description = GET_NEXT_STRING(ARGS); |
| 2036 | |
| 2037 | // check if null |
| 2038 | if( typeArray == NULL ) |
| 2039 | { |
| 2040 | CK_FPRINTF_STDERR( "CKDoc.addGroup(): null 'types' array; nothing added...\n" ); |
| 2041 | goto error; |
| 2042 | } |
| 2043 | else if( shortName == NULL || shortName->str() == "" ) |
| 2044 | { |
| 2045 | CK_FPRINTF_STDERR( "CKDoc.addGroup(): 'shortName' must be non-empty and unique; nothing added...\n" ); |
| 2046 | goto error; |
| 2047 | } |
| 2048 | else |
| 2049 | { |
| 2050 | vector<Chuck_Type *> types; |
| 2051 | for( int i = 0; i < typeArray->m_vector.size(); i++ ) |
| 2052 | { |
| 2053 | // get pointer as chuck string |
| 2054 | Chuck_Type * t = (Chuck_Type *)typeArray->m_vector[i]; |
| 2055 | // check |
| 2056 | if( t != NULL ) |
| 2057 | { |
| 2058 | // append |
| 2059 | types.push_back( t ); |
| 2060 | } |
| 2061 | } |
| 2062 | // check |
| 2063 | if( types.size() == 0 ) |
| 2064 | { |
| 2065 | CK_FPRINTF_STDERR( "CKDoc.addGroup(): empty 'types' array; nothing added...\n" ); |
| 2066 | goto error; |
| 2067 | } |
| 2068 | |
| 2069 | // add group and return success code |
| 2070 | RETURN->v_int = ckdoc->addGroup( types, |
| 2071 | groupName ? groupName->str() : "", |
| 2072 | shortName ? shortName->str() : "", |
| 2073 | description ? description->str() : "" ); |
| 2074 | } |
| 2075 | // done |
| 2076 | return; |
| 2077 | |
| 2078 | error: |
| 2079 | RETURN->v_int = FALSE; |
| 2080 | } |
| 2081 | |
| 2082 | CK_DLL_MFUN( CKDoc_addGroup_str ) |
| 2083 | { |
| 2084 | CKDoc * ckdoc = (CKDoc *)OBJ_MEMBER_UINT(SELF, CKDoc_offset_data); |
| 2085 | Chuck_ArrayInt * strArray = (Chuck_ArrayInt *)GET_NEXT_OBJECT(ARGS); |
| 2086 | Chuck_String * groupName = GET_NEXT_STRING(ARGS); |
| 2087 | Chuck_String * shortName = GET_NEXT_STRING(ARGS); |
| 2088 | Chuck_String * desc = GET_NEXT_STRING(ARGS); |
| 2089 | // check if null |
| 2090 | if( strArray == NULL ) |
| 2091 | { |
| 2092 | CK_FPRINTF_STDERR( "[chuck]: CKDoc.addGroup() given null 'typeNames' array; nothing added...\n" ); |
| 2093 | goto error; |
| 2094 | } |
| 2095 | else |
| 2096 | { |
| 2097 | // type names |
| 2098 | vector<string> typeNames; |
| 2099 | // get the names from chuck strings to c++ strings |
| 2100 | for( int i = 0; i < strArray->m_vector.size(); i++ ) |
| 2101 | { |
| 2102 | // get pointer as chuck string |
| 2103 | Chuck_String * s = (Chuck_String *)strArray->m_vector[i]; |
| 2104 | // check |
| 2105 | if( s != NULL ) |
| 2106 | { |
| 2107 | // append |
| 2108 | typeNames.push_back( s->str() ); |
| 2109 | } |
| 2110 | } |
| 2111 | // types |
| 2112 | vector<Chuck_Type *> types; |
| 2113 | // convert to types |
| 2114 | type_engine_names2types( VM->env(), typeNames, types ); |
| 2115 | |
| 2116 | // check |
| 2117 | if( types.size() == 0 ) |
| 2118 | { |
| 2119 | CK_FPRINTF_STDERR( "[chuck]: CKDoc.addGroup() given 'typeNames' array has no associated Types; nothing added...\n" ); |
| 2120 | goto error; |
| 2121 | } |
| 2122 | |
| 2123 | // add group |
| 2124 | ckdoc->addGroup( types, |
| 2125 | groupName ? groupName->str() : "", |
| 2126 | shortName ? shortName->str() : "", |
| 2127 | desc ? desc->str() : "" ); |
| 2128 | } |
| 2129 | |
| 2130 | // set return value |
| 2131 | RETURN->v_int = TRUE; |
| 2132 | // done |
| 2133 | return; |
| 2134 | |
| 2135 | error: |
| 2136 | RETURN->v_int = FALSE; |
| 2137 | } |
| 2138 | |
| 2139 | CK_DLL_MFUN( CKDoc_addGroup_ext ) // 1.5.2.4 (ge) added |
| 2140 | { |
| 2141 | CKDoc * ckdoc = (CKDoc *)OBJ_MEMBER_UINT(SELF, CKDoc_offset_data); |
| 2142 | Chuck_String * groupName = GET_NEXT_STRING(ARGS); |
| 2143 | Chuck_String * URL = GET_NEXT_STRING(ARGS); |
| 2144 | Chuck_String * desc = GET_NEXT_STRING(ARGS); |
| 2145 | Chuck_String * longDesc = GET_NEXT_STRING(ARGS); |
| 2146 | |
| 2147 | // add group |
| 2148 | ckdoc->addGroupExt( groupName ? groupName->str() : "", |
| 2149 | URL ? URL->str() : "", |
| 2150 | desc ? desc->str() : "", |
| 2151 | longDesc ? longDesc->str() : "" ); |
| 2152 | |
| 2153 | // set return value |
| 2154 | RETURN->v_int = TRUE; |
| 2155 | // done |
| 2156 | return; |
| 2157 | } |
| 2158 | |
| 2159 | CK_DLL_MFUN( CKDoc_numGroups ) |
| 2160 | { |
| 2161 | CKDoc * ckdoc = (CKDoc *)OBJ_MEMBER_UINT(SELF, CKDoc_offset_data); |
| 2162 | // return (could be different than requested) |
| 2163 | RETURN->v_int = ckdoc->numGroups(); |
| 2164 | } |
| 2165 | |
| 2166 | CK_DLL_MFUN( CKDoc_clearGroup ) |
| 2167 | { |
| 2168 | CKDoc * ckdoc = (CKDoc *)OBJ_MEMBER_UINT(SELF, CKDoc_offset_data); |
| 2169 | // clear |
| 2170 | ckdoc->clearGroups(); |
| 2171 | } |
| 2172 | |
| 2173 | CK_DLL_CTRL( CKDoc_examplesRoot_set ) |
| 2174 | { |
| 2175 | CKDoc * ckdoc = (CKDoc *)OBJ_MEMBER_UINT(SELF, CKDoc_offset_data); |
| 2176 | Chuck_String * path = GET_NEXT_STRING(ARGS); |
| 2177 | // check if null |
| 2178 | if( path == NULL ) { |
| 2179 | // default |
| 2180 | ckdoc->setExamplesRoot( "./" ); |
| 2181 | } else { |
| 2182 | // set examples root |
| 2183 | ckdoc->setExamplesRoot( trim( path->str() ) ); |
| 2184 | } |
| 2185 | // set return value |
| 2186 | RETURN->v_string = path; |
| 2187 | } |
| 2188 | |
| 2189 | CK_DLL_CGET( CKDoc_examplesRoot_get ) |
| 2190 | { |
| 2191 | CKDoc * ckdoc = (CKDoc *)OBJ_MEMBER_UINT(SELF, CKDoc_offset_data); |
| 2192 | Chuck_String * str = (Chuck_String *)instantiate_and_initialize_object( SHRED->vm_ref->env()->ckt_string, SHRED ); |
| 2193 | str->set( ckdoc->getExamplesRoot() ); |
| 2194 | RETURN->v_string = str; |
| 2195 | } |
| 2196 | |
| 2197 | CK_DLL_CTRL( CKDoc_outputFormat_set ) |
| 2198 | { |
| 2199 | CKDoc * ckdoc = (CKDoc *)OBJ_MEMBER_UINT(SELF, CKDoc_offset_data); |
| 2200 | t_CKINT format = GET_NEXT_INT(ARGS); |
| 2201 | // attempt to set |
| 2202 | ckdoc->setOutputFormat( format ); |
| 2203 | // return (could be different than requested) |
| 2204 | RETURN->v_int = ckdoc->getOutputFormat(); |
| 2205 | } |
| 2206 | |
| 2207 | CK_DLL_CGET( CKDoc_outputFormat_get ) |
| 2208 | { |
| 2209 | CKDoc * ckdoc = (CKDoc *)OBJ_MEMBER_UINT(SELF, CKDoc_offset_data); |
| 2210 | // return |
| 2211 | RETURN->v_int = ckdoc->getOutputFormat(); |
| 2212 | } |
| 2213 | |
| 2214 | CK_DLL_MFUN( CKDoc_sort_set ) |
| 2215 | { |
| 2216 | CKDoc * ckdoc = (CKDoc *)OBJ_MEMBER_UINT(SELF, CKDoc_offset_data); |
| 2217 | ckdoc->m_sort_entries = GET_NEXT_INT(ARGS); |
| 2218 | RETURN->v_int = ckdoc->m_sort_entries; |
| 2219 | } |
| 2220 | |
| 2221 | CK_DLL_MFUN( CKDoc_sort_get ) |
| 2222 | { |
| 2223 | CKDoc * ckdoc = (CKDoc *)OBJ_MEMBER_UINT(SELF, CKDoc_offset_data); |
| 2224 | RETURN->v_int = ckdoc->m_sort_entries; |
| 2225 | } |
| 2226 | |
| 2227 | CK_DLL_MFUN( CKDoc_genIndex ) |
| 2228 | { |
| 2229 | CKDoc * ckdoc = (CKDoc *)OBJ_MEMBER_UINT(SELF, CKDoc_offset_data); |
| 2230 | Chuck_String * indexTitle = GET_NEXT_STRING(ARGS); |
| 2231 | Chuck_String * str = (Chuck_String *)instantiate_and_initialize_object( SHRED->vm_ref->env()->ckt_string, SHRED ); |
| 2232 | str->set( ckdoc->genIndex( indexTitle != NULL ? indexTitle->str() : "" ) ); |
| 2233 | RETURN->v_string = str; |
| 2234 | } |
| 2235 | |
| 2236 | CK_DLL_MFUN( CKDoc_genCSS ) |
| 2237 | { |
| 2238 | CKDoc * ckdoc = (CKDoc *)OBJ_MEMBER_UINT(SELF, CKDoc_offset_data); |
| 2239 | Chuck_String * str = (Chuck_String *)instantiate_and_initialize_object( SHRED->vm_ref->env()->ckt_string, SHRED ); |
| 2240 | str->set( ckdoc->genCSS() ); |
| 2241 | RETURN->v_string = str; |
| 2242 | } |
| 2243 | |
| 2244 | CK_DLL_MFUN( CKDoc_genGroups ) |
| 2245 | { |
| 2246 | CKDoc * ckdoc = (CKDoc *)OBJ_MEMBER_UINT(SELF, CKDoc_offset_data); |
| 2247 | // the return array |
| 2248 | Chuck_ArrayInt * strArray = (Chuck_ArrayInt *)GET_NEXT_OBJECT(ARGS); |
| 2249 | // the c++ return vector |
| 2250 | vector<string> results; |
| 2251 | // gen the groups |
| 2252 | ckdoc->genGroups( results ); |
| 2253 | // clear the return array |
| 2254 | strArray->clear(); |
| 2255 | |
| 2256 | // loop over results |
| 2257 | for( t_CKINT i = 0; i < results.size(); i++ ) |
| 2258 | { |
| 2259 | // instantiate chuck string |
| 2260 | Chuck_String * str = (Chuck_String *)instantiate_and_initialize_object( SHRED->vm_ref->env()->ckt_string, SHRED ); |
| 2261 | // set into chuck string |
| 2262 | str->set( ckdoc->genCSS() ); |
| 2263 | // push back |
| 2264 | strArray->push_back( (t_CKINT)str ); |
| 2265 | } |
| 2266 | } |
| 2267 | |
| 2268 | CK_DLL_MFUN( CKDoc_genType_type ) |
| 2269 | { |
| 2270 | CKDoc * ckdoc = (CKDoc *)OBJ_MEMBER_UINT(SELF, CKDoc_offset_data); |
| 2271 | Chuck_Type * type = (Chuck_Type *)GET_NEXT_OBJECT(ARGS); |
| 2272 | // return something |
| 2273 | Chuck_String * str = (Chuck_String *)instantiate_and_initialize_object( SHRED->vm_ref->env()->ckt_string, SHRED ); |
| 2274 | // gen type |
| 2275 | str->set( type ? ckdoc->genType( type ) : "" ); |
| 2276 | // set return |
| 2277 | RETURN->v_string = str; |
| 2278 | } |
| 2279 | |
| 2280 | CK_DLL_MFUN( CKDoc_genType_str ) |
| 2281 | { |
| 2282 | CKDoc * ckdoc = (CKDoc *)OBJ_MEMBER_UINT(SELF, CKDoc_offset_data); |
| 2283 | Chuck_String * typeName = GET_NEXT_STRING(ARGS); |
| 2284 | // c++ string |
| 2285 | string name = typeName ? typeName->str() : ""; |
| 2286 | // chuck type |
| 2287 | Chuck_Type * type = type_engine_find_type( VM->env(), typeName->str() ); |
| 2288 | // return something |
| 2289 | Chuck_String * str = (Chuck_String *)instantiate_and_initialize_object( SHRED->vm_ref->env()->ckt_string, SHRED ); |
| 2290 | // gen type |
| 2291 | str->set( type ? ckdoc->genType( type ) : "" ); |
| 2292 | // set return |
| 2293 | RETURN->v_string = str; |
| 2294 | } |
| 2295 | |
| 2296 | CK_DLL_MFUN( CKDoc_outputToDir ) |
| 2297 | { |
| 2298 | CKDoc * ckdoc = (CKDoc *)OBJ_MEMBER_UINT(SELF, CKDoc_offset_data); |
| 2299 | Chuck_String * path = GET_NEXT_STRING(ARGS); |
| 2300 | Chuck_String * indexTitle = GET_NEXT_STRING(ARGS); |
| 2301 | // the path as c++ string |
| 2302 | string thePath; |
| 2303 | string theTitle; |
| 2304 | |
| 2305 | // check |
| 2306 | theTitle = indexTitle != NULL ? indexTitle->str() : ""; |
| 2307 | |
| 2308 | // check if null |
| 2309 | if( path == NULL ) { |
| 2310 | thePath = "."; |
| 2311 | } else { |
| 2312 | // set output dir |
| 2313 | thePath = trim( path->str() ); |
| 2314 | } |
| 2315 | |
| 2316 | // output |
| 2317 | ckdoc->outputToDir( thePath, theTitle ); |
| 2318 | } |
| 2319 | |
| 2320 | CK_DLL_SFUN( CKDoc_set_describe ) |
| 2321 | { |
| 2322 | Chuck_Object * target = GET_NEXT_OBJECT(ARGS); |
| 2323 | Chuck_String * desc = GET_NEXT_STRING(ARGS); |
| 2324 | string str = desc ? desc->str() : ""; |
| 2325 | RETURN->v_int = FALSE; |
| 2326 | |
| 2327 | // check it |
| 2328 | if( !target ) |
| 2329 | { |
| 2330 | CK_FPRINTF_STDERR( "CKDoc.describe(): null target argument; no action taken.\n" ); |
| 2331 | return; |
| 2332 | } |
| 2333 | |
| 2334 | // check target type |
| 2335 | Chuck_Type * type = target->type_ref; |
| 2336 | if( !isa(type,VM->env()->ckt_class) && !isa(type,VM->env()->ckt_function) ) |
| 2337 | { |
| 2338 | CK_FPRINTF_STDERR( "CKDoc.describe(): target type must be either Type (i.e., a class) or a function; no action taken.\n" ); |
| 2339 | return; |
| 2340 | } |
| 2341 | |
| 2342 | // if a class |
| 2343 | if( isa(type,VM->env()->ckt_class) ) |
| 2344 | { |
| 2345 | Chuck_Type * targetType = (Chuck_Type *)target; |
| 2346 | // check this isn't a system type |
| 2347 | if( targetType->m_locked || VM->env()->global()->contains( targetType ) ) |
| 2348 | { |
| 2349 | CK_FPRINTF_STDERR( "CKDoc.describe(): cannot modify description for system-defined type '%s'\n", targetType->name().c_str() ); |
| 2350 | return; |
| 2351 | } |
| 2352 | // check this isn't a system type |
| 2353 | if( targetType->doc != "" ) |
| 2354 | { |
| 2355 | CK_FPRINTF_STDERR( "CKDoc.describe(): cannot overwrite a description after it has already been set (type: '%s')", targetType->name().c_str() ); |
| 2356 | return; |
| 2357 | } |
| 2358 | // update the doc string |
| 2359 | targetType->doc = trim(str); |
| 2360 | } |
| 2361 | // if a func |
| 2362 | else if( isa(type,VM->env()->ckt_function) ) |
| 2363 | { |
| 2364 | Chuck_Func * targetFunc = (Chuck_Func *)target; |
| 2365 | // get containing type, if there is one |
| 2366 | Chuck_Type * funcOwner = targetFunc->ownerType(); |
| 2367 | // check this isn't a system type |
| 2368 | if( VM->env()->global()->contains( funcOwner ) ) |
| 2369 | { |
| 2370 | CK_FPRINTF_STDERR( "CKDoc.describe(): cannot modify description for system-defined function '%s'\n", targetFunc->signature(FALSE,FALSE).c_str() ); |
| 2371 | return; |
| 2372 | } |
| 2373 | // check this isn't a system type |
| 2374 | if( targetFunc->doc != "" ) |
| 2375 | { |
| 2376 | CK_FPRINTF_STDERR( "CKDoc.describe(): cannot overwrite a description after it has already been set (function: '%s'", targetFunc->signature(FALSE,FALSE).c_str() ); |
| 2377 | return; |
| 2378 | } |
| 2379 | // update the doc string |
| 2380 | targetFunc->doc = trim(str); |
| 2381 | } |
| 2382 | else |
| 2383 | { |
| 2384 | // should not get here |
| 2385 | CK_FPRINTF_STDERR( "CKDoc.describe(): internal error -- unaccounted Object type '%s", target->type_ref->name().c_str() ); |
| 2386 | return; |
| 2387 | } |
| 2388 | |
| 2389 | // return affirmative |
| 2390 | RETURN->v_int = TRUE; |
| 2391 | } |
| 2392 | |
| 2393 | CK_DLL_SFUN( CKDoc_get_describe ) |
| 2394 | { |
| 2395 | Chuck_Object * target = GET_NEXT_OBJECT(ARGS); |
| 2396 | // type of object |
| 2397 | Chuck_Type * targetType = NULL; |
| 2398 | string doc = ""; |
| 2399 | |
| 2400 | // check it |
| 2401 | if( !target ) goto done; |
| 2402 | targetType = target->type_ref; |
| 2403 | |
| 2404 | // if a class |
| 2405 | if( isa(targetType,VM->env()->ckt_class) ) |
| 2406 | { |
| 2407 | // target is a Type type |
| 2408 | Chuck_Type * type = (Chuck_Type *)target; |
| 2409 | // copy the document string |
| 2410 | doc = type->doc; |
| 2411 | } |
| 2412 | // if a func |
| 2413 | else if( isa(targetType,VM->env()->ckt_function) ) |
| 2414 | { |
| 2415 | // target is a function |
| 2416 | Chuck_Func * func = (Chuck_Func *)target; |
| 2417 | // copy the document string |
| 2418 | doc = func->doc; |
| 2419 | } |
| 2420 | else |
| 2421 | { |
| 2422 | // use the target's type and copy the document string |
| 2423 | doc = targetType->doc; |
| 2424 | } |
| 2425 | |
| 2426 | done: |
| 2427 | // return a new chuck string |
| 2428 | RETURN->v_string = (Chuck_String *)instantiate_and_initialize_object( VM->env()->ckt_string, VM ); |
| 2429 | // set the contents |
| 2430 | RETURN->v_string->set( doc ); |
| 2431 | } |
| 2432 | |
| 2433 | |
| 2434 | |
| 2435 | // the default CSS (ckdoc.css), literally |
| 2436 | string CKDoc::m_ckdocCSS = "\ |
| 2437 | html\n\ |
| 2438 | {\n\ |
| 2439 | margin: 0;\n\ |
| 2440 | padding: 0;\n\ |
| 2441 | }\n\ |
| 2442 | \n\ |
| 2443 | body\n\ |
| 2444 | {\n\ |
| 2445 | margin-left: 2em;\n\ |
| 2446 | margin-right: 2em;\n\ |
| 2447 | font-family: Helvetica, sans-serif;\n\ |
| 2448 | font-size: 14px;\n\ |
| 2449 | }\n\ |
| 2450 | \n\ |
| 2451 | a\n\ |
| 2452 | {\n\ |
| 2453 | scroll-margin-top: 80px;\n\ |
| 2454 | }\n\ |
| 2455 | \n\ |
| 2456 | \n\ |
| 2457 | .index_group\n\ |
| 2458 | {\n\ |
| 2459 | clear: both;\n\ |
| 2460 | background-color: #eee;\n\ |
| 2461 | padding: 1em 1em 1em 1em;\n\ |
| 2462 | margin-bottom: 2em;\n\ |
| 2463 | vertical-align: top;\n\ |
| 2464 | }\n\ |
| 2465 | \n\ |
| 2466 | .index_group_title\n\ |
| 2467 | {\n\ |
| 2468 | float: left;\n\ |
| 2469 | margin: 0;\n\ |
| 2470 | width: 15%;\n\ |
| 2471 | padding-right: 3em;\n\ |
| 2472 | border-right: 4px solid #fcfcfc;\n\ |
| 2473 | }\n\ |
| 2474 | \n\ |
| 2475 | .index_group_classes\n\ |
| 2476 | {\n\ |
| 2477 | padding-top: 0.15em;\n\ |
| 2478 | padding-left: 1em;\n\ |
| 2479 | padding-bottom: 0.15em;\n\ |
| 2480 | \n\ |
| 2481 | margin: 0;\n\ |
| 2482 | margin-left: 20%;\n\ |
| 2483 | width: 75%;\n\ |
| 2484 | }\n\ |
| 2485 | \n\ |
| 2486 | .index_group_classes a\n\ |
| 2487 | {\n\ |
| 2488 | margin-right: 0.5em;\n\ |
| 2489 | line-height: 1.5em;\n\ |
| 2490 | }\n\ |
| 2491 | \n\ |
| 2492 | .index_group_external\n\ |
| 2493 | {\n\ |
| 2494 | padding-top: 0.15em;\n\ |
| 2495 | padding-left: 1em;\n\ |
| 2496 | padding-bottom: 0.15em;\n\ |
| 2497 | \n\ |
| 2498 | margin: 0;\n\ |
| 2499 | margin-left: 20%;\n\ |
| 2500 | width: 75%;\n\ |
| 2501 | }\n\ |
| 2502 | \n\ |
| 2503 | .index_group_external a\n\ |
| 2504 | {\n\ |
| 2505 | margin-right: 0;\n\ |
| 2506 | line-height: 1.5em;\n\ |
| 2507 | }\n\ |
| 2508 | \n\ |
| 2509 | .index_group_desc\n\ |
| 2510 | {\n\ |
| 2511 | color: #555;\n\ |
| 2512 | }\n\ |
| 2513 | \n\ |
| 2514 | .group_desc\n\ |
| 2515 | {\n\ |
| 2516 | color: #000;\n\ |
| 2517 | }\n\ |
| 2518 | \n\ |
| 2519 | .index_group_title a\n\ |
| 2520 | {\n\ |
| 2521 | color: black;\n\ |
| 2522 | }\n\ |
| 2523 | \n\ |
| 2524 | #title\n\ |
| 2525 | {\n\ |
| 2526 | position: fixed;\n\ |
| 2527 | top: 0;\n\ |
| 2528 | left: 0;\n\ |
| 2529 | right: 0;\n\ |
| 2530 | border-bottom: 1px solid black;\n\ |
| 2531 | padding: 0.5em 2em;\n\ |
| 2532 | margin-bottom: 1.5em;\n\ |
| 2533 | background-color: white;\n\ |
| 2534 | float: left;\n\ |
| 2535 | box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);\n\ |
| 2536 | }\n\ |
| 2537 | \n\ |
| 2538 | .titleL\n\ |
| 2539 | {\n\ |
| 2540 | float: left;\n\ |
| 2541 | width: auto;\n\ |
| 2542 | /* vertically center */\n\ |
| 2543 | line-height: 48px;\n\ |
| 2544 | height: 48px;\n\ |
| 2545 | }\n\ |
| 2546 | \n\ |
| 2547 | .gray\n\ |
| 2548 | {\n\ |
| 2549 | color: gray;\n\ |
| 2550 | }\n\ |
| 2551 | \n\ |
| 2552 | .inline\n\ |
| 2553 | {\n\ |
| 2554 | display: inline;\n\ |
| 2555 | }\n\ |
| 2556 | \n\ |
| 2557 | \n\ |
| 2558 | .titleR\n\ |
| 2559 | {\n\ |
| 2560 | float: right;\n\ |
| 2561 | width: initial;\n\ |
| 2562 | clear: none;\n\ |
| 2563 | }\n\ |
| 2564 | \n\ |
| 2565 | .titleLogo\n\ |
| 2566 | {\n\ |
| 2567 | width: 48px;\n\ |
| 2568 | height: 48px;\n\ |
| 2569 | padding-right: 8px;\n\ |
| 2570 | }\n\ |
| 2571 | \n\ |
| 2572 | .titleLogo img\n\ |
| 2573 | {\n\ |
| 2574 | width: 48px;\n\ |
| 2575 | height: 48px;\n\ |
| 2576 | }\n\ |
| 2577 | \n\ |
| 2578 | h1\n\ |
| 2579 | {\n\ |
| 2580 | font-size: 28px;\n\ |
| 2581 | margin: 0;\n\ |
| 2582 | }\n\ |
| 2583 | \n\ |
| 2584 | h1 a\n\ |
| 2585 | {\n\ |
| 2586 | color: black;\n\ |
| 2587 | text-decoration: none;\n\ |
| 2588 | }\n\ |
| 2589 | \n\ |
| 2590 | h1 a:hover\n\ |
| 2591 | {\n\ |
| 2592 | color: blue;\n\ |
| 2593 | text-decoration: underline;\n\ |
| 2594 | }\n\ |
| 2595 | \n\ |
| 2596 | #body\n\ |
| 2597 | {\n\ |
| 2598 | clear: both;\n\ |
| 2599 | margin-top: 80px;\n\ |
| 2600 | }\n\ |
| 2601 | \n\ |
| 2602 | .toc\n\ |
| 2603 | {\n\ |
| 2604 | float: left;\n\ |
| 2605 | position: fixed;\n\ |
| 2606 | top: 80px;\n\ |
| 2607 | clear: both;\n\ |
| 2608 | background-color: #eee;\n\ |
| 2609 | padding: 0.25em 0.5em 1em 0.75em;\n\ |
| 2610 | margin: 0;\n\ |
| 2611 | width: 12.5em;\n\ |
| 2612 | overflow-x: auto;\n\ |
| 2613 | overflow-y: auto;\n\ |
| 2614 | max-height: calc(100% - 100px);\n\ |
| 2615 | margin-bottom: 20px;\n\ |
| 2616 | }\n\ |
| 2617 | \n\ |
| 2618 | .toc_class\n\ |
| 2619 | {\n\ |
| 2620 | font-size: 12px;\n\ |
| 2621 | margin-top: 0.5em;\n\ |
| 2622 | margin-bottom: 0.25em;\n\ |
| 2623 | }\n\ |
| 2624 | \n\ |
| 2625 | .classes\n\ |
| 2626 | {\n\ |
| 2627 | clear: right;\n\ |
| 2628 | margin-left: 15em;\n\ |
| 2629 | margin-right: 0em;\n\ |
| 2630 | margin-top: 80px;\n\ |
| 2631 | }\n\ |
| 2632 | \n\ |
| 2633 | .class\n\ |
| 2634 | {\n\ |
| 2635 | background-color: #eee;\n\ |
| 2636 | padding: 0.025em 0.5em 0.25em 1em;\n\ |
| 2637 | }\n\ |
| 2638 | \n\ |
| 2639 | .class_title\n\ |
| 2640 | {\n\ |
| 2641 | font-family: Menlo, Monaco, Courier;\n\ |
| 2642 | font-size: 18px;\n\ |
| 2643 | }\n\ |
| 2644 | \n\ |
| 2645 | .class_inherits\n\ |
| 2646 | {\n\ |
| 2647 | font-weight: normal;\n\ |
| 2648 | }\n\ |
| 2649 | \n\ |
| 2650 | .class_hierarchy\n\ |
| 2651 | {\n\ |
| 2652 | font-family: Menlo, Monaco, Courier;\n\ |
| 2653 | font-size: 14px;\n\ |
| 2654 | /* margin-right: 4em; */\n\ |
| 2655 | }\n\ |
| 2656 | \n\ |
| 2657 | .class_section_header\n\ |
| 2658 | {}\n\ |
| 2659 | \n\ |
| 2660 | .class_description\n\ |
| 2661 | {\n\ |
| 2662 | font-family: Helvetica;\n\ |
| 2663 | font-size: 14px;\n\ |
| 2664 | margin-right: 4em;\n\ |
| 2665 | }\n\ |
| 2666 | \n\ |
| 2667 | .empty_class_description\n\ |
| 2668 | {\n\ |
| 2669 | font-family: Helvetica;\n\ |
| 2670 | font-size: 12px;\n\ |
| 2671 | font-style: italic;\n\ |
| 2672 | color: grey;\n\ |
| 2673 | margin-right: 4em;\n\ |
| 2674 | }\n\ |
| 2675 | \n\ |
| 2676 | .members\n\ |
| 2677 | {\n\ |
| 2678 | font-family: Menlo, Monaco, Courier;\n\ |
| 2679 | font-size: 13px;\n\ |
| 2680 | }\n\ |
| 2681 | \n\ |
| 2682 | .member\n\ |
| 2683 | {\n\ |
| 2684 | margin-left: 0em;\n\ |
| 2685 | padding-left: 0.85em;\n\ |
| 2686 | padding-top: 0.85em;\n\ |
| 2687 | border-top: 4px solid #fcfcfc;\n\ |
| 2688 | border-left: 4px solid #fcfcfc;\n\ |
| 2689 | \n\ |
| 2690 | padding-bottom: 0.85em;\n\ |
| 2691 | padding-left: 0.85em;\n\ |
| 2692 | margin-bottom: 1.5em;\n\ |
| 2693 | \n\ |
| 2694 | margin-right: 4em;\n\ |
| 2695 | padding-right: 0;\n\ |
| 2696 | }\n\ |
| 2697 | \n\ |
| 2698 | .member_declaration\n\ |
| 2699 | {\n\ |
| 2700 | margin-top: 0;\n\ |
| 2701 | margin-bottom: 0.5em;\n\ |
| 2702 | }\n\ |
| 2703 | \n\ |
| 2704 | .member_description\n\ |
| 2705 | {\n\ |
| 2706 | font-family: Helvetica;\n\ |
| 2707 | font-size: 14px;\n\ |
| 2708 | margin-top: 0;\n\ |
| 2709 | margin-bottom: 0;\n\ |
| 2710 | }\n\ |
| 2711 | \n\ |
| 2712 | .empty_member_description\n\ |
| 2713 | {\n\ |
| 2714 | font-family: Helvetica;\n\ |
| 2715 | font-size: 12px;\n\ |
| 2716 | font-style: italic;\n\ |
| 2717 | color: grey;\n\ |
| 2718 | margin-top: 0;\n\ |
| 2719 | margin-bottom: 0;\n\ |
| 2720 | }\n\ |
| 2721 | \n\ |
| 2722 | .ckdoc_typename\n\ |
| 2723 | {\n\ |
| 2724 | font-family: Menlo, Monaco, Courier;\n\ |
| 2725 | font-size: 13px;\n\ |
| 2726 | }\n\ |
| 2727 | \n\ |
| 2728 | .membername\n\ |
| 2729 | {\n\ |
| 2730 | font-weight: bold;\n\ |
| 2731 | }\n\ |
| 2732 | \n\ |
| 2733 | .top_link\n\ |
| 2734 | {\n\ |
| 2735 | text-align: right;\n\ |
| 2736 | margin-top: 2em;\n\ |
| 2737 | margin-right: 1em;\n\ |
| 2738 | }\n\ |
| 2739 | \n\ |
| 2740 | .top_link a\n\ |
| 2741 | {\n\ |
| 2742 | color: #44F;\n\ |
| 2743 | }\n\ |
| 2744 | \n\ |
| 2745 | .examples ul\n\ |
| 2746 | {\n\ |
| 2747 | margin-top: -1em;\n\ |
| 2748 | }\n\ |
| 2749 | \n\ |
| 2750 | .examples ul li a\n\ |
| 2751 | {\n\ |
| 2752 | text-decoration: none;\n\ |
| 2753 | }\n\ |
| 2754 | \n\ |
| 2755 | .clear\n\ |
| 2756 | {\n\ |
| 2757 | clear: both;\n\ |
| 2758 | }\n\ |
| 2759 | \n\ |
| 2760 | .ckdoc_type_primitive\n\ |
| 2761 | {\n\ |
| 2762 | color: blue;\n\ |
| 2763 | }\n\ |
| 2764 | \n\ |
| 2765 | .ckdoc_type_ugen\n\ |
| 2766 | {\n\ |
| 2767 | color: #A200EC;\n\ |
| 2768 | }\n\ |
| 2769 | \n\ |
| 2770 | .ckdoc_type_object\n\ |
| 2771 | {\n\ |
| 2772 | color: #800023;\n\ |
| 2773 | }\n\ |
| 2774 | "; |