Browse Source

Autodoc: Save All comments in Procedures

Arthur Yefimov 2 years ago
parent
commit
52d0bb9a2a
2 changed files with 18 additions and 14 deletions
  1. 4 4
      src/Autodoc/AutodocHtml.Mod
  2. 14 10
      src/Autodoc/AutodocParser.Mod

+ 4 - 4
src/Autodoc/AutodocHtml.Mod

@@ -718,18 +718,18 @@ VAR Y, M, D, h, m, s: INTEGER;
 BEGIN
   Time.GetTime(Y, M, D, h, m, s);
 
-  WriteInt(Y); Write('.');
+  Write('20'); WriteInt(Y); Write('.');
   WriteInt(M); Write('.');
-  WriteInt(D); Write(' ');
+  WriteInt(D)
 
-  WriteInt(h); Write(':');
+  (*WriteInt(h); Write(':');
   WriteInt(m); Write(':');
   WriteInt(s)
 
   ;Time.GetClock(Y, M);
   Write('   ');
   WriteInt(Y); Write(':');
-  WriteInt(M);
+  WriteInt(M);*)
 END PrintDate;
 
 PROCEDURE RunTag(M: P.Module; tag: ARRAY OF CHAR);

+ 14 - 10
src/Autodoc/AutodocParser.Mod

@@ -306,7 +306,7 @@ END ClearComments;
 
 (** Comments **)
 
-(** Append the first comment from global variable doc to the the given string.
+(** Appends the first comment from global variable doc to the the given string.
      If vertical tab exists in doc, the first comment spans from doc[0] till
     the first vertical tab, otherwise till the first tab or 0X character. *)
 PROCEDURE AppendComment(VAR comment: ARRAY OF CHAR);
@@ -326,8 +326,8 @@ BEGIN
   END
 END AppendComment;
 
-(** Put text of the last comment to varpar comment, remove it from doc,
-    put in its place in doc the character vtab instead of tab. *)
+(** Puts text of the last comment to varpar comment, removes it from doc,
+    puts in its place in doc the character vtab instead of tab. *)
 PROCEDURE GetLastComment(VAR comment: ARRAY OF CHAR);
 VAR L, i, j: INTEGER;
 BEGIN
@@ -342,13 +342,17 @@ BEGIN
   END
 END GetLastComment;
 
-(** Join all comments and attach them to o *)
+(** Join all comments and append the to the comments of o.
+     !TODO:
+    If tabs or vertical tabs exist in doc, they are substituted with periods,
+    but only if the left side does not end with a punctuation mark or a comma,
+    in which case the character is substituted with a space. *)
 PROCEDURE SaveAllComments(o: Object);
 VAR i: INTEGER;
 BEGIN
   IF o # NIL THEN
-    Strings.Copy(doc, o.comment); ClearComments;
-    i := 0;
+    i := Strings.Length(o.comment);
+    Strings.Append(doc, o.comment); ClearComments;
     WHILE o.comment[i] # 0X DO
       IF o.comment[i] < ' ' THEN o.comment[i] := 0AX END;
       INC(i)
@@ -367,8 +371,8 @@ PROCEDURE SaveComment(o: Object; lastLine: INTEGER);
 BEGIN
   IF (o # NIL) & (doc[0] # 0X) & ((lastLine = -1) OR (docLine = lastLine)) THEN
     IF o.comment[0] = 0X THEN AppendComment(o.comment)
-    ELSIF docLine = lastLine THEN Strings.Append(0AX, o.comment);
-      AppendComment(o.comment)
+    ELSIF (lastLine = -1) OR (docLine = lastLine) THEN
+      Strings.Append(0AX, o.comment); AppendComment(o.comment)
     END
   END
 END SaveComment;
@@ -1394,7 +1398,7 @@ VAR name: Str;
 BEGIN
   IF ~titleNotUsed THEN curTitle := '-' END;
   WHILE sym = procedure DO UpdateCurGroup(M.procedures);
-    NEW(P); InitObject(P); SaveComment(P, -1); GetSym; foreign := FALSE;
+    NEW(P); InitObject(P); SaveAllComments(P); GetSym; foreign := FALSE;
     forward := FALSE; P.params := NewList(); P.exported := FALSE;
     P.external := FALSE; P.modifier[0] := 0X; P.code[0] := 0X;
     IF sym = lparen THEN NEW(P.receiver); InitObject(P.receiver); GetSym;
@@ -1442,7 +1446,7 @@ BEGIN
     IF P.external & (sym = string) THEN Strings.Copy(id, P.code); GetSym END;
     IF sym = semicol THEN GetSym ELSE MarkExp(';') END;
     IF ~forward & ~foreign & ~P.external THEN
-      ReachEndOf(P.name); SaveComment(P, -1);
+      ReachEndOf(P.name); SaveAllComments(P);
       IF sym = ident THEN GetSym;
         IF sym = semicol THEN GetSym ELSE MarkExp(';') END
       ELSE (* sym = eot *) MarkEnd('Procedure', P.name)