Skip to content

Commit

Permalink
Update javadocs release cross-linking script
Browse files Browse the repository at this point in the history
  • Loading branch information
Carey-AWS committed Jul 13, 2021
1 parent 04daba8 commit 9930b7d
Showing 1 changed file with 15 additions and 20 deletions.
35 changes: 15 additions & 20 deletions scripts/doc_crosslinks/generate_cross_link_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
import codecs
import json
import re
# import requests
import pathlib
from pathlib import Path
from os import listdir
from os.path import isdir, exists, join
from re import split
Expand All @@ -14,22 +15,17 @@

def generateDocsMap(apiDefinitionsPath, apiDefinitionsRelativeFilePath):

filesInDir = [f for f in listdir(apiDefinitionsPath) if isdir(join(apiDefinitionsPath, f))]
for file in filesInDir :
serviceJsonFileName = join(apiDefinitionsPath, join(file, apiDefinitionsRelativeFilePath))

if(exists(serviceJsonFileName)) :
with codecs.open(serviceJsonFileName, 'rb', 'utf-8') as api_definition:
api_content = json.loads(api_definition.read())
if "uid" in api_content["metadata"].keys():
sdks[api_content["metadata"]["uid"]] = file
clientClass[api_content["metadata"]["uid"]] = getClientClassNameFromMetadata(api_content["metadata"])

# # Below code can be used for debugging failing clients
# str = "https://sdk.amazonaws.com/java/api/latest/software/amazon/awssdk/services/"+ file +"/"+getClientClassNameFromMetadata(api_content["metadata"])+".html"+"#validateTemplate--"
# ret = requests.head(str)
# if( ret.status_code != 200 ):
# print(str)
rootPath = pathlib.Path(r'./services')
for serviceModelPaths in rootPath.rglob('service-2.json'):
tokenizePath = str(Path(serviceModelPaths).parent).split("/")
getServiceName = tokenizePath[len(tokenizePath)-1]
if (getServiceName == "codegen-resources"):
getServiceName = str(serviceModelPaths).split("services/")[1].split("/src/main/resources")[0]
with codecs.open(serviceModelPaths, 'rb', 'utf-8') as apiDefinition:
apiContent = json.loads(apiDefinition.read())
if "uid" in apiContent["metadata"].keys():
sdks[apiContent["metadata"]["uid"]] = getServiceName
clientClass[apiContent["metadata"]["uid"]] = getClientClassNameFromMetadata(apiContent["metadata"])

return sdks

Expand Down Expand Up @@ -110,11 +106,10 @@ def Main():
argMap = {}
argMap[ "apiDefinitionsBasePath" ] = args[ "apiDefinitionsBasePath" ] or "./../services/"
argMap[ "apiDefinitionsRelativeFilePath" ] = args[ "apiDefinitionsRelativeFilePath" ] or "/src/main/resources/codegen-resources/service-2.json"
argMap[ "templateFilePath" ] = args[ "templateFilePath" ] or "./scripts/crosslink_redirect.html"
argMap[ "templateFilePath" ] = args[ "templateFilePath" ] or "./scripts/doc_crosslinks/crosslink_redirect.html"
argMap[ "outputFilePath" ] = args[ "outputFilePath" ] or "./crosslink_redirect.html"

insertDocsMapToRedirect(argMap["apiDefinitionsBasePath"], argMap["apiDefinitionsRelativeFilePath"], argMap["templateFilePath"], argMap["outputFilePath"])
print("Generated Cross link at " + argMap["outputFilePath"])

Main()

Main()

0 comments on commit 9930b7d

Please sign in to comment.