Generate the documents for test cases and libraries.

- Use the phony to force execute the gendocs target (ignore directory
  exist).
- Use for loop to find all robot files and then create documents.

Change-Id: Ia5686a559b78dd506aca0b79f0bce0fba4b14c5a
diff --git a/Makefile b/Makefile
index 66626ce..60d61a5 100644
--- a/Makefile
+++ b/Makefile
@@ -30,6 +30,18 @@
 ROBOT_ONU_SN=-v BBSIM_ONU_SN:$(BBSIM_ONU_SN)
 endif
 
+.PHONY: gendocs
+
+## Variables for gendocs
+TEST_SOURCE := $(wildcard tests/*/*.robot)
+TEST_BASENAME := $(basename $(TEST_SOURCE))
+TEST_DIRS := $(dir $(TEST_SOURCE))
+
+LIB_SOURCE := $(wildcard libraries/*.robot)
+LIB_BASENAME := $(basename $(LIB_SOURCE))
+LIB_DIRS := $(dir $(LIB_SOURCE))
+
+
 sanity-kind: ROBOT_PORT_ARGS ?= -v ONOS_REST_PORT:8181 -v ONOS_SSH_PORT:8101
 sanity-kind: ROBOT_TEST_ARGS ?= --exclude notready --critical sanity
 sanity-kind: ROBOT_MISC_ARGS ?= -v num_onus:1
@@ -61,12 +73,19 @@
 	cd tests/sanity ;\
 	robot $(ROBOT_PORT_ARGS) $(ROBOT_TEST_ARGS) $(ROBOT_MISC_ARGS) $(ROBOT_OLT_SN) $(ROBOT_ONU_SN) sanity.robot
 
+
 gendocs: vst_venv
 	source ./vst_venv/bin/activate ;\
 	set -u ;\
-	mkdir -p gendocs ;\
-	python -m robot.libdoc --format HTML libraries/onos.robot gendocs/lib_onos_robot.html ;\
-	python -m robot.testdoc tests/Voltha_PODTests.robot gendocs/voltha_podtests.html
+	mkdir -p $@ ;\
+	for dir in ${LIB_DIRS}; do mkdir -p $@/$$dir; done;\
+	for dir in ${LIB_BASENAME}; do\
+		python -m robot.libdoc --format HTML $$dir.robot $@/$$dir.html ;\
+	done ;\
+	for dir in ${TEST_DIRS}; do mkdir -p $@/$$dir; done;\
+	for dir in ${TEST_BASENAME}; do\
+		python -m robot.testdoc $$dir.robot $@/$$dir.html ;\
+	done
 
 # explore use of --docformat REST - integration w/Sphinx?
 clean: