Skip to content

Commit

Permalink
ckdoc trailing punctuation
Browse files Browse the repository at this point in the history
  • Loading branch information
gewang committed Oct 14, 2023
1 parent a75290a commit aa52593
Show file tree
Hide file tree
Showing 12 changed files with 63 additions and 23 deletions.
2 changes: 0 additions & 2 deletions src/core/chuck_dl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -782,12 +782,10 @@ t_CKBOOL CK_DLL_CALL ck_add_example( Chuck_DL_Query * query, const char * ex )
// set current function documentation
t_CKBOOL CK_DLL_CALL ck_doc_func( Chuck_DL_Query * query, const char * doc )
{
// #ifdef CK_DOC // disable unless CK_DOC
if(query->curr_func)
query->curr_func->doc = doc;
else
return FALSE;
// #endif // CK_DOC

return TRUE;
}
Expand Down
6 changes: 3 additions & 3 deletions src/core/chuck_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6642,17 +6642,17 @@ t_CKBOOL init_class_serialio( Chuck_Env * env )

// add getByte
func = make_new_mfun("int", "getByte", serialio_getByte);
func->doc = "get next requested byte. ";
func->doc = "get next requested byte.";
if( !type_engine_import_mfun( env, func ) ) goto error;

// add getBytes
func = make_new_mfun("int[]", "getBytes", serialio_getBytes);
func->doc = "get next requested number of bytes. ";
func->doc = "get next requested number of bytes.";
if( !type_engine_import_mfun( env, func ) ) goto error;

// add getInts
func = make_new_mfun("int[]", "getInts", serialio_getInts);
func->doc = "get next requested number of integers. ";
func->doc = "get next requested number of integers.";
if( !type_engine_import_mfun( env, func ) ) goto error;

// add writeByte
Expand Down
6 changes: 3 additions & 3 deletions src/core/chuck_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9117,7 +9117,7 @@ void Chuck_Type::apropos_top( std::string & output, const std::string & PREFIX )
sout << endl;
// description
if( this->doc != "" )
sout << PREFIX << " |- " << capitalize(this->doc) << "" << endl;
sout << PREFIX << " |- " << capitalize_and_periodize(this->doc) << "" << endl;
// inheritance
if( type->parent != NULL )
{
Expand Down Expand Up @@ -9202,7 +9202,7 @@ void apropos_func( std::ostringstream & sout, Chuck_Func * theFunc,
// close paren
sout << ");" << endl;
// output doc
if( theFunc->doc != "" ) sout << PREFIX << " " << capitalize(theFunc->doc) << endl;
if( theFunc->doc != "" ) sout << PREFIX << " " << capitalize_and_periodize(theFunc->doc) << endl;
}


Expand Down Expand Up @@ -9336,7 +9336,7 @@ void apropos_var( std::ostringstream & sout, Chuck_Value * var,
sout << var->name << ";" << endl;

// output doc
if( var->doc != "" ) sout << PREFIX << " " << capitalize(var->doc) << endl;
if( var->doc != "" ) sout << PREFIX << " " << capitalize_and_periodize(var->doc) << endl;
}


Expand Down
2 changes: 1 addition & 1 deletion src/core/ugen_xxx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,7 @@ DLL_QUERY xxx_query( Chuck_DL_Query * QUERY )
// add cget: valueAt
func = make_new_mfun( "float", "valueAt", sndbuf_cget_valueAt );
func->add_arg( "int", "pos" );
func->doc = "get sample value at given position (in samples). ";
func->doc = "get sample value at given position (in samples).";
if( !type_engine_import_mfun( env, func ) ) goto error;

// end import
Expand Down
4 changes: 2 additions & 2 deletions src/core/ulib_ai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@
// [6] http://smirk.cs.princeton.edu/
// sMIRk | Small Music Information Retrieval toolKit
//
// [7] Tzanetakis, G. and P. R. Cook. 2000 "MARSYAS: A Framework for Audio
// [7] Tzanetakis, G. and P. R. Cook. 2000. "MARSYAS: A Framework for Audio
// Analysis." Organised Sound. 4:(3)
//
// [8] Tzanetakis, G. and P. R. Cook. 2002 "Musical Genre Classification of
// [8] Tzanetakis, G. and P. R. Cook. 2002. "Musical Genre Classification of
// Audio Signals." IEEE Transaction on Speech and Audio Processing. 10(5).
//
// [9] Wang, G., R. Fiebrink, P. R. Cook. 2007. "Combining Analysis and
Expand Down
4 changes: 2 additions & 2 deletions src/core/ulib_ai.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@
// [6] http://smirk.cs.princeton.edu/
// sMIRk | Small Music Information Retrieval toolKit
//
// [7] Tzanetakis, G. and P. R. Cook. 2000 "MARSYAS: A Framework for Audio
// [7] Tzanetakis, G. and P. R. Cook. 2000. "MARSYAS: A Framework for Audio
// Analysis." Organised Sound. 4:(3)
//
// [8] Tzanetakis, G. and P. R. Cook. 2002 "Musical Genre Classification of
// [8] Tzanetakis, G. and P. R. Cook. 2002. "Musical Genre Classification of
// Audio Signals." IEEE Transaction on Speech and Audio Processing. 10(5).
//
// [9] Wang, G., R. Fiebrink, P. R. Cook. 2007. "Combining Analysis and
Expand Down
10 changes: 5 additions & 5 deletions src/core/ulib_doc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ class CKDocHTMLOutput : public CKDocOutput

if(type->doc.size() > 0)
{
std::string doc = capitalize(type->doc);
std::string doc = capitalize_and_periodize(type->doc);
m_outputStr += "<p class=\"class_description\">" + doc + "<p>\n";
}
else
Expand Down Expand Up @@ -478,7 +478,7 @@ class CKDocHTMLOutput : public CKDocOutput
m_outputStr += "<span class=\"membername\">" + var->name + "</span></p>";

if(var->doc.size() > 0)
m_outputStr += "<p class=\"member_description\">" + capitalize(var->doc) + "</p>\n";
m_outputStr += "<p class=\"member_description\">" + capitalize_and_periodize(var->doc) + "</p>\n";
else
m_outputStr += "<p class=\"empty_member_description\">No description available</p>\n";

Expand All @@ -503,7 +503,7 @@ class CKDocHTMLOutput : public CKDocOutput
m_outputStr += "<span class=\"membername\">" + var->name + "</span></p>";

if(var->doc.size() > 0)
m_outputStr += "<p class=\"member_description\">" + capitalize(var->doc) + "</p>\n";
m_outputStr += "<p class=\"member_description\">" + capitalize_and_periodize(var->doc) + "</p>\n";
else
m_outputStr += "<p class=\"empty_member_description\">No description available</p>\n";

Expand Down Expand Up @@ -537,7 +537,7 @@ class CKDocHTMLOutput : public CKDocOutput
m_outputStr += ")</p>\n";

if(m_func->doc.size() > 0)
m_outputStr += "<p class=\"member_description\">" + capitalize(m_func->doc) + "</p>\n";
m_outputStr += "<p class=\"member_description\">" + capitalize_and_periodize(m_func->doc) + "</p>\n";
else
m_outputStr += "<p class=\"empty_member_description\">No description available</p>\n";

Expand Down Expand Up @@ -573,7 +573,7 @@ class CKDocHTMLOutput : public CKDocOutput
m_outputStr += ")</p>\n";

if(m_func->doc.size() > 0)
m_outputStr += "<p class=\"member_description\">" + capitalize(m_func->doc) + "</p>\n";
m_outputStr += "<p class=\"member_description\">" + capitalize_and_periodize(m_func->doc) + "</p>\n";
else
m_outputStr += "<p class=\"empty_member_description\">No description available</p>\n";

Expand Down
2 changes: 1 addition & 1 deletion src/core/ulib_math.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ DLL_QUERY libmath_query( Chuck_DL_Query * QUERY )
QUERY->add_sfun( QUERY, atan2_impl, "float", "atan2" );
QUERY->add_arg( QUERY, "float", "y" );
QUERY->add_arg( QUERY, "float", "x" );
QUERY->doc_func( QUERY, "Compute arc tangent of two variables (y/x). " );
QUERY->doc_func( QUERY, "Compute arc tangent of two variables (y/x)." );

// sinh
QUERY->add_sfun( QUERY, sinh_impl, "float", "sinh" );
Expand Down
2 changes: 1 addition & 1 deletion src/core/ulib_opsc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ class OscInServer
// TODO
}

// add OSC method, e.g,. "/foo/frequency"
// add OSC method, e.g., "/foo/frequency"
void addMethod( const std::string & method, OscIn * obj )
{
// message to server
Expand Down
2 changes: 1 addition & 1 deletion src/core/ulib_std.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ DLL_QUERY libstd_query( Chuck_DL_Query * QUERY )
// add ftoi
QUERY->add_sfun( QUERY, ftoi_impl, "int", "ftoi" ); //! float to int
QUERY->add_arg( QUERY, "float", "f" );
QUERY->doc_func( QUERY, "convert float to integer. " );
QUERY->doc_func( QUERY, "convert float to integer." );

// add getenv
QUERY->add_sfun( QUERY, getenv_impl, "string", "getenv" ); //! fetch environment variable
Expand Down
41 changes: 40 additions & 1 deletion src/core/util_string.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ string toupper( const string & str )

//-----------------------------------------------------------------------------
// name: capitalize()
// capitalize first character
// desc: capiitalize first character
//-----------------------------------------------------------------------------
string capitalize( const string & s )
{
Expand All @@ -183,6 +183,45 @@ string capitalize( const string & s )



//-----------------------------------------------------------------------------
// name: capitalize_and_periodize()
// desc: capiitalize first character and ensure trailing period
//-----------------------------------------------------------------------------
string capitalize_and_periodize( const string & s )
{
// copy
string retval = capitalize( trim(s) );
// check
if( retval.length() > 0 )
{
char c = retval[retval.length()-1];
// check for other punctuation
switch( c )
{
case '.':
case ',':
case '!':
case '?':
case ')':
case '(':
case '#':
case '\'':
case '\"':
case '\n':
break;

// in all other cases, append .
default:
retval += '.';
}
}
// done
return retval;
}




//-----------------------------------------------------------------------------
// name: trim()
// desc: return a whitespace (spaces and tabs)-trimmed string
Expand Down
5 changes: 4 additions & 1 deletion src/core/util_string.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,12 @@ std::string ltrim( const std::string & val );
// right trim
std::string rtrim( const std::string & val );

// return capitalized copy of a string
// return capitalized copy of string
std::string capitalize( const std::string & s );

// return capiitalized copy of string with trailing punc, adding . as needed
std::string capitalize_and_periodize( const std::string & s );

// replace tabs
std::string replace_tabs( const std::string & s,
char replaceEachTabWithThis );
Expand Down

0 comments on commit aa52593

Please sign in to comment.