Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/botocore/docs/__init__.py: 31%

13 statements  

« prev     ^ index     » next       coverage.py v7.3.2, created at 2023-12-08 06:51 +0000

1# Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. 

2# 

3# Licensed under the Apache License, Version 2.0 (the "License"). You 

4# may not use this file except in compliance with the License. A copy of 

5# the License is located at 

6# 

7# http://aws.amazon.com/apache2.0/ 

8# 

9# or in the "license" file accompanying this file. This file is 

10# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 

11# ANY KIND, either express or implied. See the License for the specific 

12# language governing permissions and limitations under the License. 

13import os 

14 

15from botocore.docs.service import ServiceDocumenter 

16 

17DEPRECATED_SERVICE_NAMES = {'sms-voice'} 

18 

19 

20def generate_docs(root_dir, session): 

21 """Generates the reference documentation for botocore 

22 

23 This will go through every available AWS service and output ReSTructured 

24 text files documenting each service. 

25 

26 :param root_dir: The directory to write the reference files to. Each 

27 service's reference documentation is loacated at 

28 root_dir/reference/services/service-name.rst 

29 """ 

30 # Create the root directory where all service docs live. 

31 services_dir_path = os.path.join(root_dir, 'reference', 'services') 

32 if not os.path.exists(services_dir_path): 

33 os.makedirs(services_dir_path) 

34 

35 # Prevents deprecated service names from being generated in docs. 

36 available_services = [ 

37 service 

38 for service in session.get_available_services() 

39 if service not in DEPRECATED_SERVICE_NAMES 

40 ] 

41 

42 # Generate reference docs and write them out. 

43 for service_name in available_services: 

44 docs = ServiceDocumenter( 

45 service_name, session, services_dir_path 

46 ).document_service() 

47 

48 # Write the main service documentation page. 

49 # Path: <root>/reference/services/<service>/index.rst 

50 service_file_path = os.path.join( 

51 services_dir_path, f'{service_name}.rst' 

52 ) 

53 with open(service_file_path, 'wb') as f: 

54 f.write(docs)