Allow to pass configuration values to templates

This commit is contained in:
Alexis BRENON 2018-01-10 11:29:33 +01:00
parent f91c3182cf
commit d635e18d36
1 changed files with 10 additions and 2 deletions

View File

@ -122,7 +122,9 @@ local file_types = {
------- ldoc external API ------------ ------- ldoc external API ------------
-- the ldoc table represents the API available in `config.ld`. -- the ldoc table represents the API available in `config.ld`.
local ldoc = { charset = 'UTF-8', version = version } local ldoc = { charset = 'UTF-8', version = version}
local config_values = {}
local known_types, kind_names = {} local known_types, kind_names = {}
@ -229,6 +231,10 @@ function ldoc.custom_see_handler(pat, handler)
doc.add_custom_see_handler(pat, handler) doc.add_custom_see_handler(pat, handler)
end end
function ldoc.add_config_value(name, value)
config_values[name] = value
end
local ldoc_contents = { local ldoc_contents = {
'alias','add_language_extension','custom_tags','new_type','add_section', 'tparam_alias', 'alias','add_language_extension','custom_tags','new_type','add_section', 'tparam_alias',
'file','project','title','package','format','output','dir','ext', 'topics', 'file','project','title','package','format','output','dir','ext', 'topics',
@ -241,7 +247,8 @@ local ldoc_contents = {
'dont_escape_underscore','global_lookup','prettify_files','convert_opt', 'user_keywords', 'dont_escape_underscore','global_lookup','prettify_files','convert_opt', 'user_keywords',
'postprocess_html', 'postprocess_html',
'custom_css','version', 'custom_css','version',
'no_args_infer' 'no_args_infer',
'add_config_value'
} }
ldoc_contents = tablex.makeset(ldoc_contents) ldoc_contents = tablex.makeset(ldoc_contents)
@ -810,6 +817,7 @@ ldoc.modules = module_list
ldoc.title = ldoc.title or args.title ldoc.title = ldoc.title or args.title
ldoc.project = ldoc.project or args.project ldoc.project = ldoc.project or args.project
ldoc.package = args.package:match '%a+' and args.package or nil ldoc.package = args.package:match '%a+' and args.package or nil
ldoc.config = config_values
local source_date_epoch = os.getenv("SOURCE_DATE_EPOCH") local source_date_epoch = os.getenv("SOURCE_DATE_EPOCH")
if args.testing then if args.testing then