add script for syncing docs
This commit is contained in:
		@ -1,3 +1,4 @@
 | 
				
			|||||||
 | 
					---
 | 
				
			||||||
documents:
 | 
					documents:
 | 
				
			||||||
  - html_location: docs/antiddos/api-ref
 | 
					  - html_location: docs/antiddos/api-ref
 | 
				
			||||||
    pdf_name: antiddos-api-ref
 | 
					    pdf_name: antiddos-api-ref
 | 
				
			||||||
@ -956,6 +957,9 @@ services:
 | 
				
			|||||||
      - repo: docs/elastic-cloud-server
 | 
					      - repo: docs/elastic-cloud-server
 | 
				
			||||||
        type: gitea
 | 
					        type: gitea
 | 
				
			||||||
        environment: internal
 | 
					        environment: internal
 | 
				
			||||||
 | 
					      - repo: opentelekomcloud-docs/elastic-cloud-server
 | 
				
			||||||
 | 
					        type: github
 | 
				
			||||||
 | 
					        environment: public
 | 
				
			||||||
    service_category: compute
 | 
					    service_category: compute
 | 
				
			||||||
    service_title: Elastic Cloud Server
 | 
					    service_title: Elastic Cloud Server
 | 
				
			||||||
    service_type: ecs
 | 
					    service_type: ecs
 | 
				
			||||||
@ -993,7 +997,8 @@ services:
 | 
				
			|||||||
        type: gitea
 | 
					        type: gitea
 | 
				
			||||||
        environment: internal
 | 
					        environment: internal
 | 
				
			||||||
    service_category: database
 | 
					    service_category: database
 | 
				
			||||||
    service_title: GaussDB Enterprise-class Distributed Database compatible with MySQL
 | 
					    service_title: |
 | 
				
			||||||
 | 
					      GaussDB Enterprise-class Distributed Database compatible with MySQL
 | 
				
			||||||
    service_type: gaussdb_mysql
 | 
					    service_type: gaussdb_mysql
 | 
				
			||||||
  - repositories:
 | 
					  - repositories:
 | 
				
			||||||
      - environment: internal
 | 
					      - environment: internal
 | 
				
			||||||
@ -1063,7 +1068,8 @@ services:
 | 
				
			|||||||
        repo: docs/gaussdb-opengauss
 | 
					        repo: docs/gaussdb-opengauss
 | 
				
			||||||
        type: gitea
 | 
					        type: gitea
 | 
				
			||||||
    service_category: database
 | 
					    service_category: database
 | 
				
			||||||
    service_title: GaussDB Enterprise-grade Relational Database on the openGauss ecosystem
 | 
					    service_title: |
 | 
				
			||||||
 | 
					      GaussDB Enterprise-grade Relational Database on the openGauss ecosystem
 | 
				
			||||||
    service_type: opengauss
 | 
					    service_type: opengauss
 | 
				
			||||||
  - repositories:
 | 
					  - repositories:
 | 
				
			||||||
      - environment: internal
 | 
					      - environment: internal
 | 
				
			||||||
 | 
				
			|||||||
@ -141,6 +141,17 @@ class Services(object):
 | 
				
			|||||||
                res.append(res_doc)
 | 
					                res.append(res_doc)
 | 
				
			||||||
        return res
 | 
					        return res
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def docs_by_service_type(self, service_type):
 | 
				
			||||||
 | 
					        """List documents of the service
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        :param str service_type: Service type
 | 
				
			||||||
 | 
					        :returns: generator for documents
 | 
				
			||||||
 | 
					        """
 | 
				
			||||||
 | 
					        for doc in self.all_docs:
 | 
				
			||||||
 | 
					            if doc["service_type"] != service_type:
 | 
				
			||||||
 | 
					                continue
 | 
				
			||||||
 | 
					            yield copy.deepcopy(doc)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def all_docs_full(self, environment):
 | 
					    def all_docs_full(self, environment):
 | 
				
			||||||
        """Return list or documents with full service data
 | 
					        """Return list or documents with full service data
 | 
				
			||||||
        """
 | 
					        """
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										2
									
								
								tools-requirements.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								tools-requirements.txt
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,2 @@
 | 
				
			|||||||
 | 
					GitPython
 | 
				
			||||||
 | 
					ruamel
 | 
				
			||||||
							
								
								
									
										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)
 | 
				
			||||||
@ -11,8 +11,6 @@ api_session = requests.Session()
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def open_issue(args, repository, issue_data):
 | 
					def open_issue(args, repository, issue_data):
 | 
				
			||||||
    #if issue_data['repository'] not in ['docs/elastic-cloud-server']:
 | 
					 | 
				
			||||||
    #    return
 | 
					 | 
				
			||||||
    req = dict(
 | 
					    req = dict(
 | 
				
			||||||
        title=issue_data["title"],
 | 
					        title=issue_data["title"],
 | 
				
			||||||
        body=issue_data["body"].replace("\\n", "\n")
 | 
					        body=issue_data["body"].replace("\\n", "\n")
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										192
									
								
								tools/sync_doc_repo.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										192
									
								
								tools/sync_doc_repo.py
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
		Reference in New Issue
	
	Block a user