Commit 3bf41c28 authored by hbristow's avatar hbristow

Formatted URLs in the documentation so that they are redirected to the system…

Formatted URLs in the documentation so that they are redirected to the system browser instead of the builtin Matlab browser
parent fad7b35b
from textwrap import TextWrapper from textwrap import TextWrapper
from string import split, join from string import split, join
import re, os import re, os
urlexpr = re.compile(r"((https?):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)", re.MULTILINE|re.UNICODE)
def inputs(args): def inputs(args):
'''Keeps only the input arguments in a list of elements. '''Keeps only the input arguments in a list of elements.
...@@ -58,7 +59,6 @@ def binaryToDecimal(string): ...@@ -58,7 +59,6 @@ def binaryToDecimal(string):
return string return string
def formatMatlabConstant(string, table): def formatMatlabConstant(string, table):
import re
# split the string into expressions # split the string into expressions
words = re.split('(\W+)', string) words = re.split('(\W+)', string)
# add a 'cv' prefix if an expression is also a key in the lookup table # add a 'cv' prefix if an expression is also a key in the lookup table
...@@ -70,6 +70,11 @@ def formatMatlabConstant(string, table): ...@@ -70,6 +70,11 @@ def formatMatlabConstant(string, table):
words = 'bitshift('+shift[0]+', '+shift[1]+')' if len(shift) == 2 else words words = 'bitshift('+shift[0]+', '+shift[1]+')' if len(shift) == 2 else words
return words return words
def matlabURL(string):
"""This filter is used to construct a Matlab specific URL that calls the
system browser instead of the (insanely bad) builtin Matlab browser"""
return re.sub(urlexpr, '<a href="matlab: web(\'\\1\', \'-browser\')">\\1</a>', string)
def capitalizeFirst(text): def capitalizeFirst(text):
return text[0].upper() + text[1:] return text[0].upper() + text[1:]
......
...@@ -45,6 +45,7 @@ class MatlabWrapperGenerator(object): ...@@ -45,6 +45,7 @@ class MatlabWrapperGenerator(object):
jtemplate.filters['toUpperCamelCase'] = toUpperCamelCase jtemplate.filters['toUpperCamelCase'] = toUpperCamelCase
jtemplate.filters['toLowerCamelCase'] = toLowerCamelCase jtemplate.filters['toLowerCamelCase'] = toLowerCamelCase
jtemplate.filters['toUnderCase'] = toUnderCase jtemplate.filters['toUnderCase'] = toUnderCase
jtemplate.filters['matlabURL'] = matlabURL
jtemplate.filters['stripTags'] = stripTags jtemplate.filters['stripTags'] = stripTags
jtemplate.filters['filename'] = filename jtemplate.filters['filename'] = filename
jtemplate.filters['comment'] = comment jtemplate.filters['comment'] = comment
......
{% import 'functional.cpp' as functional %} {% import 'functional.cpp' as functional %}
{{ ('CV.' + fun.name | upper + ' ' + doc.brief | stripTags) | comment(75, '%') }} {{ ('CV.' + fun.name | upper + ' ' + doc.brief | stripTags) | comment(75, '%') | matlabURL }}
% %
% {{ functional.composeMatlab(fun) | upper }} % {{ functional.composeMatlab(fun) | upper }}
{% if doc.long %} {% if doc.long %}
{{ doc.long | stripTags | qualify(fun.name) | comment(75, '% ') }} {{ doc.long | stripTags | qualify(fun.name) | comment(75, '% ') | matlabURL }}
{% endif %} {% endif %}
% %
{# ----------------------- Returns --------------------- #} {# ----------------------- Returns --------------------- #}
...@@ -57,6 +57,6 @@ cv.{{ item }}{% if not loop.last %}, {% endif %} ...@@ -57,6 +57,6 @@ cv.{{ item }}{% if not loop.last %}, {% endif %}
{% endif %} {% endif %}
{# ----------------------- Online ---------------------- #} {# ----------------------- Online ---------------------- #}
{% set url = 'http://docs.opencv.org/modules/' + doc.module + '/doc/' + (doc.file|filename) + '.html#' + (fun.name|slugify) %} {% set url = 'http://docs.opencv.org/modules/' + doc.module + '/doc/' + (doc.file|filename) + '.html#' + (fun.name|slugify) %}
% Online docs: <a href="matlab: web('{{url}}', '-browser')">{{url}}</a> % Online docs: {{ url | matlabURL }}
% Copyright {{ time.strftime("%Y", time.localtime()) }} The OpenCV Foundation % Copyright {{ time.strftime("%Y", time.localtime()) }} The OpenCV Foundation
% %
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment