ON Semiconductor / mbed-os

Dependents:   mbed-TFT-example-NCS36510 mbed-Accelerometer-example-NCS36510 mbed-Accelerometer-example-NCS36510

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers docs_gen.py Source File

docs_gen.py

00001 """An api for generating documentation from the codebase
00002 """
00003 
00004 from os.path import dirname, join
00005 from os import sep
00006 from re import compile
00007 
00008 import subprocess
00009 
00010 def generate_documentation (dirs, output_dir):
00011     """Use doxygen to generate the documentation
00012 
00013     Positional arguments:
00014     dirs - the directories that doxygen should scan for documentation
00015     output_dir - location of the documentation after the return of this function
00016     """
00017     print dirs
00018     with open(join(dirname(__file__), "Doxyfile")) as doxyfile:
00019         proc = subprocess.Popen(["doxygen", "-"], stdin=subprocess.PIPE)
00020         proc.stdin.write(doxyfile.read())
00021         proc.stdin.write("OUTPUT_DIRECTORY={}\n".format(output_dir))
00022         proc.stdin.write("INPUT={}".format(" ".join(dirs)))
00023         proc.stdin.close()
00024         proc.wait()
00025 
00026 EXCLUDES = ["targets", "features/FEATURE", "features/mbedtls",
00027            "features/nanostack", "features/storage"]
00028 
00029 def is_not_excluded(src):
00030     return all(exclude not in src for exclude in EXCLUDES)
00031 
00032 if __name__ == "__main__":
00033     import sys
00034     from os.path import abspath, dirname, join
00035     # Be sure that the tools directory is in the search path
00036     ROOT = abspath(join(dirname(__file__), "..", ".."))
00037     sys.path.insert(0, ROOT)
00038 
00039     from tools.toolchains.gcc import GCC_ARM
00040     from tools.targets import TARGET_MAP
00041     toolchain = GCC_ARM(TARGET_MAP["Super_Target"])
00042     resources = toolchain.scan_resources(".")
00043     generate_documentation(filter(is_not_excluded,
00044                                   sum(map(lambda x:x.headers,
00045                                           resources.features.values()),
00046                                       resources.headers)),
00047                            join(dirname(dirname(__file__)), "mbed-docs"))