diff --git a/src/core/ulib_doc.cpp b/src/core/ulib_doc.cpp index a285993ff..ba5d94393 100644 --- a/src/core/ulib_doc.cpp +++ b/src/core/ulib_doc.cpp @@ -56,6 +56,8 @@ CK_DLL_CTRL( CKDoc_examplesRoot_set ); CK_DLL_CGET( CKDoc_examplesRoot_get ); CK_DLL_CTRL( CKDoc_outputFormat_set ); CK_DLL_CGET( CKDoc_outputFormat_get ); +CK_DLL_MFUN( CKDoc_sort_set ); +CK_DLL_MFUN( CKDoc_sort_get ); CK_DLL_MFUN( CKDoc_genIndex ); CK_DLL_MFUN( CKDoc_genCSS ); CK_DLL_MFUN( CKDoc_genGroups ); @@ -172,6 +174,17 @@ DLL_QUERY ckdoc_query( Chuck_DL_Query * QUERY ) func->doc = "Set which output format is selected; see CKDoc.HTML, CKDoc.TEXT, CKDoc.MARKDOWN, CKDoc.JSON."; if( !type_engine_import_mfun( env, func ) ) goto error; + // CKDoc disable sort + func = make_new_mfun( "int", "disableSort", CKDoc_sort_set ); + func->add_arg("int", "disable"); + func->doc = "Disable alphabetical sorting of the documentation."; + if( !type_engine_import_mfun( env, func ) ) goto error; + + // CKDoc get sort status + func = make_new_mfun( "int", "disableSort", CKDoc_sort_get ); + func->doc = "Get the current status of alphabetical sorting."; + if( !type_engine_import_mfun( env, func ) ) goto error; + // genIndex func = make_new_mfun( "string", "genIndex", CKDoc_genIndex ); func->add_arg( "string", "indexTitle" ); @@ -811,6 +824,8 @@ CKDoc::CKDoc( Chuck_VM * vm ) // reset m_format = FORMAT_NONE; m_output = NULL; + // enable alphabetical sorting by default + m_disable_sort = false; // default setOutputFormat( FORMAT_HTML ); @@ -1025,7 +1040,7 @@ t_CKBOOL CKDoc::setOutputFormat( t_CKINT which ) // name: getOutputFormat() // desc: get output format //----------------------------------------------------------------------------- -t_CKINT CKDoc::getOutpuFormat() const +t_CKINT CKDoc::getOutputFormat() const { return m_format; } @@ -1316,12 +1331,15 @@ string CKDoc::genType( Chuck_Type * type, t_CKBOOL clearOutput ) } } + // @kellyyyyyyyyyyyyyyyy @azaday make alphabetical sorting optional // sort - sort( svars.begin(), svars.end(), ck_comp_value ); - sort( mvars.begin(), mvars.end(), ck_comp_value ); - sort( sfuncs.begin(), sfuncs.end(), ck_comp_func ); - sort( mfuncs.begin(), mfuncs.end(), ck_comp_func ); - sort( ctors.begin(), ctors.end(), ck_comp_func_args ); + if (!m_disable_sort) { + sort( svars.begin(), svars.end(), ck_comp_value ); + sort( mvars.begin(), mvars.end(), ck_comp_value ); + sort( sfuncs.begin(), sfuncs.end(), ck_comp_func ); + sort( mfuncs.begin(), mfuncs.end(), ck_comp_func ); + sort( ctors.begin(), ctors.end(), ck_comp_func_args ); + } // whether to potentially insert a default constructor | 1.5.2.0 t_CKBOOL insertDefaultCtor = type_engine_has_implicit_def_ctor( type ); @@ -1731,14 +1749,27 @@ CK_DLL_CTRL( CKDoc_outputFormat_set ) // attempt to set ckdoc->setOutputFormat( format ); // return (could be different than requested) - RETURN->v_int = ckdoc->getOutpuFormat(); + RETURN->v_int = ckdoc->getOutputFormat(); } CK_DLL_CGET( CKDoc_outputFormat_get ) { CKDoc * ckdoc = (CKDoc *)OBJ_MEMBER_UINT(SELF, CKDoc_offset_data); // return - RETURN->v_int = ckdoc->getOutpuFormat(); + RETURN->v_int = ckdoc->getOutputFormat(); +} + +CK_DLL_MFUN( CKDoc_sort_set ) +{ + CKDoc * ckdoc = (CKDoc *)OBJ_MEMBER_UINT(SELF, CKDoc_offset_data); + ckdoc->m_disable_sort = GET_NEXT_INT(ARGS); + RETURN->v_int = ckdoc->m_disable_sort; +} + +CK_DLL_MFUN( CKDoc_sort_get ) +{ + CKDoc * ckdoc = (CKDoc *)OBJ_MEMBER_UINT(SELF, CKDoc_offset_data); + RETURN->v_int = ckdoc->m_disable_sort; } CK_DLL_MFUN( CKDoc_genIndex ) diff --git a/src/core/ulib_doc.h b/src/core/ulib_doc.h index 04eab66d1..e9fd4f795 100644 --- a/src/core/ulib_doc.h +++ b/src/core/ulib_doc.h @@ -169,7 +169,7 @@ class CKDoc // set output format: CKDoc.HTML, CKDoc.TEXT, CKDoc.MARKDOWN, CKDoc.JSON t_CKBOOL setOutputFormat( t_CKINT which ); // get output format - t_CKINT getOutpuFormat() const; + t_CKINT getOutputFormat() const; // set base examples root path void setExamplesRoot( const std::string & path ); // get base examples root path @@ -196,6 +196,8 @@ class CKDoc static const t_CKINT FORMAT_TEXT; // same as help static const t_CKINT FORMAT_MARKDOWN; // not implemented static const t_CKINT FORMAT_JSON; // not implemented + // sorting flag + bool m_disable_sort; protected: // write string to file