diff --git a/docs/apache-airflow-providers-ftp/index.rst b/docs/apache-airflow-providers-ftp/index.rst
index 75bc3bd5756b7..f3194e77d6965 100644
--- a/docs/apache-airflow-providers-ftp/index.rst
+++ b/docs/apache-airflow-providers-ftp/index.rst
@@ -43,8 +43,13 @@ Content
PyPI Repository
Installing from sources
-.. THE REMAINDER OF THE FILE IS AUTOMATICALLY GENERATED. IT WILL BE OVERWRITTEN AT RELEASE TIME!
+.. toctree::
+ :hidden:
+ :caption: System tests
+ System Tests <_api/tests/system/providers/ftp/index>
+
+.. THE REMAINDER OF THE FILE IS AUTOMATICALLY GENERATED. IT WILL BE OVERWRITTEN AT RELEASE TIME!
.. toctree::
:maxdepth: 1
@@ -52,12 +57,6 @@ Content
Detailed list of commits
-.. toctree::
- :hidden:
- :caption: System tests
-
- System Tests <_api/tests/system/providers/ftp/index>
-
Package apache-airflow-providers-ftp
------------------------------------------------------
diff --git a/scripts/ci/pre_commit/pre_commit_check_system_tests_hidden_in_index.py b/scripts/ci/pre_commit/pre_commit_check_system_tests_hidden_in_index.py
index 3cc29e5a03b3e..c8adab41b45fb 100755
--- a/scripts/ci/pre_commit/pre_commit_check_system_tests_hidden_in_index.py
+++ b/scripts/ci/pre_commit/pre_commit_check_system_tests_hidden_in_index.py
@@ -56,10 +56,16 @@ def check_system_test_entry_hidden(provider_index: Path):
"""
index_text = provider_index.read_text()
system_tests_path = AIRFLOW_SOURCES_ROOT / "tests" / "system" / "providers" / provider_path
+ index_text_manual = index_text.split(
+ ".. THE REMAINDER OF THE FILE IS AUTOMATICALLY GENERATED. IT WILL BE OVERWRITTEN AT RELEASE TIME!"
+ )[0]
if system_tests_path.exists():
- if expected_text not in index_text:
+ if expected_text not in index_text_manual:
console.print(f"[red]The {provider_index} does not contain System Tests TOC.\n")
- console.print(f"[yellow]Make sure to add those lines to {provider_index}:\n")
+ console.print(
+ f"[yellow]Make sure to add those lines to {provider_index} BEFORE (!) the line "
+ f"starting with '.. THE REMINDER OF THE FILE':\n"
+ )
console.print(expected_text, markup=False)
errors.append(provider_index)
else: