module doc options prepend config instead of resetting it; fixes #114
This commit is contained in:
parent
bb526eae1b
commit
ea694c0bdd
27
update.py
27
update.py
@ -224,6 +224,21 @@ def gen_cmakelists(project_name, minimum_cmake_version, relative_path, modules):
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
|
||||
def prepend_or_set(config, section, option, value):
|
||||
"""
|
||||
If option is already set, then value is prepended.
|
||||
If option is not set, then it is created and set to value.
|
||||
This is used to prepend options with values which come from the module documentation.
|
||||
"""
|
||||
if value:
|
||||
if config.has_option(section, option):
|
||||
value += '\n%s' % config.get(section, option)
|
||||
config.set(section, option, value)
|
||||
return config
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
|
||||
def fetch_modules(config, relative_path):
|
||||
"""
|
||||
Assemble modules which will
|
||||
@ -272,14 +287,10 @@ def fetch_modules(config, relative_path):
|
||||
if parse_doc:
|
||||
with open(file_name, 'r') as f:
|
||||
config_docopt, config_define, config_export, config_fetch = parse_cmake_module(f.read())
|
||||
if config_docopt:
|
||||
config.set(section, 'docopt', config_docopt)
|
||||
if config_define:
|
||||
config.set(section, 'define', config_define)
|
||||
if config_export:
|
||||
config.set(section, 'export', config_export)
|
||||
if config_fetch:
|
||||
config.set(section, 'fetch', config_fetch)
|
||||
config = prepend_or_set(config, section, 'docopt', config_docopt)
|
||||
config = prepend_or_set(config, section, 'define', config_define)
|
||||
config = prepend_or_set(config, section, 'export', config_export)
|
||||
config = prepend_or_set(config, section, 'fetch', config_fetch)
|
||||
modules.append(Module(path=path, name=name))
|
||||
i += 1
|
||||
print_progress_bar(
|
||||
|
Loading…
x
Reference in New Issue
Block a user