Move some code out of S_html_create_func
Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/0cf67709 Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/0cf67709 Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/0cf67709 Branch: refs/heads/markdown_v2 Commit: 0cf67709440ce1ce35d3d83fab3f51647baf2fe7 Parents: 719d229 Author: Nick Wellnhofer <[email protected]> Authored: Wed Dec 3 19:53:28 2014 +0100 Committer: Nick Wellnhofer <[email protected]> Committed: Wed Dec 3 19:53:28 2014 +0100 ---------------------------------------------------------------------- compiler/src/CFCCHtml.c | 44 ++++++++++++++++++-------------------------- 1 file changed, 18 insertions(+), 26 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/0cf67709/compiler/src/CFCCHtml.c ---------------------------------------------------------------------- diff --git a/compiler/src/CFCCHtml.c b/compiler/src/CFCCHtml.c index c3c701c..d06c823 100644 --- a/compiler/src/CFCCHtml.c +++ b/compiler/src/CFCCHtml.c @@ -138,7 +138,7 @@ S_html_create_fresh_methods(CFCClass *klass, CFCClass *ancestor); static char* S_html_create_func(CFCClass *klass, CFCFunction *func, const char *prefix, - const char *name, const char *short_sym, const char *attrs); + const char *short_sym); static char* S_html_create_param_list(CFCClass *klass, CFCFunction *func); @@ -490,13 +490,15 @@ S_html_create_functions(CFCClass *klass) { result = CFCUtil_cat(result, "<h2>Functions</h2>\n<dl>\n", NULL); } + const char *micro_sym = CFCFunction_micro_sym(func); + result = CFCUtil_cat(result, "<dt id=\"func_", micro_sym, "\">", + micro_sym, "</dt>\n", NULL); + CFCParcel *parcel = CFCSymbol_get_parcel((CFCSymbol*)func); const char *prefix = CFCParcel_get_prefix(parcel); - const char *micro_sym = CFCFunction_micro_sym(func); const char *short_sym = CFCFunction_short_func_sym(func); - char *func_html = S_html_create_func(klass, func, prefix, micro_sym, - short_sym, NULL); + char *func_html = S_html_create_func(klass, func, prefix, short_sym); result = CFCUtil_cat(result, func_html, NULL); FREEMEM(func_html); } @@ -575,18 +577,21 @@ S_html_create_fresh_methods(CFCClass *klass, CFCClass *ancestor) { result = CFCUtil_cat(result, "<dl>\n", NULL); } + result = CFCUtil_cat(result, "<dt id=\"func_", macro_sym, "\">", + macro_sym, NULL); + if (CFCMethod_abstract(method)) { + result = CFCUtil_cat(result, + " <span class=\"comment\">(abstract)</span>", NULL); + } + result = CFCUtil_cat(result, "</dt>\n", NULL); + CFCParcel *parcel = CFCSymbol_get_parcel((CFCSymbol*)method); const char *prefix = CFCParcel_get_PREFIX(parcel); char *short_sym = CFCMethod_short_method_sym(method, klass); const char *attrs = NULL; - if (CFCMethod_abstract(method)) { - attrs = "abstract"; - } - char *method_html = S_html_create_func(klass, (CFCFunction*)method, - prefix, macro_sym, short_sym, - attrs); + prefix, short_sym); result = CFCUtil_cat(result, method_html, NULL); FREEMEM(method_html); @@ -602,20 +607,10 @@ S_html_create_fresh_methods(CFCClass *klass, CFCClass *ancestor) { static char* S_html_create_func(CFCClass *klass, CFCFunction *func, const char *prefix, - const char *name, const char *short_sym, - const char *attrs) { + const char *short_sym) { CFCType *return_type = CFCFunction_get_return_type(func); char *return_type_html = S_type_to_html(klass, return_type); const char *incremented = ""; - char *attr_string; - - if (attrs && attrs[0] != '\0') { - attr_string = CFCUtil_sprintf(" <span class=\"comment\">(%s)</span>", - attrs); - } - else { - attr_string = CFCUtil_strdup(""); - } if (CFCType_incremented(return_type)) { incremented = " <span class=\"comment\">// incremented</span>"; @@ -624,16 +619,13 @@ S_html_create_func(CFCClass *klass, CFCFunction *func, const char *prefix, char *param_list = S_html_create_param_list(klass, func); const char *pattern = - "<dt id=\"func_%s\">%s%s</dt>\n" "<dd>\n" "<pre><code>%s%s\n" "<span class=\"prefix\">%s</span><strong>%s</strong>%s</code></pre>\n"; - char *result = CFCUtil_sprintf(pattern, name, name, attr_string, - return_type_html, incremented, prefix, - short_sym, param_list); + char *result = CFCUtil_sprintf(pattern, return_type_html, incremented, + prefix, short_sym, param_list); FREEMEM(param_list); - FREEMEM(attr_string); // Get documentation, which may be inherited. CFCDocuComment *docucomment = CFCFunction_get_docucomment(func);
