4
4
import codecs
5
5
import json
6
6
import re
7
- # import requests
7
+ import pathlib
8
+ from pathlib import Path
8
9
from os import listdir
9
10
from os .path import isdir , exists , join
10
11
from re import split
14
15
15
16
def generateDocsMap (apiDefinitionsPath , apiDefinitionsRelativeFilePath ):
16
17
17
- filesInDir = [f for f in listdir (apiDefinitionsPath ) if isdir (join (apiDefinitionsPath , f ))]
18
- for file in filesInDir :
19
- serviceJsonFileName = join (apiDefinitionsPath , join (file , apiDefinitionsRelativeFilePath ))
20
-
21
- if (exists (serviceJsonFileName )) :
22
- with codecs .open (serviceJsonFileName , 'rb' , 'utf-8' ) as api_definition :
23
- api_content = json .loads (api_definition .read ())
24
- if "uid" in api_content ["metadata" ].keys ():
25
- sdks [api_content ["metadata" ]["uid" ]] = file
26
- clientClass [api_content ["metadata" ]["uid" ]] = getClientClassNameFromMetadata (api_content ["metadata" ])
27
-
28
- # # Below code can be used for debugging failing clients
29
- # str = "https://sdk.amazonaws.com/java/api/latest/software/amazon/awssdk/services/"+ file +"/"+getClientClassNameFromMetadata(api_content["metadata"])+".html"+"#validateTemplate--"
30
- # ret = requests.head(str)
31
- # if( ret.status_code != 200 ):
32
- # print(str)
18
+ rootPath = pathlib .Path (r'./services' )
19
+ for serviceModelPaths in rootPath .rglob ('service-2.json' ):
20
+ tokenizePath = str (Path (serviceModelPaths ).parent ).split ("/" )
21
+ getServiceName = tokenizePath [len (tokenizePath )- 1 ]
22
+ if (getServiceName == "codegen-resources" ):
23
+ getServiceName = str (serviceModelPaths ).split ("services/" )[1 ].split ("/src/main/resources" )[0 ]
24
+ with codecs .open (serviceModelPaths , 'rb' , 'utf-8' ) as apiDefinition :
25
+ apiContent = json .loads (apiDefinition .read ())
26
+ if "uid" in apiContent ["metadata" ].keys ():
27
+ sdks [apiContent ["metadata" ]["uid" ]] = getServiceName
28
+ clientClass [apiContent ["metadata" ]["uid" ]] = getClientClassNameFromMetadata (apiContent ["metadata" ])
33
29
34
30
return sdks
35
31
@@ -110,11 +106,10 @@ def Main():
110
106
argMap = {}
111
107
argMap [ "apiDefinitionsBasePath" ] = args [ "apiDefinitionsBasePath" ] or "./../services/"
112
108
argMap [ "apiDefinitionsRelativeFilePath" ] = args [ "apiDefinitionsRelativeFilePath" ] or "/src/main/resources/codegen-resources/service-2.json"
113
- argMap [ "templateFilePath" ] = args [ "templateFilePath" ] or "./scripts/crosslink_redirect.html"
109
+ argMap [ "templateFilePath" ] = args [ "templateFilePath" ] or "./scripts/doc_crosslinks/ crosslink_redirect.html"
114
110
argMap [ "outputFilePath" ] = args [ "outputFilePath" ] or "./crosslink_redirect.html"
115
111
116
112
insertDocsMapToRedirect (argMap ["apiDefinitionsBasePath" ], argMap ["apiDefinitionsRelativeFilePath" ], argMap ["templateFilePath" ], argMap ["outputFilePath" ])
117
113
print ("Generated Cross link at " + argMap ["outputFilePath" ])
118
114
119
- Main ()
120
-
115
+ Main ()
0 commit comments