add script for syncing docs
This commit is contained in:
27
tools/convert_data.py
Normal file
27
tools/convert_data.py
Normal file
@ -0,0 +1,27 @@
|
||||
import copy
|
||||
|
||||
import otc_metadata.services
|
||||
from ruamel.yaml import YAML
|
||||
|
||||
data = otc_metadata.services.Services()
|
||||
new_data = data._service_data
|
||||
|
||||
services = data.service_dict
|
||||
|
||||
for doc in new_data["documents"]:
|
||||
service = services.get(doc["service_type"])
|
||||
if not service:
|
||||
continue
|
||||
service_link = service["repositories"][0]["repo"].split('/')[1]
|
||||
if doc["rst_location"].find("api-ref") >= 0:
|
||||
doc["rst_location"] = "api-ref/source"
|
||||
elif doc["rst_location"].find("umn") >= 0:
|
||||
doc["rst_location"] = "umn/source"
|
||||
doc["type"] = "umn"
|
||||
elif doc["rst_location"].find("dev") >= 0:
|
||||
doc["rst_location"] = "dev_guide/source"
|
||||
|
||||
_yaml = YAML()
|
||||
_yaml.indent(mapping=2, sequence=4, offset=2)
|
||||
with open('new.yaml', 'w') as fd:
|
||||
_yaml.dump(new_data, fd)
|
Reference in New Issue
Block a user