aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2017-03-06 17:26:04 +0000
committerIngo Schwarze <schwarze@openbsd.org>2017-03-06 17:26:04 +0000
commitc30903de74e443fffffd9d160ef6911d2d434468 (patch)
tree3ef915c858f0f89cb3b1348940352e114086b827
parent2da973e1cbee8826e4ccfd50d7f8ab5517bd9006 (diff)
downloadmandoc-c30903de74e443fffffd9d160ef6911d2d434468.tar.gz
mandoc-c30903de74e443fffffd9d160ef6911d2d434468.tar.zst
mandoc-c30903de74e443fffffd9d160ef6911d2d434468.zip
Using .Nd only makes sense in the NAME section.
Warn if that macro occurs elsewhere. Triggered by a question from Dag-Erling Smoergrav <des @ FreeBSD>.
-rw-r--r--mandoc.112
-rw-r--r--mandoc.h3
-rw-r--r--mdoc_validate.c6
-rw-r--r--read.c3
-rw-r--r--regress/mdoc/Nd/broken.out_lint2
5 files changed, 21 insertions, 5 deletions
diff --git a/mandoc.1 b/mandoc.1
index c5f38c2b..275540ee 100644
--- a/mandoc.1
+++ b/mandoc.1
@@ -1,4 +1,4 @@
-.\" $Id: mandoc.1,v 1.176 2017/03/04 17:17:34 schwarze Exp $
+.\" $Id: mandoc.1,v 1.177 2017/03/06 17:26:04 schwarze Exp $
.\"
.\" Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
.\" Copyright (c) 2012, 2014-2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -15,7 +15,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: March 4 2017 $
+.Dd $Mdocdate: March 6 2017 $
.Dt MANDOC 1
.Os
.Sh NAME
@@ -908,6 +908,14 @@ The
.Ic \&Nd
macro lacks the required argument.
The title line of the manual will end after the dash.
+.It Sy "description line outside NAME section"
+.Pq mdoc
+An
+.Ic \&Nd
+macro appears outside the NAME section.
+The arguments are printed anyway and the following text is used for
+.Xr apropos 1 ,
+but none of that behaviour is portable.
.It Sy "sections out of conventional order"
.Pq mdoc
A standard section occurs after another section it usually precedes.
diff --git a/mandoc.h b/mandoc.h
index a80d6ae7..12c26a18 100644
--- a/mandoc.h
+++ b/mandoc.h
@@ -1,4 +1,4 @@
-/* $Id: mandoc.h,v 1.214 2017/01/28 23:30:08 schwarze Exp $ */
+/* $Id: mandoc.h,v 1.215 2017/03/06 17:26:04 schwarze Exp $ */
/*
* Copyright (c) 2010, 2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -71,6 +71,7 @@ enum mandocerr {
MANDOCERR_NAMESEC_BAD, /* bad NAME section content: macro */
MANDOCERR_NAMESEC_PUNCT, /* missing comma before name: Nm name */
MANDOCERR_ND_EMPTY, /* missing description line, using "" */
+ MANDOCERR_ND_LATE, /* description line outside NAME section */
MANDOCERR_SEC_ORDER, /* sections out of conventional order: Sh title */
MANDOCERR_SEC_REP, /* duplicate section title: Sh title */
MANDOCERR_SEC_MSEC, /* unexpected section: Sh title for ... only */
diff --git a/mdoc_validate.c b/mdoc_validate.c
index e58e7a47..d5318754 100644
--- a/mdoc_validate.c
+++ b/mdoc_validate.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_validate.c,v 1.318 2017/02/06 03:44:58 schwarze Exp $ */
+/* $Id: mdoc_validate.c,v 1.319 2017/03/06 17:26:04 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -1035,6 +1035,10 @@ post_nd(POST_ARGS)
if (n->type != ROFFT_BODY)
return;
+ if (n->sec != SEC_NAME)
+ mandoc_msg(MANDOCERR_ND_LATE, mdoc->parse,
+ n->line, n->pos, "Nd");
+
if (n->child == NULL)
mandoc_msg(MANDOCERR_ND_EMPTY, mdoc->parse,
n->line, n->pos, "Nd");
diff --git a/read.c b/read.c
index 3e5d4116..b4718e51 100644
--- a/read.c
+++ b/read.c
@@ -1,4 +1,4 @@
-/* $Id: read.c,v 1.161 2017/02/18 17:29:28 schwarze Exp $ */
+/* $Id: read.c,v 1.162 2017/03/06 17:26:05 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010-2017 Ingo Schwarze <schwarze@openbsd.org>
@@ -113,6 +113,7 @@ static const char * const mandocerrs[MANDOCERR_MAX] = {
"bad NAME section content",
"missing comma before name",
"missing description line, using \"\"",
+ "description line outside NAME section",
"sections out of conventional order",
"duplicate section title",
"unexpected section",
diff --git a/regress/mdoc/Nd/broken.out_lint b/regress/mdoc/Nd/broken.out_lint
index 181ec60b..d187e8c3 100644
--- a/regress/mdoc/Nd/broken.out_lint
+++ b/regress/mdoc/Nd/broken.out_lint
@@ -3,5 +3,7 @@ mandoc: broken.in:5:2: WARNING: bad NAME section content: Oo
mandoc: broken.in:9:1: WARNING: bad NAME section content: text
mandoc: broken.in:4:2: WARNING: NAME section without Nm before Nd
mandoc: broken.in:4:2: WARNING: NAME section without description
+mandoc: broken.in:16:2: WARNING: description line outside NAME section: Nd
mandoc: broken.in:13:2: WARNING: moving content out of list: Bl
mandoc: broken.in:18:1: WARNING: moving content out of list: text
+mandoc: broken.in:27:2: WARNING: description line outside NAME section: Nd