From bd6eb9e893d458b2886fd8d184034bc27418c361 Mon Sep 17 00:00:00 2001
From: SebastianGode <70581801+SebastianGode@users.noreply.github.com>
Date: Tue, 10 Dec 2024 12:22:18 +0100
Subject: [PATCH] Add check for pdf visibility (#45)
Add check for pdf visibility
Reviewed-by: Tino Schr
---
doc/source/examples/directives_as.rst | 15 +++++++++++++++
doc/source/examples/directives_as_internal.rst | 16 ++++++++++++++++
doc/source/examples/index.rst | 2 ++
otc_sphinx_directives/service_card.py | 18 +++++++++++-------
4 files changed, 44 insertions(+), 7 deletions(-)
create mode 100644 doc/source/examples/directives_as.rst
create mode 100644 doc/source/examples/directives_as_internal.rst
diff --git a/doc/source/examples/directives_as.rst b/doc/source/examples/directives_as.rst
new file mode 100644
index 0000000..935102e
--- /dev/null
+++ b/doc/source/examples/directives_as.rst
@@ -0,0 +1,15 @@
+Auto Scaling
+============
+
+Long Long Long Auto Scaling description which is very important.
+
+
+.. directive_wrapper::
+ :class: container-sbv
+ :id: test2
+
+ .. service_card::
+ :service_type: as
+ :umn: This document describes basic concepts, functions, key terms, and FAQs of ASs and provides instructions for applying for and using ASs.
+ :api-ref: This document describes application programming interfaces (APIs) of AS (ECS) and provides API parameter description and example values.
+ :dev: This document describes how to call the APIs of AS (AS) to use AS functions.
diff --git a/doc/source/examples/directives_as_internal.rst b/doc/source/examples/directives_as_internal.rst
new file mode 100644
index 0000000..0da1242
--- /dev/null
+++ b/doc/source/examples/directives_as_internal.rst
@@ -0,0 +1,16 @@
+Auto Scaling - Internal
+=======================
+
+Long Long Long Auto Scaling description which is very important.
+
+
+.. directive_wrapper::
+ :class: container-sbv
+ :id: test2
+
+ .. service_card::
+ :environment: internal
+ :service_type: as
+ :umn: This document describes basic concepts, functions, key terms, and FAQs of ASs and provides instructions for applying for and using ASs.
+ :api-ref: This document describes application programming interfaces (APIs) of AS (AS) and provides API parameter description and example values.
+ :dev: This document describes how to call the APIs of AS (AS) to use ECS functions.
diff --git a/doc/source/examples/index.rst b/doc/source/examples/index.rst
index d5b41f7..75b2f65 100644
--- a/doc/source/examples/index.rst
+++ b/doc/source/examples/index.rst
@@ -7,6 +7,8 @@ Documentation Examples
directives_obs_clean
directives_ecs
directives_ecs_internal
+ directives_as
+ directives_as_internal
directives_bd
directives_geminidb_internal
directives_docsportal
diff --git a/otc_sphinx_directives/service_card.py b/otc_sphinx_directives/service_card.py
index 10fd7a7..2d0661c 100644
--- a/otc_sphinx_directives/service_card.py
+++ b/otc_sphinx_directives/service_card.py
@@ -129,15 +129,19 @@ def service_card_html(self, node):
)
data += ''
try:
+ pdf_environment = doc.get('pdf_environment')
if doc["pdf_enabled"]:
- data += (f'''
-
-
- Download PDF
-
- ''')
+ if pdf_environment == "hidden":
+ print("PDF not enabled anywhere!")
+ elif ((pdf_environment == "internal" and node['environment'] == "internal") or (pdf_environment == "public")):
+ data += (f'''
+
+
+ Download PDF
+
+ ''')
except Exception:
- print("Service " + node['service_type'] + " has not defined pdf_enabled!")
+ print("Service " + node['service_type'] + " has not defined pdf_enabled or pdf_environment!")
data += ''