summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Fontein <felix@fontein.de>2023-03-27 22:54:29 +0200
committerGitHub <noreply@github.com>2023-03-27 13:54:29 -0700
commit086ae4220957cdb66eee8aa060c151a071f3b9bd (patch)
tree6e41fa7057842fe24eb55a796fe3b594789e10cc
parentba4505f5cb2fb52cda450a06679ddea3599e3e70 (diff)
downloadansible-086ae4220957cdb66eee8aa060c151a071f3b9bd.tar.gz
Fix URL processing. (#80295)
-rw-r--r--test/integration/targets/ansible-doc/fix-urls.py15
-rw-r--r--test/integration/targets/ansible-doc/randommodule-text.output9
-rwxr-xr-xtest/integration/targets/ansible-doc/runme.sh8
-rw-r--r--test/integration/targets/ansible-doc/yolo-text.output12
4 files changed, 26 insertions, 18 deletions
diff --git a/test/integration/targets/ansible-doc/fix-urls.py b/test/integration/targets/ansible-doc/fix-urls.py
new file mode 100644
index 0000000000..1379a4e4a0
--- /dev/null
+++ b/test/integration/targets/ansible-doc/fix-urls.py
@@ -0,0 +1,15 @@
+"""Unwrap URLs to docs.ansible.com and remove version"""
+
+import re
+import sys
+
+
+def main():
+ data = sys.stdin.read()
+ data = re.sub('(https://docs\\.ansible\\.com/[^ ]+)\n +([^ ]+)\n', '\\1\\2\n', data, flags=re.MULTILINE)
+ data = re.sub('https://docs\\.ansible\\.com/ansible(|-core)/(?:[^/]+)/', 'https://docs.ansible.com/ansible\\1/devel/', data)
+ sys.stdout.write(data)
+
+
+if __name__ == '__main__':
+ main()
diff --git a/test/integration/targets/ansible-doc/randommodule-text.output b/test/integration/targets/ansible-doc/randommodule-text.output
index 08eae65e9b..347b2b21bc 100644
--- a/test/integration/targets/ansible-doc/randommodule-text.output
+++ b/test/integration/targets/ansible-doc/randommodule-text.output
@@ -72,12 +72,10 @@ SEE ALSO:
* Module ansible.builtin.ping
The official documentation on the
ansible.builtin.ping module.
- https://docs.ansible.com/ansible-core/devel/collectio
- ns/ansible/builtin/ping_module.html
+ https://docs.ansible.com/ansible-core/devel/collections/ansible/builtin/ping_module.html
* Module ansible.builtin.uri
Use this to fetch an URI
- https://docs.ansible.com/ansible-core/devel/collectio
- ns/ansible/builtin/uri_module.html
+ https://docs.ansible.com/ansible-core/devel/collections/ansible/builtin/uri_module.html
* Module testns.testcol.test
* Module testns.testcol.fakemodule
A fake module
@@ -86,8 +84,7 @@ SEE ALSO:
https://docs.ansible.com
* Ansible documentation [foo_bar]
Some foo bar.
- https://docs.ansible.com/ansible-
- core/devel/#stq=foo_bar&stp=1
+ https://docs.ansible.com/ansible-core/devel/#stq=foo_bar&stp=1
AUTHOR: Ansible Core Team
diff --git a/test/integration/targets/ansible-doc/runme.sh b/test/integration/targets/ansible-doc/runme.sh
index 8fde3e053b..14f746c60b 100755
--- a/test/integration/targets/ansible-doc/runme.sh
+++ b/test/integration/targets/ansible-doc/runme.sh
@@ -43,14 +43,14 @@ expected_out="$(sed '1 s/\(^> TESTNS\.TESTCOL\.FAKEMODULE\).*(.*)$/\1/' fakemodu
test "$current_out" == "$expected_out"
echo "test randommodule docs from collection"
-# we use sed to strip the plugin path from the first line, and remove versions from URLs when this is run from stable-X branches
-current_out="$(ansible-doc --playbook-dir ./ testns.testcol.randommodule | sed '1 s/\(^> TESTNS\.TESTCOL\.RANDOMMODULE\).*(.*)$/\1/' | sed 's/https:\/\/docs.ansible.com\/ansible-core\/[^\/]+\//https:\/\/docs.ansible.com\/ansible-core\/devel\//g')"
+# we use sed to strip the plugin path from the first line, and fix-urls.py to unbreak and replace URLs from stable-X branches
+current_out="$(ansible-doc --playbook-dir ./ testns.testcol.randommodule | sed '1 s/\(^> TESTNS\.TESTCOL\.RANDOMMODULE\).*(.*)$/\1/' | python fix-urls.py)"
expected_out="$(sed '1 s/\(^> TESTNS\.TESTCOL\.RANDOMMODULE\).*(.*)$/\1/' randommodule-text.output)"
test "$current_out" == "$expected_out"
echo "test yolo filter docs from collection"
-# we use sed to strip the plugin path from the first line
-current_out="$(ansible-doc --playbook-dir ./ testns.testcol.yolo --type test | sed '1 s/\(^> TESTNS\.TESTCOL\.YOLO\).*(.*)$/\1/' | sed 's/https:\/\/docs.ansible.com\/ansible-core\/[^\/]+\//https:\/\/docs.ansible.com\/ansible-core\/devel\//g')"
+# we use sed to strip the plugin path from the first line, and fix-urls.py to unbreak and replace URLs from stable-X branches
+current_out="$(ansible-doc --playbook-dir ./ testns.testcol.yolo --type test | sed '1 s/\(^> TESTNS\.TESTCOL\.YOLO\).*(.*)$/\1/' | python fix-urls.py)"
expected_out="$(sed '1 s/\(^> TESTNS\.TESTCOL\.YOLO\).*(.*)$/\1/' yolo-text.output)"
test "$current_out" == "$expected_out"
diff --git a/test/integration/targets/ansible-doc/yolo-text.output b/test/integration/targets/ansible-doc/yolo-text.output
index 5d0570d974..647a4f6a80 100644
--- a/test/integration/targets/ansible-doc/yolo-text.output
+++ b/test/integration/targets/ansible-doc/yolo-text.output
@@ -13,8 +13,7 @@ SEE ALSO:
* Module ansible.builtin.test
The official documentation on the
ansible.builtin.test module.
- https://docs.ansible.com/ansible-core/devel/collectio
- ns/ansible/builtin/test_module.html
+ https://docs.ansible.com/ansible-core/devel/collections/ansible/builtin/test_module.html
* Module testns.testcol.fakemodule
A fake module
* Lookup plugin testns.testcol.noop
@@ -23,19 +22,16 @@ SEE ALSO:
* Filter plugin ansible.builtin.combine
The official documentation on the
ansible.builtin.combine filter plugin.
- https://docs.ansible.com/ansible-core/devel/collectio
- ns/ansible/builtin/combine_filter.html
+ https://docs.ansible.com/ansible-core/devel/collections/ansible/builtin/combine_filter.html
* Lookup plugin ansible.builtin.file
Read a file on the controller.
- https://docs.ansible.com/ansible-core/devel/collectio
- ns/ansible/builtin/file_lookup.html
+ https://docs.ansible.com/ansible-core/devel/collections/ansible/builtin/file_lookup.html
* Ansible docsite
See also the Ansible docsite.
https://docs.ansible.com
* Ansible documentation [foo_bar]
Some foo bar.
- https://docs.ansible.com/ansible-
- core/devel/#stq=foo_bar&stp=1
+ https://docs.ansible.com/ansible-core/devel/#stq=foo_bar&stp=1
NAME: yolo