Compare commits
2 Commits
cab8a437aa
...
pdf
Author | SHA1 | Date | |
---|---|---|---|
03ecab9755 | |||
ec59663c39 |
44
README.rst
44
README.rst
@ -1,9 +1,6 @@
|
|||||||
============
|
===============================
|
||||||
otc-metadata
|
ssh://git@gitea.eco.tsi-dev.otc-service.com:2222/infra/otc-metadata.git
|
||||||
============
|
===============================
|
||||||
|
|
||||||
Link: ssh://git@gitea.eco.tsi-dev.otc-service.com:2222/infra/otc-metadata.git
|
|
||||||
|
|
||||||
|
|
||||||
Metadata about OTC for Ecosystem
|
Metadata about OTC for Ecosystem
|
||||||
|
|
||||||
@ -16,39 +13,6 @@ Note that this is a hard requirement.
|
|||||||
* Source: https://github.com/infra/ssh://git@gitea.eco.tsi-dev.otc-service.com:2222/infra/otc-metadata.git
|
* Source: https://github.com/infra/ssh://git@gitea.eco.tsi-dev.otc-service.com:2222/infra/otc-metadata.git
|
||||||
|
|
||||||
Features
|
Features
|
||||||
========
|
--------
|
||||||
|
|
||||||
* TODO
|
* TODO
|
||||||
|
|
||||||
Overview: service.yaml
|
|
||||||
======================
|
|
||||||
|
|
||||||
The :code:`service.yaml` file contains all data about services, service
|
|
||||||
categories and the related documents of each service. The file is
|
|
||||||
used as a base for several internal and external applications or
|
|
||||||
websites like the Helpcenter 3.0 where the information about the document
|
|
||||||
repositories and its properties are stored.
|
|
||||||
|
|
||||||
File structure
|
|
||||||
--------------
|
|
||||||
|
|
||||||
The file is based on the yaml-file format and has three main sections
|
|
||||||
which can be compared with database tables in a relational database.
|
|
||||||
|
|
||||||
* documents: contains the information about every single document and its type
|
|
||||||
like umn, api-ref etc.
|
|
||||||
|
|
||||||
* service category: contains the keyword and title of the service category
|
|
||||||
|
|
||||||
* services: contains the repository information about the internal (Gitea) and
|
|
||||||
external location (GitHub) and all the necessary parameters of the service itself
|
|
||||||
|
|
||||||
These sections, or better "tables" have
|
|
||||||
their own keys and foreign keys so that the tables are linked together and
|
|
||||||
the related information can be fetched.
|
|
||||||
For the :code:`services` table
|
|
||||||
the key is :code:`service_type` which has the foreign key in the
|
|
||||||
:code:`documents` table. So a service can have multiple documents and each
|
|
||||||
document can only be linked to one service.
|
|
||||||
The key :code:`service_category` table is :code:`name` of the service category
|
|
||||||
which is then used in the :code:`services` table as foreign key.
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -18,10 +18,7 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
extensions = [
|
extensions = [
|
||||||
'otcdocstheme',
|
'otcdocstheme'
|
||||||
{%- if otc_sbv %}
|
|
||||||
'otc_sphinx_directives'
|
|
||||||
{%- endif %}
|
|
||||||
]
|
]
|
||||||
|
|
||||||
otcdocs_auto_name = False
|
otcdocs_auto_name = False
|
||||||
@ -37,15 +34,6 @@ 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 }}'
|
|
||||||
|
|
||||||
# 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.
|
||||||
|
@ -2,6 +2,3 @@ sphinx>=2.0.0,!=2.1.0 # BSD
|
|||||||
otcdocstheme # Apache-2.0
|
otcdocstheme # Apache-2.0
|
||||||
# releasenotes
|
# releasenotes
|
||||||
reno>=3.1.0 # Apache-2.0
|
reno>=3.1.0 # Apache-2.0
|
||||||
|
|
||||||
otc-sphinx-directives>=0.1.0
|
|
||||||
git+https://gitea.eco.tsi-dev.otc-service.com/infra/otc-metadata.git#egg=otc_metadata
|
|
@ -1,7 +0,0 @@
|
|||||||
{{ sbv_title }}
|
|
||||||
|
|
||||||
.. directive_wrapper::
|
|
||||||
:class: container-sbv
|
|
||||||
|
|
||||||
.. service_card::
|
|
||||||
:service_type: {{ service_type }}
|
|
@ -29,17 +29,13 @@ allowlist_externals =
|
|||||||
mkdir
|
mkdir
|
||||||
cp
|
cp
|
||||||
sh
|
sh
|
||||||
rm
|
|
||||||
sphinx-build
|
|
||||||
commands =
|
commands =
|
||||||
rm -rf doc/build/html doc/build/doctrees
|
|
||||||
sphinx-build -a -E -W -d doc/build/doctrees -b html doc/source 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:pdf-docs]
|
||||||
deps = -r{toxinidir}/doc/requirements.txt
|
deps = -r{toxinidir}/doc/requirements.txt
|
||||||
allowlist_externals =
|
allowlist_externals =
|
||||||
rm
|
rm
|
||||||
@ -119,7 +115,3 @@ commands =
|
|||||||
cp {{ loc }}/build/pdf/{{ doc.pdf_name }}.pdf doc/build/pdf/
|
cp {{ loc }}/build/pdf/{{ doc.pdf_name }}.pdf doc/build/pdf/
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
[doc8]
|
|
||||||
ignore = D001
|
|
||||||
extensions = .rst, .yaml
|
|
@ -21,45 +21,8 @@ Tests for `otc-metadata` module.
|
|||||||
|
|
||||||
from unittest import TestCase
|
from unittest import TestCase
|
||||||
|
|
||||||
from otc_metadata import services
|
|
||||||
|
|
||||||
|
|
||||||
class TestOtcMetadata(TestCase):
|
class TestOtcMetadata(TestCase):
|
||||||
def setUp(self):
|
|
||||||
self.data = services.Services()
|
|
||||||
|
|
||||||
def test_data_is_sorted(self):
|
def test_something(self):
|
||||||
curr = self.data
|
pass
|
||||||
new = services.Services()
|
|
||||||
new._sort_data()
|
|
||||||
self.assertEqual(
|
|
||||||
curr._service_data, new._service_data, "Data is sorted properly"
|
|
||||||
)
|
|
||||||
|
|
||||||
def test_service_categories(self):
|
|
||||||
category = dict()
|
|
||||||
for cat in self.data._service_data["service_categories"]:
|
|
||||||
category[cat["name"]] = cat["title"]
|
|
||||||
for srv in self.data.all_services:
|
|
||||||
self.assertTrue(
|
|
||||||
srv["service_category"] in category,
|
|
||||||
f"Category {srv['service_category']} is present",
|
|
||||||
)
|
|
||||||
|
|
||||||
def test_doc_contains_required_data(self):
|
|
||||||
srv_types = dict()
|
|
||||||
for srv in self.data.all_services:
|
|
||||||
srv_types[srv["service_type"]] = srv
|
|
||||||
for doc in self.data.all_docs:
|
|
||||||
for attr in [
|
|
||||||
"rst_location",
|
|
||||||
"service_type",
|
|
||||||
"title",
|
|
||||||
"type",
|
|
||||||
]:
|
|
||||||
self.assertIn(attr, doc, f"Document {doc} contains {attr}")
|
|
||||||
self.assertIn(
|
|
||||||
doc["service_type"],
|
|
||||||
srv_types,
|
|
||||||
f"Document {doc} contains valid service_type",
|
|
||||||
)
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -130,6 +130,7 @@ def process_repositories(args, service):
|
|||||||
zuul_templates = None
|
zuul_templates = None
|
||||||
zuul_jobs = dict()
|
zuul_jobs = dict()
|
||||||
zuul_new_jobs = list()
|
zuul_new_jobs = list()
|
||||||
|
zuul_vars = dict()
|
||||||
zuul_config_updated = False
|
zuul_config_updated = False
|
||||||
for item in zuul_config:
|
for item in zuul_config:
|
||||||
if "project" in item.keys():
|
if "project" in item.keys():
|
||||||
@ -137,10 +138,11 @@ def process_repositories(args, service):
|
|||||||
zuul_templates = project.setdefault("templates", [])
|
zuul_templates = project.setdefault("templates", [])
|
||||||
if not zuul_templates:
|
if not zuul_templates:
|
||||||
zuul_templates = []
|
zuul_templates = []
|
||||||
|
zuul_vars = project.setdefault("vars", {})
|
||||||
elif "job" in item.keys():
|
elif "job" in item.keys():
|
||||||
job = item["job"]
|
job = item["job"]
|
||||||
zuul_jobs[job["name"]] = job
|
zuul_jobs[job["name"]] = job
|
||||||
print(f"Existing jobs {zuul_jobs}")
|
logging.debug(f"Existing jobs {zuul_jobs}")
|
||||||
if "helpcenter-base-jobs" not in zuul_templates:
|
if "helpcenter-base-jobs" not in zuul_templates:
|
||||||
zuul_templates.append("helpcenter-base-jobs")
|
zuul_templates.append("helpcenter-base-jobs")
|
||||||
zuul_config_updated = True
|
zuul_config_updated = True
|
||||||
@ -148,6 +150,7 @@ def process_repositories(args, service):
|
|||||||
job_suffix = (
|
job_suffix = (
|
||||||
"-hc-int-jobs" if args.environment == "internal" else "-hc-jobs"
|
"-hc-int-jobs" if args.environment == "internal" else "-hc-jobs"
|
||||||
)
|
)
|
||||||
|
sphinx_pdf_files = zuul_vars.setdefault('sphinx_pdf_files', [])
|
||||||
for doc in data.docs_by_service_type(service["service_type"]):
|
for doc in data.docs_by_service_type(service["service_type"]):
|
||||||
logging.debug(f"Analyzing document {doc}")
|
logging.debug(f"Analyzing document {doc}")
|
||||||
if not doc.get("type"):
|
if not doc.get("type"):
|
||||||
@ -156,6 +159,12 @@ def process_repositories(args, service):
|
|||||||
doc_type = "dev-guide"
|
doc_type = "dev-guide"
|
||||||
else:
|
else:
|
||||||
doc_type = doc["type"]
|
doc_type = doc["type"]
|
||||||
|
# Collect all PDF files into sphinx_pdf_files var
|
||||||
|
pdf_name = doc.get('pdf_name')
|
||||||
|
if pdf_name and f"{pdf_name}.pdf" not in sphinx_pdf_files:
|
||||||
|
sphinx_pdf_files.append(f"{pdf_name}.pdf")
|
||||||
|
zuul_config_updated = True
|
||||||
|
|
||||||
template_name = f"{doc_type}{job_suffix}"
|
template_name = f"{doc_type}{job_suffix}"
|
||||||
if doc_type in ["api-ref", "umn", "dev-guide"]:
|
if doc_type in ["api-ref", "umn", "dev-guide"]:
|
||||||
if template_name not in zuul_templates:
|
if template_name not in zuul_templates:
|
||||||
@ -190,6 +199,7 @@ def process_repositories(args, service):
|
|||||||
if "project" in item.keys():
|
if "project" in item.keys():
|
||||||
project = item["project"]
|
project = item["project"]
|
||||||
project["templates"] = zuul_templates
|
project["templates"] = zuul_templates
|
||||||
|
project["vars"] = zuul_vars
|
||||||
# Ensure new jobs are in check
|
# Ensure new jobs are in check
|
||||||
if len(zuul_new_jobs) > 0:
|
if len(zuul_new_jobs) > 0:
|
||||||
project.setdefault(
|
project.setdefault(
|
||||||
|
1
tox.ini
1
tox.ini
@ -19,6 +19,7 @@ commands = {posargs}
|
|||||||
|
|
||||||
[flake8]
|
[flake8]
|
||||||
# E123, E125 skipped as they are invalid PEP-8.
|
# E123, E125 skipped as they are invalid PEP-8.
|
||||||
|
|
||||||
show-source = True
|
show-source = True
|
||||||
ignore = E123,E125,W503
|
ignore = E123,E125,W503
|
||||||
builtins = _
|
builtins = _
|
||||||
|
Reference in New Issue
Block a user