I've attached a python script I'm using to obtain a list of keywords across all CMake commands that I can use. Can someone let me know if this is a reliable way to craw the help documentation to find these keywords?
Note that the keywords I'm referring to are things like APPEND in the list() command, or PUBLIC and PRIVATE in the target_link_libraries() command. Each command has a set of all-upper-case keywords it uses to separate out arguments. I want a list of these keywords for all commands in one big list. I'm doing this to support syntax highlighting in a text editor. To use the script, first pipe out CMake's help to a file like this: $ cmake --help-full > help.txt Then run it through the python script attached: $ python-3.4 strip-options.py help.txt This should output to console the list of keywords. I feel like a lot are missing. I also got a lot of false positives. Can anyone suggest a better way to isolate true argument keywords in the help text?
# This script requires Python 3.x import re import sys matched_words = [] help_file = sys.argv[1] with open(help_file, 'r') as f: for line in f: if line.startswith(' ') or line.startswith('\t'): for match in re.finditer('[^\w\d]([A-Z]+)(?=[^\w\d])', line): matched_words.append(match.group(1)) for word in set(matched_words): if len(word) > 1: print(word)
-- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake