diff --git a/modules/matlab/generator/filters.py b/modules/matlab/generator/filters.py index 9ef7dcc6bc..d8b2d9541f 100644 --- a/modules/matlab/generator/filters.py +++ b/modules/matlab/generator/filters.py @@ -1,6 +1,6 @@ from textwrap import TextWrapper from string import split, join -import re +import re, os def inputs(args): '''Keeps only the input arguments in a list of elements. @@ -92,6 +92,12 @@ def stripTags(text): def qualify(text, name): return re.sub(name.upper(), 'CV.'+name.upper(), text) + +def slugify(text): + return text.lower().replace('_', '-') + +def filename(fullpath): + return os.path.splitext(os.path.basename(fullpath))[0] def comment(text, wrap=80, escape='% ', escape_first='', escape_last=''): '''comment filter diff --git a/modules/matlab/generator/gen_matlab.py b/modules/matlab/generator/gen_matlab.py index 6abaa5d620..3cc1829020 100644 --- a/modules/matlab/generator/gen_matlab.py +++ b/modules/matlab/generator/gen_matlab.py @@ -46,12 +46,14 @@ class MatlabWrapperGenerator(object): jtemplate.filters['toLowerCamelCase'] = toLowerCamelCase jtemplate.filters['toUnderCase'] = toUnderCase jtemplate.filters['stripTags'] = stripTags + jtemplate.filters['filename'] = filename jtemplate.filters['comment'] = comment jtemplate.filters['inputs'] = inputs jtemplate.filters['ninputs'] = ninputs jtemplate.filters['outputs'] = outputs jtemplate.filters['noutputs'] = noutputs jtemplate.filters['qualify'] = qualify + jtemplate.filters['slugify'] = slugify jtemplate.filters['only'] = only jtemplate.filters['void'] = void jtemplate.filters['not'] = flip diff --git a/modules/matlab/generator/templates/template_doc_base.m b/modules/matlab/generator/templates/template_doc_base.m index 6b25c67320..8cb21b7f72 100644 --- a/modules/matlab/generator/templates/template_doc_base.m +++ b/modules/matlab/generator/templates/template_doc_base.m @@ -52,6 +52,7 @@ cv.{{ item }}{% if not loop.last %}, {% endif %} % {% endif %} -% Official documentation: http://docs.opencv.org +{% set url = 'http://docs.opencv.org/modules/' + doc.module + '/doc/' + (doc.file|filename) + '.html#' + (fun.name|slugify) %} +% Online docs: {{url}} % Copyright {{ time.strftime("%Y", time.localtime()) }} The OpenCV Foundation %