Repository: benjamincorcoran/sasdocs

Issue:
Give Macro object an about attribute
# Issue

Macro object needs an `about` attribute capturing the documentation of the macro variable. This should be the first set of comments *inside* the macro. The comments need to be collapsed into a single string object. 

Discussion:

Patch:
diff --git a/sasdocs/objects.py b/sasdocs/objects.py
index b625e6e..5208195 100644
--- a/sasdocs/objects.py
+++ b/sasdocs/objects.py
@@ -507,6 +507,19 @@ class macro:
 
     def __attrs_post_init__(self):
         self.contents = [obj for obj in self.contents if obj != '\n']
+        about = []
+        for obj in self.contents:
+            if type(obj).__name__ == 'comment':
+                about.append(obj)
+            else:
+                break
+        if len(about) == 0:
+            self.about = 'No docstring found.'
+            self.documented = False
+        else:
+            self.about = '\n'.join([comment.text for comment in about])
+            self.documented = True
+        
 
 
 # Parsy Objects


Test patch:
diff --git a/tests/test_objects.py b/tests/test_objects.py
index 7249a1f..515899d 100644
--- a/tests/test_objects.py
+++ b/tests/test_objects.py
@@ -149,10 +149,20 @@ testcases = [
 ]
 
 @pytest.mark.parametrize("case,expected", testcases)
-def test_macro_parse(case, expected):
-
+def test_macro_about_parse(case, expected):
     assert force_partial_parse(fullprogram, case) == [expected]
 
+testcases = [
+    ('%macro test; /*This is the test macro*/ %mend;', 'This is the test macro'),
+    ('%macro test; /*This is the test macro*/\n/*This is the second line*/%mend;', 'This is the test macro\nThis is the second line'),
+    ('%macro test; data a; set b; run; /*This is the test macro*/ %mend;', 'No docstring found.'),
+]
+
+@pytest.mark.parametrize("case,expected", testcases)
+def test_macro_parse(case, expected):
+    macro = force_partial_parse(fullprogram,case)[0]
+    assert macro.about == expected
+
 testcases = [
     ('%macro test; data a; set b; run; %mend;', [dataStep(outputs=[dataObject(library=None, dataset=['a'], options=None)], header=' ', inputs=[dataObject(library=None, dataset=['b'], options=None)], body=' ')]),
     ('%macro test(a=1/*Doc A*/,b/*Doc B*/); data a; set b; run; %mend;', [dataStep(outputs=[dataObject(library=None, dataset=['a'], options=None)], header=' ', inputs=[dataObject(library='work', dataset=['b'])], body=' ')]),