Fix links to methods in POD

The Perl POD only contains sections for novel methods. Link to the class
where the method is declared first.


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

Branch: refs/heads/master
Commit: b35885f1c65b89608765312a6c09e9f54db9f256
Parents: 39a6685
Author: Nick Wellnhofer <wellnho...@aevum.de>
Authored: Sat Dec 12 16:43:36 2015 +0100
Committer: Nick Wellnhofer <wellnho...@aevum.de>
Committed: Sat Dec 12 16:43:36 2015 +0100

----------------------------------------------------------------------
 compiler/src/CFCPerlPod.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/b35885f1/compiler/src/CFCPerlPod.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCPerlPod.c b/compiler/src/CFCPerlPod.c
index 6c2a638..97f93c8 100644
--- a/compiler/src/CFCPerlPod.c
+++ b/compiler/src/CFCPerlPod.c
@@ -876,6 +876,16 @@ S_convert_link(cmark_node *link, CFCClass *doc_class, int 
header_level) {
                 perl_name[i] = tolower(perl_name[i]);
             }
 
+            // The Perl POD only contains sections for novel methods. Link
+            // to the class where the method is declared first.
+            if (type == CFC_URI_METHOD) {
+                CFCClass *parent = CFCClass_get_parent(klass);
+                while (parent && CFCClass_method(parent, name)) {
+                    klass = parent;
+                    parent = CFCClass_get_parent(klass);
+                }
+            }
+
             if (klass == doc_class) {
                 new_uri = CFCUtil_sprintf("/%s", perl_name);
             }

Reply via email to