Przeglądaj źródła

Autodoc: Template file (not working yet)

Arthur Yefimov 2 lat temu
rodzic
commit
0933d863d0
3 zmienionych plików z 70 dodań i 3 usunięć
  1. 8 3
      src/Autodoc/Autodoc.Mod
  2. 25 0
      src/Autodoc/AutodocHtml.Mod
  3. 37 0
      src/Autodoc/T.html

+ 8 - 3
src/Autodoc/Autodoc.Mod

@@ -106,10 +106,13 @@ BEGIN
   Out.Ln;
   Out.String('           Put extension in the end to change it: Program/.cp');
   Out.Ln;
-  Out.String('--pal <pal> ..... Supply a named palette.'); Out.Ln;
+  Out.String('--pal <pal> .............. Supply a named palette.'); Out.Ln;
   Out.String('  <pal> is one of: default, bw, horror'); Out.Ln;
-  Out.String('--debug ......... Produce debug output in console.'); Out.Ln;
-  Out.Ln; Out.Ln;
+  Out.String('--template <filename> .... Use <filename> as HTML-file'); Out.Ln;
+  Out.String('  with placeholders: %TITLE% %HEADING% %MENU% %BODY% %DATE%');
+  Out.Ln;
+  Out.String('--debug .................. Produce debug output in console.');
+  Out.Ln; Out.Ln; Out.Ln;
   Out.String('Examples:'); Out.Ln;
   Out.String('  '); Out.String(s);
   Out.String(' -o Apples.Mod'); Out.Ln;
@@ -229,6 +232,8 @@ BEGIN
         IF i < count THEN INC(i); Args.Get(i, indexTitle); END
       ELSIF s = '--pal' THEN
         IF i < count THEN INC(i); Args.Get(i, s); H.SetPalette(s) END
+      ELSIF s = '--template' THEN (* Template HTML file *)
+        IF i < count THEN INC(i); Args.Get(i, s); H.SetTemplate(s) END
       ELSIF s = '--lang' THEN (* Output language *)
         IF i < count THEN INC(i); Args.Get(i, s); H.SetLang(s) END
       ELSE (* One of the Oberon module file names *)

+ 25 - 0
src/Autodoc/AutodocHtml.Mod

@@ -57,6 +57,9 @@ VAR
   declNames: ARRAY 256 OF ARRAY 64 OF CHAR;
   declNameCount: INTEGER; (** Actual length of array declNames *)
 
+(** HTML Template **)
+  tpl: ARRAY 40960 OF CHAR;
+
 (** Link Module List **)
 
 PROCEDURE AddLinkMod*(name: ARRAY OF CHAR);
@@ -753,6 +756,28 @@ BEGIN ClearColors;
   END
 END SetPalette;
 
+(** Set template HTML-file *)
+PROCEDURE SetTemplate*(fname: ARRAY OF CHAR);
+VAR T: Texts.Text;
+  R: Texts.Reader;
+  i: INTEGER;
+  c: CHAR;
+BEGIN
+  NEW(T); Texts.Open(T, fname); i := 0;
+  IF T.len # 0 THEN
+    Texts.OpenReader(R, T, 0);
+    Texts.Read(R, c);
+    WHILE ~R.eot & (i # LEN(tpl) - 1) DO
+      tpl[i] := c; INC(i);
+      Texts.Read(R, c)
+    END
+  END;
+  tpl[i] := 0X;
+  Out.String('TEMPLATE');Out.Ln;
+  Out.String(tpl);Out.Ln;
+  Out.String('END TEMPLATE');Out.Ln;
+END SetTemplate;
+
 (** Main procedure *)
 PROCEDURE Save*(module: P.Module; fname: ARRAY OF CHAR): BOOLEAN;
 BEGIN

+ 37 - 0
src/Autodoc/T.html

@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>{{TITLE}}</title>
+</head>
+<style>body{max-width:800px}</style>
+<body>
+
+<h2>{{HEADING}}</h2>
+
+<br><br>
+MENU:
+<table border="1"><tr><td>
+{{MENU}}
+</td></tr></table>
+
+<br><br>
+BODY:
+<table border="1"><tr><td>
+{{BODY}}
+</td></tr></table>
+
+<br><br>
+DATE:
+<pre>
+{{DATE}}
+</pre>
+
+<br><br>
+DATE:
+<pre>
+{{DATE}}
+</pre>
+
+</body>
+</html>