git: 7c2eef6968 - main - macros: Disallow crossref without description

From: Fernando Apesteguía <fernape_at_FreeBSD.org>
Date: Sun, 22 Sep 2024 17:35:41 UTC
The branch main has been updated by fernape:

URL: https://cgit.FreeBSD.org/doc/commit/?id=7c2eef6968d54237a82be653f14b712f574b97fa

commit 7c2eef6968d54237a82be653f14b712f574b97fa
Author:     Fernando Apesteguía <fernape@FreeBSD.org>
AuthorDate: 2024-09-22 17:30:45 +0000
Commit:     Fernando Apesteguía <fernape@FreeBSD.org>
CommitDate: 2024-09-22 17:35:28 +0000

    macros: Disallow crossref without description
    
    While here, fix the macro documentation in fdp-primer.
---
 .../content/en/books/fdp-primer/asciidoctor-primer/_index.adoc        | 2 +-
 shared/lib/InterDocumentReferencesMacro/extension.rb                  | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/documentation/content/en/books/fdp-primer/asciidoctor-primer/_index.adoc b/documentation/content/en/books/fdp-primer/asciidoctor-primer/_index.adoc
index 12b3f4421f..a808ca8be0 100644
--- a/documentation/content/en/books/fdp-primer/asciidoctor-primer/_index.adoc
+++ b/documentation/content/en/books/fdp-primer/asciidoctor-primer/_index.adoc
@@ -252,7 +252,7 @@ Books are structured in different directories to keep a sane layout.
 To create a link from one subdirectory of a book to another subdirectory of the
 same book, use the `crossref` macro:
 ....
-crossref:doc-build[documentation-makefile]
+crossref:doc-build[documentation-makefile, This link]
 ....
 And this would be rendered as
 
diff --git a/shared/lib/InterDocumentReferencesMacro/extension.rb b/shared/lib/InterDocumentReferencesMacro/extension.rb
index fc6ca4e76a..da18d39935 100644
--- a/shared/lib/InterDocumentReferencesMacro/extension.rb
+++ b/shared/lib/InterDocumentReferencesMacro/extension.rb
@@ -12,6 +12,10 @@ class InterDocumentReferencesMacro < Asciidoctor::Extensions::InlineMacroProcess
     anchor = attrs[1]
     text = attrs[2]
 
+    if text.nil? || text.empty?
+      raise StandardError, "Crossref needs a description."
+    end
+
     doc = parent.document
 
     if doc.backend == 'html5'