From 8c2aa088e9b62c5ecb2399bba286a5e58ef08238 Mon Sep 17 00:00:00 2001 From: Sebastian Gode Date: Tue, 9 Sep 2025 12:12:31 +0000 Subject: [PATCH] Add filter to json builds to prevent search indexing on hidden documents (#56) Reviewed-on: https://gitea.eco.tsi-dev.otc-service.com/infra/otc-metadata-rework/pulls/56 Reviewed-by: Tino Schreiber Co-authored-by: Sebastian Gode Co-committed-by: Sebastian Gode --- otc_metadata/templates/tox.ini.j2 | 9 +++++++++ tools/generate_doc_confpy.py | 1 + 2 files changed, 10 insertions(+) diff --git a/otc_metadata/templates/tox.ini.j2 b/otc_metadata/templates/tox.ini.j2 index f855ee9..7328db9 100644 --- a/otc_metadata/templates/tox.ini.j2 +++ b/otc_metadata/templates/tox.ini.j2 @@ -41,7 +41,11 @@ commands = sphinx-minify --input-directory doc/build/html_temp/ --output-directory doc/build/html {%- for doc in docs %} {[testenv:{{ doc.type }}]commands} + {#- To avoid hidden documents to be searchable -#} + {%- if (target_environment == 'internal' and doc.visibility != 'hidden') + or (target_environment == 'public' and doc.visibility == 'public') %} {[testenv:json-{{ doc.type }}]commands} + {%- endif %} {%- endfor %} {% if docs|length > 0 %} @@ -90,6 +94,10 @@ commands = cp -av doc/build/html/{{ doc.type }} {{ doc.type }}/build/html {%- endif %} +{#- To avoid hidden documents to be searchable -#} +{%- if (target_environment == 'internal' and doc.visibility != 'hidden') + or (target_environment == 'public' and doc.visibility == 'public') %} + # Json version (for search) [testenv:json-{{ doc.type }}] deps = {[testenv:docs]deps} @@ -109,6 +117,7 @@ commands = mkdir -p {{ doc.type }}/build/json cp -av doc/build/json/{{ doc.type }} {{ doc.type }}/build/json {%- endif %} +{%- endif %} # PDF version [testenv:{{ doc.type }}-pdf-docs] diff --git a/tools/generate_doc_confpy.py b/tools/generate_doc_confpy.py index 52a5460..b5af54b 100644 --- a/tools/generate_doc_confpy.py +++ b/tools/generate_doc_confpy.py @@ -316,6 +316,7 @@ def process_repositories(args, service): if doc["type"] == "dev": doc["type"] = "dev-guide" doc["pdf_enabled"] = cloud_environment["pdf_enabled"] + doc["visibility"] = cloud_environment["visibility"] context["docs"].append(doc) context["target_environment"] = args.target_environment