From 70ad20cc6ee421b450491a8661ce2694eb8cc332 Mon Sep 17 00:00:00 2001 From: Andrew Aday Date: Wed, 19 Jun 2024 16:45:08 -0700 Subject: [PATCH 1/2] add option to disable alphabetical sorting of ckdoc --- src/core/ulib_doc.cpp | 47 +++++++++++++++++++++++++++++++++++-------- src/core/ulib_doc.h | 4 +++- 2 files changed, 42 insertions(+), 9 deletions(-) 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 From 6877d5f9b8c775e51329cc597a2b924479d2bf05 Mon Sep 17 00:00:00 2001 From: Ge Wang Date: Wed, 19 Jun 2024 23:32:27 -0700 Subject: [PATCH 2/2] update CKDoc sort function naming --- src/core/ulib_doc.cpp | 26 +++++++++++++------------- src/core/ulib_doc.h | 6 ++++-- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/core/ulib_doc.cpp b/src/core/ulib_doc.cpp index ba5d94393..17ec78d9d 100644 --- a/src/core/ulib_doc.cpp +++ b/src/core/ulib_doc.cpp @@ -174,14 +174,14 @@ 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."; + // CKDoc toggle sort | 1.5.2.5 (@kellyyyyyyyyyyyyyyyy @azaday) + func = make_new_mfun( "int", "sort", CKDoc_sort_set ); + func->add_arg( "int", "toggle" ); + func->doc = "Enable or disable alphabetical sorting of functions and variables."; if( !type_engine_import_mfun( env, func ) ) goto error; - // CKDoc get sort status - func = make_new_mfun( "int", "disableSort", CKDoc_sort_get ); + // CKDoc get sort status | 1.5.2.5 (@kellyyyyyyyyyyyyyyyy @azaday) + func = make_new_mfun( "int", "sort", CKDoc_sort_get ); func->doc = "Get the current status of alphabetical sorting."; if( !type_engine_import_mfun( env, func ) ) goto error; @@ -825,7 +825,7 @@ CKDoc::CKDoc( Chuck_VM * vm ) m_format = FORMAT_NONE; m_output = NULL; // enable alphabetical sorting by default - m_disable_sort = false; + m_sort_entries = true; // default setOutputFormat( FORMAT_HTML ); @@ -1331,9 +1331,9 @@ string CKDoc::genType( Chuck_Type * type, t_CKBOOL clearOutput ) } } - // @kellyyyyyyyyyyyyyyyy @azaday make alphabetical sorting optional - // sort - if (!m_disable_sort) { + // sort | 1.5.2.5 (@kellyyyyyyyyyyyyyyyy @azaday) added check + if( m_sort_entries ) + { sort( svars.begin(), svars.end(), ck_comp_value ); sort( mvars.begin(), mvars.end(), ck_comp_value ); sort( sfuncs.begin(), sfuncs.end(), ck_comp_func ); @@ -1762,14 +1762,14 @@ CK_DLL_CGET( CKDoc_outputFormat_get ) 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; + ckdoc->m_sort_entries = GET_NEXT_INT(ARGS); + RETURN->v_int = ckdoc->m_sort_entries; } CK_DLL_MFUN( CKDoc_sort_get ) { CKDoc * ckdoc = (CKDoc *)OBJ_MEMBER_UINT(SELF, CKDoc_offset_data); - RETURN->v_int = ckdoc->m_disable_sort; + RETURN->v_int = ckdoc->m_sort_entries; } CK_DLL_MFUN( CKDoc_genIndex ) diff --git a/src/core/ulib_doc.h b/src/core/ulib_doc.h index e9fd4f795..93a9e5d79 100644 --- a/src/core/ulib_doc.h +++ b/src/core/ulib_doc.h @@ -189,6 +189,10 @@ class CKDoc // generate documentation for a single Type std::string genType( Chuck_Type * type, t_CKBOOL clearOutput = TRUE ); +public: + // sort functions and variables | 1.5.2.5 (@kellyyyyyyyyyyyyyyyy @azaday) added + t_CKBOOL m_sort_entries; + public: // enumeration for output format types static const t_CKINT FORMAT_NONE; // no output format @@ -196,8 +200,6 @@ 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