Created
September 7, 2023 12:05
-
-
Save Fatpandac/4a591c366418a6f7ff33f59e5188ebce to your computer and use it in GitHub Desktop.
Rap2JSDoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
def load_data(filePath): | |
f = open(filePath) | |
data = json.load(f) | |
return data | |
def generateJSDoc(actionList): | |
jsdoc = list() | |
jsdoc.append("\\**") | |
jsdoc.append(f" * {actionList['name']}") | |
jsdoc.append(" * @param {object} params - 请求参数") | |
requestParameterList = actionList['requestParameterList'] | |
if requestParameterList: | |
for params in requestParameterList: | |
jsdoc.append(f" * @param {'{'}{params['dataType']}{'}'} params.{params['identifier']} - {params['name']}") | |
jsdoc.append(" *\\") | |
return "\n".join(jsdoc) | |
def main(): | |
projectData = load_data('/Users/fatpandac/Downloads/a.json')['projectData'] | |
moduleList = projectData['moduleList'] | |
for module in moduleList: | |
print(f"============={module['name']}=============") | |
for pageList in module["pageList"]: | |
for actionList in pageList['actionList']: | |
generatedJSDoc = generateJSDoc(actionList) | |
if (generatedJSDoc): | |
print(generatedJSDoc) | |
print() | |
if __name__ == "__main__": | |
main() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment