Skip to content

Commit

Permalink
update CKDoc sort function naming
Browse files Browse the repository at this point in the history
  • Loading branch information
gewang committed Jun 20, 2024
1 parent 70ad20c commit 6877d5f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
26 changes: 13 additions & 13 deletions src/core/ulib_doc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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 )
Expand Down
6 changes: 4 additions & 2 deletions src/core/ulib_doc.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,15 +189,17 @@ 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
static const t_CKINT FORMAT_HTML; // default
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
Expand Down

0 comments on commit 6877d5f

Please sign in to comment.