Commits

Olivier Debeir  committed f71f8e9

parse fun.__doc__

  • Participants
  • Parent commits 575f359

Comments (0)

Files changed (1)

File pyrankfilter/filter.py

     MEAN kernel
     ---------------------
     computes MEAN on the local neighborhood.
-    """
+    """
+
+
+def parse_doc(fun):
+    """identify comment and code portion inside a doc string
+    """
+    s = fun.__doc__
+    code = ''
+    comment = ''
+    for t in s.split('\n'):
+        if t.strip().startswith('/* ----- KERNEL C-CODE START HERE '):
+            print "*"*80
+            comment = code
+            code = ''
+        else:
+            code = code + t + '\n'
+    print 'the function :',fun.__name__
+    print 'the code :\n', code
+    print 'the comment :\n', comment
+    fun.__doc__ = comment
+
+def test_parse():
+    """
+    MEAN kernel
+    ---------------------
+    computes MEAN on the local neighborhood.
+
+    /* ----- KERNEL C-CODE START HERE  -----  */
+    sum=0.0f;
+    for(m=0;m<HISTOSIZE;m++)
+        sum+=(m*histo[m]);
+    if(pop){
+        *ptemp=sum/pop;
+    }
+    """
+
+parse_doc(test_parse)
+
+print test_parse.__doc__