2 Robot testdoc and testlib generator
3 Authors: Kailash Khalasi (kkhalasi@iix.net)
5 This script will issue a command to all the robot suites and libraries in the given directories
6 to generate documentation using Robot's "testdoc" and "libdoc" tool.
7 ex usage: python create_docs.py suitelocation librarylocation suitedocoutputlocation libdocoutputlocation
9 suitelocation:$HOME/integration/test/csit/suites
10 librarylocation:$HOME/integration/test/csit/libraries
11 suitedocoutputlocation:/tmp/RobotDocs
12 libdocoutputlocation: /tmp/RobotLibs
21 suiteRoot = os.getenv("HOME")+'/integration/test/csit/suites'
22 libraryRoot = os.getenv("HOME")+'/integration/test/csit/libraries'
23 tmpSuite = '/tmp/RobotDocs/'
24 tmpLib = '/tmp/RobotLibs/'
25 print "All arguments are not passed....Using default arguments:"
26 print 'Suite Location: ' + suiteRoot
27 print 'Library Location: ' + libraryRoot
28 print 'Suite Doc Output Location: ' + tmpSuite
29 print 'Library Doc Output Location: ' + tmpLib
31 script, suiteRoot, libraryRoot, tmpSuite, tmpLib = argv
34 def generate_docs(testDir, outputFolder, debug=False):
36 Generate Robot Documentation
39 testDir: The directory in which your robot files live (can be suites or libraries)
40 outputFolder: The directory where you want your generated docs to be placed.
42 This function will "walk" through each robot file in the given "suitelocation"
43 and "librarylocation" and will issue a python -m robot.testdoc|libdoc on each
44 of those files. The script will first determine if you've passed in a robot
45 suite location or robot library location. The outcome generates an HTML file
46 (our expected documents) to the given "suitedocoutputlocation"|"libdocoutputlocation".
48 :param debug: Default is false. Setting debug to true will print the output of each
49 command entered to generate a robot doc
52 if testDir == suiteRoot:
53 docFunction = robot.testdoc.testdoc
55 docFunction = robot.libdoc.libdoc
57 for root, dirs, files, in os.walk(testDir):
59 if file.endswith(".robot"):
60 inputFile = os.path.join(root, file)
61 outputFile = os.path.join(outputFolder, file + ".html")
62 docFunction(inputFile, outputFile)
64 tmpDirs = [tmpSuite, tmpLib]
66 if not os.path.exists(dirs):
69 generate_docs(suiteRoot, tmpSuite)
70 generate_docs(libraryRoot, tmpLib)