diff options
-rw-r--r-- | libman.h | 4 | ||||
-rw-r--r-- | man.7 | 17 | ||||
-rw-r--r-- | man.c | 6 | ||||
-rw-r--r-- | man_validate.c | 17 | ||||
-rw-r--r-- | mdoc.7 | 18 |
5 files changed, 56 insertions, 6 deletions
@@ -45,7 +45,9 @@ enum merr { WDATE, WLNSCOPE, WTSPACE, - WTQUOTE + WTQUOTE, + WNODATA, + WNOTITLE }; __BEGIN_DECLS @@ -97,7 +97,7 @@ Characters may alternatively be escaped by a slash-asterisk, .Sq \e* , with the same combinations as described above. This form is deprecated. .\" SECTION -.Sh STRUCTURE +.Sh SYNTAX Macros are one to three three characters in length and begin with a control character , .Sq \&. , @@ -155,7 +155,20 @@ The .Sq \&.TP macro is similar, but does not need an empty argument line to trigger the behaviour. -.\" PARAGRAPH +.\" SECTION +.Sh STRUCTURE +Each +.Nm +document must contain contains at least the +.Sq \&.TH +macro describing the document's section and title. It may occur +anywhere in the document, although conventionally, it appears as the +first macro. +.Pp +Beyond the +.Sq \&.TH , +at least one macro or text node must appear in the document. +.\" SECTION .Sh MACROS This section contains a complete list of all .Nm @@ -466,6 +466,12 @@ man_err(struct man *m, int line, int pos, case (WTQUOTE): p = "unterminated quotation"; break; + case (WNODATA): + p = "document has no data"; + break; + case (WNOTITLE): + p = "document has no title/section"; + break; } assert(p); diff --git a/man_validate.c b/man_validate.c index 77ca142e..e9a65510 100644 --- a/man_validate.c +++ b/man_validate.c @@ -38,6 +38,7 @@ static int check_le1(POSTARGS); static int check_le2(POSTARGS); static int check_le5(POSTARGS); static int check_text(POSTARGS); +static int check_root(POSTARGS); static v_post posts_le1[] = { check_le1, NULL }; static v_post posts_le2[] = { check_le2, NULL }; @@ -85,8 +86,7 @@ man_valid_post(struct man *m) case (MAN_TEXT): return(check_text(m, m->last)); case (MAN_ROOT): - /* FIXME: validate that TH has been invoked! */ - return(1); + return(check_root(m, m->last)); default: break; } @@ -102,6 +102,19 @@ man_valid_post(struct man *m) static int +check_root(POSTARGS) +{ + + if (NULL == m->first->child) + return(man_nerr(m, n, WNODATA)); + if (NULL == m->meta.title) + return(man_nerr(m, n, WNOTITLE)); + + return(1); +} + + +static int check_text(POSTARGS) { const char *p; @@ -278,7 +278,23 @@ In-lines have \(>=0 scoped arguments. \&.Yy \(lB\-arg \(lBval...\(rB\(rB arg0 arg1 argN .Ed -.\" +.\" SECTION +.Sh STRUCTURE +Each +.Nm +document must begin with the document prologue, containing, in order, +.Sq \&.Dd , +.Sq \&.Dt , +and +.Sq \&.Os . +.Pp +Following these, the document body must begin with the NAME section +containing at least one +.Sq \&.Nm +followed by a +.Sq \&.Nd +macro. +.\" SECTION .Sh MACROS This section contains a complete list of all .Nm |