Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions matlab/src/matlab/+arrow/+internal/+display/makeLinkString.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
%MAKELINKSTRING Creates a hyperlink string if possible.

% Licensed to the Apache Software Foundation (ASF) under one or more
% contributor license agreements. See the NOTICE file distributed with
% this work for additional information regarding copyright ownership.
% The ASF licenses this file to you under the Apache License, Version
% 2.0 (the "License"); you may not use this file except in compliance
% with the License. You may obtain a copy of the License at
%
% http://www.apache.org/licenses/LICENSE-2.0
%
% Unless required by applicable law or agreed to in writing, software
% distributed under the License is distributed on an "AS IS" BASIS,
% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
% implied. See the License for the specific language governing
% permissions and limitations under the License.

function link = makeLinkString(opts)
arguments
opts.HelpTarget(1, 1) string {mustBeNonzeroLengthText}
opts.Text(1, 1) string {mustBeNonzeroLengthText}
% When displaying heterogeneous arrays, only the name of the
% closest shared ancestor class is displayed in bold. All other
% class names are not bolded.
opts.BoldFont(1, 1) logical = false
end

if usejava("desktop")
if opts.BoldFont
link = compose("<a href=""matlab:helpPopup('%s')""" + ...
" style=""font-weight:bold"">%s</a>", ...
opts.HelpTarget, opts.Text);
else
link = compose("<a href=""matlab:helpPopup('%s')"">%s</a>", ...
opts.HelpTarget, opts.Text);
end
else
link = opts.Text;
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,8 @@
opts.BoldFont(1, 1) logical
end

if opts.BoldFont
link = compose("<a href=""matlab:helpPopup('%s')""" + ...
" style=""font-weight:bold"">%s</a>", ...
opts.FullClassName, opts.ClassName);
else
link = compose("<a href=""matlab:helpPopup('%s')"">%s</a>", ...
opts.FullClassName, opts.ClassName);
end
link = arrow.internal.display.makeLinkString( ...
HelpTarget=opts.FullClassName, ...
Text=opts.ClassName, ...
BoldFont=opts.BoldFont);
end
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,12 @@
idx = strlength(names) == 0;
names(idx) = "<empty>";

if usejava("desktop")
% When in desktop mode, the Command Window can interpret HTML tags
% to display bold font and hyperlinks.
names = compose("<strong>%s</strong>", names);
classNames = arrayfun(@(type) string(class(type)), types);

% Creates a string array with the following form:
%
% ["arrow.type.BooleanType" "Boolean" "arrow.type.StringType" "String" ...]
%
% This string array is passed to the compose call below. The
% format specifier operator supplied to compose contains two
% formatting operators (%s), so compose uses two elements from the
% string array (classNameAndIDs) at a time.
classNameAndIDs = strings([1 numel(typeIDs) * 2]);
classNameAndIDs(1:2:end-1) = classNames;
classNameAndIDs(2:2:end) = typeIDs;
typeIDs = compose("<a href=""matlab:helpPopup('%s')"" style=""font-weight:bold"">%s</a>", classNameAndIDs);
end
% When in desktop mode, the Command Window can interpret HTML tags
% to display bold font and hyperlinks.
names = arrayfun(@arrow.internal.display.boldFontIfPossible, names);
classNames = arrayfun(@(type) string(class(type)), types);
typeIDs = arrayfun(@(className, typeID) arrow.internal.display.makeLinkString( ...
HelpTarget=className, Text=typeID, BoldFont=true), classNames, typeIDs);

text = names + ": " + typeIDs;
text = strjoin(text, " | ");
Expand Down