Browse Source

Автодок: вынос из списка и запятая после последнего импорта; -o принимает каталог

Arthur Yefimov 2 years ago
parent
commit
a0dff8eb5b
3 changed files with 22 additions and 15 deletions
  1. 14 9
      src/Autodoc/Autodoc.Mod
  2. 4 4
      src/Autodoc/AutodocHtml.Mod
  3. 4 2
      src/Autodoc/AutodocParser.Mod

+ 14 - 9
src/Autodoc/Autodoc.Mod

@@ -89,10 +89,12 @@ BEGIN
   Out.Ln; Out.Ln;
   Out.String('outputPath is a file name if a single source file is given.');
   Out.Ln;
-  Out.String('outputPath is a directory if many source files are given.');
+  Out.String('outputPath is a directory if many source files are given or if');
   Out.Ln;
-  Out.String('-a ...... get All objects, not only exported'); Out.Ln;
-  Out.String('-k ...... Keep module aliases');
+  Out.String('           there is a slash in the end of outputPath.');
+  Out.Ln;
+  Out.String('-a ....... get All objects, not only exported'); Out.Ln;
+  Out.String('-k ....... Keep module aliases');
   Out.Ln; Out.Ln;
   Out.String('Examples:'); Out.Ln;
   Out.String('  '); Out.String(s);
@@ -100,7 +102,7 @@ BEGIN
   Out.String('  '); Out.String(s);
   Out.String(' -o doc.html --lang ru Apples.Mod'); Out.Ln;
   Out.String('  '); Out.String(s);
-  Out.String(' -o docs Fruits.Mod Apples.Mod'); Out.Ln
+  Out.String(' -o docs/ Fruits.Mod Apples.Mod'); Out.Ln
 END Usage;
 
 (** Changes extension of the file to '.html'. Puts result is out. *)
@@ -121,7 +123,7 @@ BEGIN
 END FnameToHtml;
 
 PROCEDURE Do;
-VAR i: INTEGER;
+VAR i, len: INTEGER;
   out, s: ARRAY 256 OF CHAR;
   fnames: ARRAY 64, 256 OF CHAR;
   fnameCount: INTEGER;
@@ -154,13 +156,16 @@ BEGIN
       END;
       INC(i)
     END;
-    IF fnameCount = 1 THEN (* Single file given *)
-      IF out[0] = 0X THEN FnameToHtml(fnames[0], out) END;
-      HandleFile(fnames[0], out)
-    ELSE (* Multiple file given, treat "-o" parameter as directory *)
+    len := Strings.Length(out);
+    IF (fnameCount > 1) OR
+       (len # 0) & ((out[len - 1] = '/') OR (out[len - 1] = '\'))
+    THEN (* treat "-o" parameter as directory *)
       FOR i := 0 TO fnameCount - 1 DO
         HandleFileToDir(fnames[i], out)
       END
+    ELSE (* Single file given and "-o" is a file name *)
+      IF out[0] = 0X THEN FnameToHtml(fnames[0], out) END;
+      HandleFile(fnames[0], out)
     END
   END
 END Do;

+ 4 - 4
src/Autodoc/AutodocHtml.Mod

@@ -199,14 +199,14 @@ BEGIN
 END PrintComment;
 
 PROCEDURE PrintImport(I: P.Import; indent: INTEGER; inlined: BOOLEAN);
-VAR tmp: BOOLEAN;
-BEGIN tmp := isLastListItem; isLastListItem := FALSE;
+BEGIN
   Write('<span class="import">');
   IF I.name # I.alias THEN
     Write('<span class="alias">'); Write(I.alias); Write('</span> := ')
   END;
-  Write('<span class="name">'); Write(I.name); Write('</span>');
-  IF ~tmp THEN WriteLn(', ') END
+  Write('<span class="name">'); Write(I.name); Write('</span></span>');
+  IF ~isLastListItem THEN WriteLn(', ') END;
+  isLastListItem := FALSE
 END PrintImport;
 
 PROCEDURE PrintOrdinalConst(C: P.Const);

+ 4 - 2
src/Autodoc/AutodocParser.Mod

@@ -628,10 +628,12 @@ END AddToList;
 PROCEDURE RemoveFromList(L: List; o: Object);
 VAR x: Object;
 BEGIN
-  IF L.first = o THEN L.first := L.first.next
+  IF L.first = o THEN L.first := L.first.next;
+    IF L.first = NIL THEN L.last := NIL END
   ELSE x := L.first;
     WHILE x.next # o DO x := x.next END;
-    x.next := x.next.next
+    x.next := x.next.next;
+    IF x.next = NIL THEN L.last := x END
   END;
   o.next := NIL
 END RemoveFromList;