mbed-os for GR-LYCHEE
Dependents: mbed-os-example-blinky-gr-lychee GR-Boads_Camera_sample GR-Boards_Audio_Recoder GR-Boads_Camera_DisplayApp ... more
tools/misc/docs_gen.py@0:f782d9c66c49, 2018-02-02 (annotated)
- Committer:
- dkato
- Date:
- Fri Feb 02 05:42:23 2018 +0000
- Revision:
- 0:f782d9c66c49
mbed-os for GR-LYCHEE
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dkato | 0:f782d9c66c49 | 1 | """An api for generating documentation from the codebase |
dkato | 0:f782d9c66c49 | 2 | """ |
dkato | 0:f782d9c66c49 | 3 | |
dkato | 0:f782d9c66c49 | 4 | from os.path import dirname, join |
dkato | 0:f782d9c66c49 | 5 | from os import sep |
dkato | 0:f782d9c66c49 | 6 | from re import compile |
dkato | 0:f782d9c66c49 | 7 | |
dkato | 0:f782d9c66c49 | 8 | import subprocess |
dkato | 0:f782d9c66c49 | 9 | |
dkato | 0:f782d9c66c49 | 10 | def generate_documentation(dirs, output_dir): |
dkato | 0:f782d9c66c49 | 11 | """Use doxygen to generate the documentation |
dkato | 0:f782d9c66c49 | 12 | |
dkato | 0:f782d9c66c49 | 13 | Positional arguments: |
dkato | 0:f782d9c66c49 | 14 | dirs - the directories that doxygen should scan for documentation |
dkato | 0:f782d9c66c49 | 15 | output_dir - location of the documentation after the return of this function |
dkato | 0:f782d9c66c49 | 16 | """ |
dkato | 0:f782d9c66c49 | 17 | print dirs |
dkato | 0:f782d9c66c49 | 18 | with open(join(dirname(__file__), "Doxyfile")) as doxyfile: |
dkato | 0:f782d9c66c49 | 19 | proc = subprocess.Popen(["doxygen", "-"], stdin=subprocess.PIPE) |
dkato | 0:f782d9c66c49 | 20 | proc.stdin.write(doxyfile.read()) |
dkato | 0:f782d9c66c49 | 21 | proc.stdin.write("OUTPUT_DIRECTORY={}\n".format(output_dir)) |
dkato | 0:f782d9c66c49 | 22 | proc.stdin.write("INPUT={}".format(" ".join(dirs))) |
dkato | 0:f782d9c66c49 | 23 | proc.stdin.close() |
dkato | 0:f782d9c66c49 | 24 | proc.wait() |
dkato | 0:f782d9c66c49 | 25 | |
dkato | 0:f782d9c66c49 | 26 | EXCLUDES = ["targets", "features/FEATURE", "features/mbedtls", |
dkato | 0:f782d9c66c49 | 27 | "features/nanostack", "features/storage"] |
dkato | 0:f782d9c66c49 | 28 | |
dkato | 0:f782d9c66c49 | 29 | def is_not_excluded(src): |
dkato | 0:f782d9c66c49 | 30 | return all(exclude not in src for exclude in EXCLUDES) |
dkato | 0:f782d9c66c49 | 31 | |
dkato | 0:f782d9c66c49 | 32 | if __name__ == "__main__": |
dkato | 0:f782d9c66c49 | 33 | import sys |
dkato | 0:f782d9c66c49 | 34 | from os.path import abspath, dirname, join |
dkato | 0:f782d9c66c49 | 35 | # Be sure that the tools directory is in the search path |
dkato | 0:f782d9c66c49 | 36 | ROOT = abspath(join(dirname(__file__), "..", "..")) |
dkato | 0:f782d9c66c49 | 37 | sys.path.insert(0, ROOT) |
dkato | 0:f782d9c66c49 | 38 | |
dkato | 0:f782d9c66c49 | 39 | from tools.toolchains.gcc import GCC_ARM |
dkato | 0:f782d9c66c49 | 40 | from tools.targets import TARGET_MAP |
dkato | 0:f782d9c66c49 | 41 | toolchain = GCC_ARM(TARGET_MAP["Super_Target"]) |
dkato | 0:f782d9c66c49 | 42 | resources = toolchain.scan_resources(".") |
dkato | 0:f782d9c66c49 | 43 | generate_documentation(filter(is_not_excluded, |
dkato | 0:f782d9c66c49 | 44 | sum(map(lambda x:x.headers, |
dkato | 0:f782d9c66c49 | 45 | resources.features.values()), |
dkato | 0:f782d9c66c49 | 46 | resources.headers)), |
dkato | 0:f782d9c66c49 | 47 | join(dirname(dirname(__file__)), "mbed-docs")) |