Make Clownfish URIs link to relevant POD section

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

Branch: refs/heads/master
Commit: 18007a3a085fe51ebc12cd6b991770a0d6a17974
Parents: e2626d9
Author: Nick Wellnhofer <wellnho...@aevum.de>
Authored: Sat Dec 12 15:56:31 2015 +0100
Committer: Nick Wellnhofer <wellnho...@aevum.de>
Committed: Sat Dec 12 15:56:31 2015 +0100

----------------------------------------------------------------------
 compiler/src/CFCPerlPod.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/18007a3a/compiler/src/CFCPerlPod.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCPerlPod.c b/compiler/src/CFCPerlPod.c
index 7388cea..153072d 100644
--- a/compiler/src/CFCPerlPod.c
+++ b/compiler/src/CFCPerlPod.c
@@ -871,22 +871,24 @@ S_convert_link(cmark_node *link, CFCClass *doc_class, int 
header_level) {
                 break;
             }
 
-            // TODO: Link to relevant POD section. This isn't easy because
-            // the section headers for functions also contain a description
-            // of the parameters.
+            char *perl_name = CFCUtil_strdup(name);
+            for (size_t i = 0; perl_name[i] != '\0'; ++i) {
+                perl_name[i] = tolower(perl_name[i]);
+            }
 
-            if (klass != doc_class) {
+            if (klass == doc_class) {
+                new_uri = CFCUtil_sprintf("/%s", perl_name);
+            }
+            else {
                 const char *class_name = CFCClass_get_name(klass);
-                new_uri = CFCUtil_strdup(class_name);
+                new_uri = CFCUtil_sprintf("%s/%s", class_name, perl_name);
             }
 
             if (text[0] == '\0') {
-                new_text = CFCUtil_sprintf("%s()", name);
-                for (size_t i = 0; new_text[i] != '\0'; ++i) {
-                    new_text[i] = tolower(new_text[i]);
-                }
+                new_text = CFCUtil_sprintf("%s()", perl_name);
             }
 
+            FREEMEM(perl_name);
             break;
         }
 

Reply via email to