the other jimmy / mbed-sdk-tools

Fork of mbed-sdk-tools by mbed official

Committer:
The Other Jimmy
Date:
Wed Jan 04 11:58:24 2017 -0600
Revision:
32:8ea194f6145b
Update tools to follow mbed-os tools release 5.3.1

Who changed what in which revision?

UserRevisionLine numberNew contents of line
The Other Jimmy 32:8ea194f6145b 1 """An api for generating documentation from the codebase
The Other Jimmy 32:8ea194f6145b 2 """
The Other Jimmy 32:8ea194f6145b 3
The Other Jimmy 32:8ea194f6145b 4 from os.path import dirname, join
The Other Jimmy 32:8ea194f6145b 5 from os import sep
The Other Jimmy 32:8ea194f6145b 6 from re import compile
The Other Jimmy 32:8ea194f6145b 7
The Other Jimmy 32:8ea194f6145b 8 import subprocess
The Other Jimmy 32:8ea194f6145b 9
The Other Jimmy 32:8ea194f6145b 10 def generate_documentation(dirs, output_dir):
The Other Jimmy 32:8ea194f6145b 11 """Use doxygen to generate the documentation
The Other Jimmy 32:8ea194f6145b 12
The Other Jimmy 32:8ea194f6145b 13 Positional arguments:
The Other Jimmy 32:8ea194f6145b 14 dirs - the directories that doxygen should scan for documentation
The Other Jimmy 32:8ea194f6145b 15 output_dir - location of the documentation after the return of this function
The Other Jimmy 32:8ea194f6145b 16 """
The Other Jimmy 32:8ea194f6145b 17 print dirs
The Other Jimmy 32:8ea194f6145b 18 with open(join(dirname(__file__), "Doxyfile")) as doxyfile:
The Other Jimmy 32:8ea194f6145b 19 proc = subprocess.Popen(["doxygen", "-"], stdin=subprocess.PIPE)
The Other Jimmy 32:8ea194f6145b 20 proc.stdin.write(doxyfile.read())
The Other Jimmy 32:8ea194f6145b 21 proc.stdin.write("OUTPUT_DIRECTORY={}\n".format(output_dir))
The Other Jimmy 32:8ea194f6145b 22 proc.stdin.write("INPUT={}".format(" ".join(dirs)))
The Other Jimmy 32:8ea194f6145b 23 proc.stdin.close()
The Other Jimmy 32:8ea194f6145b 24 proc.wait()
The Other Jimmy 32:8ea194f6145b 25
The Other Jimmy 32:8ea194f6145b 26 EXCLUDES = ["targets", "features/FEATURE", "features/mbedtls",
The Other Jimmy 32:8ea194f6145b 27 "features/nanostack", "features/storage"]
The Other Jimmy 32:8ea194f6145b 28
The Other Jimmy 32:8ea194f6145b 29 def is_not_excluded(src):
The Other Jimmy 32:8ea194f6145b 30 return all(exclude not in src for exclude in EXCLUDES)
The Other Jimmy 32:8ea194f6145b 31
The Other Jimmy 32:8ea194f6145b 32 if __name__ == "__main__":
The Other Jimmy 32:8ea194f6145b 33 import sys
The Other Jimmy 32:8ea194f6145b 34 from os.path import abspath, dirname, join
The Other Jimmy 32:8ea194f6145b 35 # Be sure that the tools directory is in the search path
The Other Jimmy 32:8ea194f6145b 36 ROOT = abspath(join(dirname(__file__), "..", ".."))
The Other Jimmy 32:8ea194f6145b 37 sys.path.insert(0, ROOT)
The Other Jimmy 32:8ea194f6145b 38
The Other Jimmy 32:8ea194f6145b 39 from tools.toolchains.gcc import GCC_ARM
The Other Jimmy 32:8ea194f6145b 40 from tools.targets import TARGET_MAP
The Other Jimmy 32:8ea194f6145b 41 toolchain = GCC_ARM(TARGET_MAP["Super_Target"])
The Other Jimmy 32:8ea194f6145b 42 resources = toolchain.scan_resources(".")
The Other Jimmy 32:8ea194f6145b 43 generate_documentation(filter(is_not_excluded,
The Other Jimmy 32:8ea194f6145b 44 sum(map(lambda x:x.headers,
The Other Jimmy 32:8ea194f6145b 45 resources.features.values()),
The Other Jimmy 32:8ea194f6145b 46 resources.headers)),
The Other Jimmy 32:8ea194f6145b 47 join(dirname(dirname(__file__)), "mbed-docs"))