Create doc-exports metadata generator script

- add script to generate metadata file for doc-exports repository
- fix metadata issues which became visible with that script
This commit is contained in:
Artem Goncharov 2022-08-22 12:04:17 +02:00
parent 7b158ac72b
commit 2ff9eeca27
3 changed files with 65 additions and 5 deletions

View File

@ -7,7 +7,7 @@ documents:
- html_location: docs/antiddos/api-ref - html_location: docs/antiddos/api-ref
pdf_name: antiddos-api-ref pdf_name: antiddos-api-ref
rst_location: api-ref/source rst_location: api-ref/source
service_ype: antiddos service_type: antiddos
title: API Reference title: API Reference
- html_location: docs/cbr/umn - html_location: docs/cbr/umn
pdf_name: cbr-umn pdf_name: cbr-umn
@ -75,13 +75,15 @@ documents:
service_type: eip service_type: eip
title: API Reference title: API Reference
- html_location: docs/elb/umn - html_location: docs/elb/umn
pdf_name: elb-umn
rst_location: umn/source rst_location: umn/source
service_type: elb service_type: elb
title: User Guide title: User Guide
- html_location: docs/elb/api-ref - html_location: docs/elb/api-ref
pdf_name: elb-api-ref
rst_location: api-ref/source rst_location: api-ref/source
title: API Reference title: API Reference
type: api-ref service_type: elb
- html_location: docs/ed/umn - html_location: docs/ed/umn
pdf_name: edb-umn pdf_name: edb-umn
rst_location: umn/source rst_location: umn/source
@ -212,7 +214,7 @@ documents:
pdf_name: obs-dev-guide pdf_name: obs-dev-guide
rst_location: dev_guide/source rst_location: dev_guide/source
title: Developer Guide title: Developer Guide
type: tool-guide service_type: obs
- html_location: docs/plas/umn - html_location: docs/plas/umn
pdf_name: plas-umn pdf_name: plas-umn
rst_location: umn/source rst_location: umn/source
@ -569,6 +571,9 @@ service_categories:
- name: compute - name: compute
- name: container - name: container
- name: database - name: database
- name: network
- name: md
- name: security
services: services:
- repositories: - repositories:
- repo: docs/application-operations-management - repo: docs/application-operations-management
@ -773,7 +778,7 @@ services:
service_category: md service_category: md
service_title: Tag Management Service service_title: Tag Management Service
service_type: tms service_type: tms
- repository: - repositories:
- environment: internal - environment: internal
repo: docs/content-delivery-network repo: docs/content-delivery-network
type: gitea type: gitea
@ -865,7 +870,7 @@ services:
service_category: security service_category: security
service_title: Anti DDoS service_title: Anti DDoS
service_type: antiddos service_type: antiddos
- repositores: - repositories:
- environment: internal - environment: internal
repo: docs/key-management-service repo: docs/key-management-service
type: gitea type: gitea

View File

@ -95,3 +95,37 @@ class Services(object):
res_doc["repository"] = srv_env["repo"] res_doc["repository"] = srv_env["repo"]
res.append(res_doc) res.append(res_doc)
return res return res
def docs_html_by_category(self, environment):
"""Generate structure for doc-exports repository
"""
doc_struct = dict()
services = self.service_dict
for srv in self.all_services:
doc_struct.setdefault(srv["service_category"], [])
srv_res = dict(
service_title=srv['service_title'],
service_type=srv['service_type'],
docs=[]
)
if "repositories" in srv and environment:
for repo in srv["repositories"]:
if "environment" in repo and repo["environment"] == environment:
srv_res["repository"] = repo["repo"]
for doc in self.all_docs:
if (
"html_location" in doc
and doc["service_type"] == srv_res["service_type"]
):
doc_res = dict(
html_location=doc["html_location"],
rst_location=doc["rst_location"],
title=doc["title"],
pdf_name=doc["pdf_name"]
)
srv_res["docs"].append(doc_res)
if len(srv_res["docs"]) > 0:
doc_struct[srv["service_category"]].append(srv_res)
return dict(categories=doc_struct)

View File

@ -0,0 +1,21 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
from ruamel.yaml import YAML
import otc_metadata.services
def main():
data = otc_metadata.services.Services()
_yaml = YAML()
_yaml.indent(mapping=2, sequence=4, offset=2)
filepath = sys.stdout
sys.stdout.write('# Auto-generated by otc_metadata.generate_docexports.data\n')
_yaml.dump(data.docs_html_by_category('internal'), sys.stdout)
if __name__ == '__main__':
main()