From ee11847c7e594207f333b158a663ff08b4e11387 Mon Sep 17 00:00:00 2001
From: Felix Fontein <felix@fontein.de>
Date: Sun, 16 Apr 2023 18:20:52 +0200
Subject: [PATCH] Do extra docs validation; explicitly disallow semantic markup
 in docs (#6345)

* Do extra docs validation. Explicitly disallow semantic markup in docs.

* Forgot to add new requirement.

* Fix prefixes.

* Remove superfluous condition.

* TEMP - make CI fail.

* Revert "TEMP - make CI fail."

This reverts commit 14f4d6b503e36b1c29144013640b85a277a983de.

* Remove unnecessary import.

* Make sure ANSIBLE_COLLECTIONS_PATH is set.

* Make sure sanity tests from older Ansible versions don't complain.
---
 tests/sanity/extra/extra-docs.json |  5 ++++-
 tests/sanity/extra/extra-docs.py   | 11 ++++++++---
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/tests/sanity/extra/extra-docs.json b/tests/sanity/extra/extra-docs.json
index c2e612e5f7..9a28d174fd 100644
--- a/tests/sanity/extra/extra-docs.json
+++ b/tests/sanity/extra/extra-docs.json
@@ -1,10 +1,13 @@
 {
     "include_symlinks": false,
     "prefixes": [
-        "docs/docsite/"
+        "docs/docsite/",
+        "plugins/",
+        "roles/"
     ],
     "output": "path-line-column-message",
     "requirements": [
+        "ansible-core",
         "antsibull-docs"
     ]
 }
diff --git a/tests/sanity/extra/extra-docs.py b/tests/sanity/extra/extra-docs.py
index 6731049231..c636beb08e 100755
--- a/tests/sanity/extra/extra-docs.py
+++ b/tests/sanity/extra/extra-docs.py
@@ -13,9 +13,14 @@ import subprocess
 
 def main():
     """Main entry point."""
-    if not os.path.isdir(os.path.join('docs', 'docsite')):
-        return
-    p = subprocess.run(['antsibull-docs', 'lint-collection-docs', '.'], check=False)
+    env = os.environ.copy()
+    suffix = ':{env}'.format(env=env["ANSIBLE_COLLECTIONS_PATH"]) if 'ANSIBLE_COLLECTIONS_PATH' in env else ''
+    env['ANSIBLE_COLLECTIONS_PATH'] = '{root}{suffix}'.format(root=os.path.dirname(os.path.dirname(os.path.dirname(os.getcwd()))), suffix=suffix)
+    p = subprocess.run(
+        ['antsibull-docs', 'lint-collection-docs', '--plugin-docs', '--disallow-semantic-markup', '--skip-rstcheck', '.'],
+        env=env,
+        check=False,
+    )
     if p.returncode not in (0, 3):
         print('{0}:0:0: unexpected return code {1}'.format(sys.argv[0], p.returncode))