[CMake] Crawling documentation to find named argument keywords
Robert Dailey
rcdailey.lists at gmail.com
Mon Aug 17 08:51:14 EDT 2015
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?
-------------- next part --------------
# 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)
More information about the CMake
mailing list