Group C documentation by "fresh" methods

I'm not really sure whether it's better to group novel or fresh methods.
Doing it this way fixes at least the following problems:

* Implementations of abstract methods show up correctly and more
  prominently.
* The statement "Methods inherited from {subclass}" is now correct.
  Before, it should have said "Methods novel in {subclass}".

What bothers me is that methods show up in "vtable" order. Keeping the
original order from the .cfh file would probably be the best solution
but this information is lost in S_bequeath_methods.


Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/a96b4c4b
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/a96b4c4b
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/a96b4c4b

Branch: refs/heads/markdown_v2
Commit: a96b4c4ba9d215b0ad5f5f1658d85b81a3e9dac2
Parents: 8350753
Author: Nick Wellnhofer <[email protected]>
Authored: Tue Dec 2 20:23:41 2014 +0100
Committer: Nick Wellnhofer <[email protected]>
Committed: Tue Dec 2 20:34:04 2014 +0100

----------------------------------------------------------------------
 compiler/src/CFCCHtml.c | 30 +++++++++++++++++++-----------
 1 file changed, 19 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/a96b4c4b/compiler/src/CFCCHtml.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCCHtml.c b/compiler/src/CFCCHtml.c
index 74a9c8c..da02942 100644
--- a/compiler/src/CFCCHtml.c
+++ b/compiler/src/CFCCHtml.c
@@ -134,7 +134,7 @@ static char*
 S_html_create_methods(CFCClass *klass);
 
 static char*
-S_html_create_novel_methods(CFCClass *klass);
+S_html_create_fresh_methods(CFCClass *klass, CFCClass *invoker);
 
 static char*
 S_html_create_func(CFCClass *klass, CFCFunction *func, const char *prefix,
@@ -524,12 +524,10 @@ S_html_create_methods(CFCClass *klass) {
             break;
         }
 
-        char *novel_html = S_html_create_novel_methods(ancestor);
+        char *novel_html = S_html_create_fresh_methods(ancestor, klass);
         if (novel_html[0] != '\0') {
             if (ancestor == klass) {
-                methods_html
-                    = CFCUtil_cat(methods_html, "<h3>Novel methods</h3>\n",
-                                  novel_html, NULL);
+                methods_html = CFCUtil_cat(methods_html, novel_html, NULL);
             }
             else {
                 methods_html
@@ -553,13 +551,24 @@ S_html_create_methods(CFCClass *klass) {
 }
 
 static char*
-S_html_create_novel_methods(CFCClass *klass) {
-    CFCMethod **fresh_methods = CFCClass_fresh_methods(klass);
-    char       *result        = CFCUtil_strdup("");
+S_html_create_fresh_methods(CFCClass *klass, CFCClass *invoker) {
+    CFCMethod  **fresh_methods = CFCClass_fresh_methods(klass);
+    const char  *class_name    = CFCClass_get_class_name(klass);
+    char        *result        = CFCUtil_strdup("");
 
     for (int meth_num = 0; fresh_methods[meth_num] != NULL; meth_num++) {
         CFCMethod *method = fresh_methods[meth_num];
-        if (!CFCMethod_public(method) || !CFCMethod_novel(method)) {
+        if (!CFCMethod_public(method)) {
+            continue;
+        }
+
+        const char *macro_sym = CFCMethod_get_macro_sym(method);
+        CFCMethod *maybe_overridden_method
+            = CFCClass_method(invoker, macro_sym);
+        const char *maybe_overridden_class_name
+            = CFCMethod_get_class_name(maybe_overridden_method);
+        if (strcmp(maybe_overridden_class_name, class_name) != 0) {
+            // Overridden by a subclass.
             continue;
         }
 
@@ -569,8 +578,7 @@ S_html_create_novel_methods(CFCClass *klass) {
 
         CFCParcel  *parcel    = CFCSymbol_get_parcel((CFCSymbol*)method);
         const char *prefix    = CFCParcel_get_PREFIX(parcel);
-        const char *macro_sym = CFCMethod_get_macro_sym(method);
-        char       *short_sym = CFCMethod_short_method_sym(method, NULL);
+        char       *short_sym = CFCMethod_short_method_sym(method, invoker);
         const char *attrs     = NULL;
 
         if (CFCMethod_abstract(method)) {

Reply via email to