Compare commits
11 Commits
adding_sor
...
minify-tem
Author | SHA1 | Date | |
---|---|---|---|
c8ac912005 | |||
2b99369390 | |||
96ffbc1403 | |||
ca8c5fb34c | |||
a6a001cdba | |||
7b319ca858 | |||
9bb3ef92a5 | |||
898c1aafc2 | |||
d8ed8a0ba4 | |||
bc0676ac51 | |||
6caf290136 |
@ -1,5 +1,4 @@
|
|||||||
---
|
---
|
||||||
environment: internal
|
|
||||||
hc_location: api/dwaf
|
hc_location: api/dwaf
|
||||||
html_location: docs/wafd/api-ref
|
html_location: docs/wafd/api-ref
|
||||||
link: /web-application-firewall-dedicated/api-ref/
|
link: /web-application-firewall-dedicated/api-ref/
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
---
|
---
|
||||||
environment: internal
|
|
||||||
hc_location: usermanual/dwaf
|
hc_location: usermanual/dwaf
|
||||||
html_location: docs/wafd/umn
|
html_location: docs/wafd/umn
|
||||||
link: /web-application-firewall-dedicated/umn/
|
link: /web-application-firewall-dedicated/umn/
|
||||||
|
@ -122,6 +122,58 @@ class Services(object):
|
|||||||
res[cat]["docs"].append(res_doc)
|
res[cat]["docs"].append(res_doc)
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
def service_types_with_doc_types(self, environment=None):
|
||||||
|
"""Retrieve type and title from services and corresponding docs.
|
||||||
|
As well as a list of all available doc types with title.
|
||||||
|
|
||||||
|
:param str environment: Optional service environment.
|
||||||
|
"""
|
||||||
|
service_list = []
|
||||||
|
docs = []
|
||||||
|
|
||||||
|
for service in self.all_services:
|
||||||
|
if "environment" in service:
|
||||||
|
if service["environment"] != environment:
|
||||||
|
continue
|
||||||
|
if not service["service_title"]:
|
||||||
|
continue
|
||||||
|
if not service["service_type"]:
|
||||||
|
continue
|
||||||
|
|
||||||
|
doc_list = []
|
||||||
|
for doc in self.all_docs:
|
||||||
|
if "environment" in doc:
|
||||||
|
if doc["environment"] != environment:
|
||||||
|
continue
|
||||||
|
if doc["service_type"] == service["service_type"]:
|
||||||
|
doc_list.append({
|
||||||
|
"title": doc["title"],
|
||||||
|
"type": doc["type"]
|
||||||
|
})
|
||||||
|
|
||||||
|
new_doc = {
|
||||||
|
"type": doc["type"],
|
||||||
|
"title": doc["title"]
|
||||||
|
}
|
||||||
|
type_exists = any(
|
||||||
|
doc_dict["type"] == new_doc["type"] for doc_dict in docs
|
||||||
|
)
|
||||||
|
if not type_exists:
|
||||||
|
docs.append(new_doc)
|
||||||
|
|
||||||
|
service_list.append({
|
||||||
|
"service_title": service["service_title"],
|
||||||
|
"service_type": service["service_type"],
|
||||||
|
"docs": doc_list
|
||||||
|
})
|
||||||
|
|
||||||
|
res = {
|
||||||
|
"services": service_list,
|
||||||
|
"docs": docs
|
||||||
|
}
|
||||||
|
|
||||||
|
return res
|
||||||
|
|
||||||
def docs_by_service_category(self, category, environment=None):
|
def docs_by_service_category(self, category, environment=None):
|
||||||
"""List services matching category
|
"""List services matching category
|
||||||
|
|
||||||
@ -185,6 +237,8 @@ class Services(object):
|
|||||||
srv_res = dict(
|
srv_res = dict(
|
||||||
service_title=srv["service_title"],
|
service_title=srv["service_title"],
|
||||||
service_type=srv["service_type"],
|
service_type=srv["service_type"],
|
||||||
|
service_category=srv["service_category"],
|
||||||
|
service_environment=environment,
|
||||||
docs=[],
|
docs=[],
|
||||||
)
|
)
|
||||||
if "teams" in srv:
|
if "teams" in srv:
|
||||||
@ -208,6 +262,7 @@ class Services(object):
|
|||||||
rst_location=doc["rst_location"],
|
rst_location=doc["rst_location"],
|
||||||
title=doc["title"],
|
title=doc["title"],
|
||||||
type=doc.get("type", "dummy"),
|
type=doc.get("type", "dummy"),
|
||||||
|
link=doc["link"],
|
||||||
)
|
)
|
||||||
if "pdf_name" in doc:
|
if "pdf_name" in doc:
|
||||||
doc_res["pdf_name"] = doc["pdf_name"]
|
doc_res["pdf_name"] = doc["pdf_name"]
|
||||||
|
@ -26,7 +26,6 @@ extensions = [
|
|||||||
|
|
||||||
otcdocs_auto_name = False
|
otcdocs_auto_name = False
|
||||||
otcdocs_auto_version = False
|
otcdocs_auto_version = False
|
||||||
otcdocs_search_environment = 'hc_swiss'
|
|
||||||
|
|
||||||
project = '{{ project }}'
|
project = '{{ project }}'
|
||||||
otcdocs_repo_name = '{{ repo_name }}'
|
otcdocs_repo_name = '{{ repo_name }}'
|
||||||
@ -38,6 +37,18 @@ otcdocs_git_fqdn = '{{ git_fqdn }}'
|
|||||||
otcdocs_git_type = '{{ git_type }}'
|
otcdocs_git_type = '{{ git_type }}'
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
|
||||||
|
# Those variables are needed for indexing into OpenSearch
|
||||||
|
otcdocs_doc_environment = '{{ doc_environment }}'
|
||||||
|
otcdocs_doc_link = '{{ doc_link }}'
|
||||||
|
otcdocs_doc_title = '{{ doc_title }}'
|
||||||
|
otcdocs_doc_type = '{{ doc_type }}'
|
||||||
|
otcdocs_service_category = '{{ service_category }}'
|
||||||
|
otcdocs_service_title = '{{ service_title }}'
|
||||||
|
otcdocs_service_type = '{{ service_type }}'
|
||||||
|
otcdocs_search_environment = 'hc_swiss'
|
||||||
|
otcdocs_search_index = 'search_index_swiss'
|
||||||
|
otcdocs_search_url = "https://opensearch.eco.tsi-dev.otc-service.com/"
|
||||||
|
|
||||||
# If extensions (or modules to document with autodoc) are in another directory,
|
# If extensions (or modules to document with autodoc) are in another directory,
|
||||||
# add these directories to sys.path here. If the directory is relative to the
|
# add these directories to sys.path here. If the directory is relative to the
|
||||||
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
||||||
|
@ -4,4 +4,5 @@ otcdocstheme # Apache-2.0
|
|||||||
reno>=3.1.0 # Apache-2.0
|
reno>=3.1.0 # Apache-2.0
|
||||||
|
|
||||||
otc-sphinx-directives>=0.1.0
|
otc-sphinx-directives>=0.1.0
|
||||||
|
sphinx-minify>=0.0.1 # Apache-2.0
|
||||||
git+https://gitea.eco.tsi-dev.otc-service.com/infra/otc-metadata-swiss.git#egg=otc_metadata
|
git+https://gitea.eco.tsi-dev.otc-service.com/infra/otc-metadata-swiss.git#egg=otc_metadata
|
||||||
|
@ -24,7 +24,9 @@ commands = {posargs}
|
|||||||
# This env is invoked in the periodic pipeline and is therefore responsible to
|
# This env is invoked in the periodic pipeline and is therefore responsible to
|
||||||
# build all relevant docs at once.
|
# build all relevant docs at once.
|
||||||
[testenv:docs]
|
[testenv:docs]
|
||||||
deps = -r{toxinidir}/doc/requirements.txt
|
deps =
|
||||||
|
-r{toxinidir}/doc/requirements.txt
|
||||||
|
-c https://raw.githubusercontent.com/opentelekomcloud-docs-swiss/docs-constraints/main/constraints.txt
|
||||||
allowlist_externals =
|
allowlist_externals =
|
||||||
mkdir
|
mkdir
|
||||||
cp
|
cp
|
||||||
@ -32,15 +34,16 @@ allowlist_externals =
|
|||||||
rm
|
rm
|
||||||
sphinx-build
|
sphinx-build
|
||||||
commands =
|
commands =
|
||||||
rm -rf doc/build/html doc/build/doctrees
|
rm -rf doc/build/html doc/build/html_temp doc/build/doctrees
|
||||||
sphinx-build -a -E -W -d doc/build/doctrees -b html doc/source doc/build/html
|
sphinx-build -a -E -W -d doc/build/doctrees -b html doc/source doc/build/html_temp
|
||||||
|
sphinx-minify --input-directory doc/build/html_temp/ --output-directory doc/build/html
|
||||||
{%- for doc in docs %}
|
{%- for doc in docs %}
|
||||||
{[testenv:{{ doc.type }}]commands}
|
{[testenv:{{ doc.type }}]commands}
|
||||||
{[testenv:json-{{ doc.type }}]commands}
|
{[testenv:json-{{ doc.type }}]commands}
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
|
|
||||||
[testenv:docs-pdf]
|
[testenv:docs-pdf]
|
||||||
deps = -r{toxinidir}/doc/requirements.txt
|
deps = {[testenv:docs]deps}
|
||||||
allowlist_externals =
|
allowlist_externals =
|
||||||
rm
|
rm
|
||||||
mkdir
|
mkdir
|
||||||
@ -59,26 +62,24 @@ commands =
|
|||||||
{% set loc = doc.rst_location | replace('/source', '') %}
|
{% set loc = doc.rst_location | replace('/source', '') %}
|
||||||
# HTML version
|
# HTML version
|
||||||
[testenv:{{ doc.type }}]
|
[testenv:{{ doc.type }}]
|
||||||
deps = -r{toxinidir}/doc/requirements.txt
|
deps = {[testenv:docs]deps}
|
||||||
allowlist_externals =
|
allowlist_externals =
|
||||||
cp
|
cp
|
||||||
mkdir
|
mkdir
|
||||||
commands =
|
commands =
|
||||||
sphinx-build -W --keep-going -b html {{ loc }}/source doc/build/html/{{ doc.type }}
|
sphinx-build -W --keep-going -b html {{ loc }}/source doc/build/html_temp/{{ doc.type }}
|
||||||
{%- if doc.type == 'api-ref' %}
|
sphinx-minify --input-directory doc/build/html_temp/{{ doc.type }} --output-directory doc/build/html/{{ doc.type }}
|
||||||
mkdir -p api-ref/build/html
|
{%- if doc.type == 'dev-guide' %}
|
||||||
cp -av doc/build/html/api-ref api-ref/build/html
|
|
||||||
{%- elif doc.type == 'umn' %}
|
|
||||||
mkdir -p umn/build/html
|
|
||||||
cp -av doc/build/html/umn umn/build/html
|
|
||||||
{%- elif doc.type == 'dev-guide' %}
|
|
||||||
mkdir -p dev_guide/build/html
|
mkdir -p dev_guide/build/html
|
||||||
cp -av doc/build/html/dev-guide dev_guide/build/html
|
cp -av doc/build/html/dev-guide dev_guide/build/html
|
||||||
|
{%- else %}
|
||||||
|
mkdir -p {{ doc.type }}/build/html
|
||||||
|
cp -av doc/build/html/{{ doc.type }} {{ doc.type }}/build/html
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
|
||||||
# Json version (for search)
|
# Json version (for search)
|
||||||
[testenv:json-{{ doc.type }}]
|
[testenv:json-{{ doc.type }}]
|
||||||
deps = -r{toxinidir}/doc/requirements.txt
|
deps = {[testenv:docs]deps}
|
||||||
allowlist_externals =
|
allowlist_externals =
|
||||||
cp
|
cp
|
||||||
mkdir
|
mkdir
|
||||||
@ -88,21 +89,18 @@ commands =
|
|||||||
# Drop data useless for the search - wrap it also with sh/xargs due to bugs
|
# Drop data useless for the search - wrap it also with sh/xargs due to bugs
|
||||||
# in tox
|
# in tox
|
||||||
sh -c "find doc/build/json -type d -and '(' -name '_images' -or -name '_static' -or -name '_sources' ')' -print0 | xargs -0 rm -rf"
|
sh -c "find doc/build/json -type d -and '(' -name '_images' -or -name '_static' -or -name '_sources' ')' -print0 | xargs -0 rm -rf"
|
||||||
{%- if doc.type == 'api-ref' %}
|
{%- if doc.type == 'dev-guide' %}
|
||||||
mkdir -p api-ref/build/json
|
|
||||||
cp -av doc/build/json/api-ref api-ref/build/json
|
|
||||||
{%- elif doc.type == 'umn' %}
|
|
||||||
mkdir -p umn/build/json
|
|
||||||
cp -av doc/build/json/umn umn/build/json
|
|
||||||
{%- elif doc.type == 'dev-guide' %}
|
|
||||||
mkdir -p dev_guide/build/json
|
mkdir -p dev_guide/build/json
|
||||||
cp -av doc/build/json/dev-guide dev_guide/build/json
|
cp -av doc/build/json/dev-guide dev_guide/build/json
|
||||||
|
{%- else %}
|
||||||
|
mkdir -p {{ doc.type }}/build/json
|
||||||
|
cp -av doc/build/json/{{ doc.type }} {{ doc.type }}/build/json
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
|
||||||
{% if doc.pdf_name -%}
|
{% if doc.pdf_name -%}
|
||||||
# PDF version
|
# PDF version
|
||||||
[testenv:{{ doc.type }}-pdf-docs]
|
[testenv:{{ doc.type }}-pdf-docs]
|
||||||
deps = -r{toxinidir}/doc/requirements.txt
|
deps = {[testenv:docs]deps}
|
||||||
allowlist_externals =
|
allowlist_externals =
|
||||||
rm
|
rm
|
||||||
mkdir
|
mkdir
|
||||||
|
@ -148,8 +148,30 @@ def process_repositories(args, service):
|
|||||||
context["html_options"] = dict(
|
context["html_options"] = dict(
|
||||||
disable_search=True,
|
disable_search=True,
|
||||||
site_name="Internal Documentation Portal",
|
site_name="Internal Documentation Portal",
|
||||||
logo_url="https://docs-int.otc-service.com",
|
logo_url="https://docs-int.sc.otc.t-systems.com",
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
|
context["html_options"] = dict(
|
||||||
|
site_name="Swiss Open Telekom Cloud Docs",
|
||||||
|
logo_url="https://docs-beta.sc.otc.t-systems.com",
|
||||||
|
)
|
||||||
|
context["doc_environment"] = args.target_environment
|
||||||
|
if doc['link']:
|
||||||
|
context["doc_link"] = doc['link']
|
||||||
|
else:
|
||||||
|
context["doc_link"] = (
|
||||||
|
'/'
|
||||||
|
+ service['service_uri']
|
||||||
|
+ '/'
|
||||||
|
+ doc['type']
|
||||||
|
+ '/'
|
||||||
|
)
|
||||||
|
context["doc_title"] = doc['title']
|
||||||
|
context["doc_type"] = doc['type']
|
||||||
|
context["service_category"] = service['service_category']
|
||||||
|
context["service_title"] = service['service_title']
|
||||||
|
context["service_type"] = service['service_type']
|
||||||
|
|
||||||
conf_py_content = conf_py_template.render(**context)
|
conf_py_content = conf_py_template.render(**context)
|
||||||
with open(conf_py_path, "w", encoding="utf-8", newline="") as out:
|
with open(conf_py_path, "w", encoding="utf-8", newline="") as out:
|
||||||
logging.debug(f"Generating {conf_py_path} from template...")
|
logging.debug(f"Generating {conf_py_path} from template...")
|
||||||
@ -167,6 +189,8 @@ def process_repositories(args, service):
|
|||||||
title=f"{service['service_title']} - Service Based View",
|
title=f"{service['service_title']} - Service Based View",
|
||||||
service_type=service["service_type"]
|
service_type=service["service_type"]
|
||||||
)
|
)
|
||||||
|
context["service_category"] = service['service_category']
|
||||||
|
context["service_title"] = service['service_title']
|
||||||
if not copy_path.exists():
|
if not copy_path.exists():
|
||||||
logging.info("Path for sbv does not exist")
|
logging.info("Path for sbv does not exist")
|
||||||
copy_path.mkdir(parents=True, exist_ok=True)
|
copy_path.mkdir(parents=True, exist_ok=True)
|
||||||
@ -179,7 +203,12 @@ def process_repositories(args, service):
|
|||||||
context["html_options"] = dict(
|
context["html_options"] = dict(
|
||||||
disable_search=True,
|
disable_search=True,
|
||||||
site_name="Internal Documentation Portal",
|
site_name="Internal Documentation Portal",
|
||||||
logo_url="https://docs-int.otc-service.com",
|
logo_url="https://docs-int.sc.otc.t-systems.com",
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
context["html_options"] = dict(
|
||||||
|
site_name="Swiss Open Telekom Cloud Docs",
|
||||||
|
logo_url="https://docs-beta.sc.otc.t-systems.com",
|
||||||
)
|
)
|
||||||
sbv_title = (service["service_title"] + "\n"
|
sbv_title = (service["service_title"] + "\n"
|
||||||
+ ('=' * len(service["service_title"])))
|
+ ('=' * len(service["service_title"])))
|
||||||
@ -248,7 +277,7 @@ def process_repositories(args, service):
|
|||||||
args.commit_description
|
args.commit_description
|
||||||
)
|
)
|
||||||
push_args = ["--set-upstream", "origin", branch_name]
|
push_args = ["--set-upstream", "origin", branch_name]
|
||||||
if args.branch_force:
|
if args.force_push:
|
||||||
push_args.append("--force")
|
push_args.append("--force")
|
||||||
repo_to.git.push(*push_args)
|
repo_to.git.push(*push_args)
|
||||||
if "github" in url_to:
|
if "github" in url_to:
|
||||||
@ -328,6 +357,11 @@ def main():
|
|||||||
help=("Whether to overwrite index.rst for service-based-view."
|
help=("Whether to overwrite index.rst for service-based-view."
|
||||||
+ "\nCan only be used if --update-sbv is also specified")
|
+ "\nCan only be used if --update-sbv is also specified")
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--force-push",
|
||||||
|
action="store_true",
|
||||||
|
help="Whether to force push the commit"
|
||||||
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--commit-description",
|
"--commit-description",
|
||||||
default=(
|
default=(
|
||||||
|
Reference in New Issue
Block a user