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
2 changes: 1 addition & 1 deletion .github/workflows/docmaker-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
strategy:
matrix:
platform: [ubuntu-latest, windows-latest]
matlab-version: [R2022b, R2023b, R2024b, R2025b]
matlab-version: [R2022b, R2023b, R2024b, R2025b, R2026a]
runs-on: ${{ matrix.platform }}
continue-on-error: false
steps:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<Info/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<Info location="DocMakerTask.md" type="File"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<Info/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<Info location="tex-mml-chtml.js.rights" type="File"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<Info/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<Info location="tex-mml-chtml.js" type="File"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<Info/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<Info location="mathjax-config.js" type="File"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Info>
<Category UUID="FileClassCategory">
<Label UUID="design"/>
</Category>
</Info>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<Info location="mustBeTheme.m" type="File"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Info>
<Category UUID="FileClassCategory">
<Label UUID="design"/>
</Category>
</Info>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<Info location="superfolder.m" type="File"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Info>
<Category UUID="FileClassCategory">
<Label UUID="design"/>
</Category>
</Info>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<Info location="getDefaultFigureSize.m" type="File"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Info>
<Category UUID="FileClassCategory">
<Label UUID="design"/>
</Category>
</Info>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<Info location="docmakerroot.m" type="File"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Info>
<Category UUID="FileClassCategory">
<Label UUID="design"/>
</Category>
</Info>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<Info location="DocMakerTask.m" type="File"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Info>
<Category UUID="FileClassCategory">
<Label UUID="test"/>
</Category>
</Info>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<Info location="tDocMakerTask.m" type="File"/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<Info/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<Info location="LaTeXExample.md" type="File"/>
7 changes: 7 additions & 0 deletions tbx/docmaker/+docmaker/getDefaultFigureSize.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
function s = getDefaultFigureSize()
%getDefaultFigureSize Default figure size

p = get( 0, "DefaultFigurePosition" ); % [x y w h]
s = p(3:4); % [w h]

end % getDefaultFigureSize
10 changes: 10 additions & 0 deletions tbx/docmaker/+docmaker/mustBeTheme.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
function mustBeTheme( theme )
%mustBeTheme Validation function for optional named argument Theme

themes = ["none","light","dark","auto"];
assert( ( ischar( theme ) && ismember( theme, themes ) ) || ...
( isstring( theme ) && isscalar( theme ) && ismember( theme, themes ) ) || ...
( isa( theme, "matlab.graphics.theme.GraphicsTheme" ) && isscalar( theme ) ), ...
"Theme must be ""none"", ""light"", ""dark"", ""auto"", or a GraphicsTheme." )

end % mustBeTheme
44 changes: 44 additions & 0 deletions tbx/docmaker/+docmaker/superfolder.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
function s = superfolder( varargin )
%superfolder Common ancestor folder
%
% s = superfolder(p1,p2,...) returns the common ancestor of the folders
% p1, p2, ... The folders must exist. If there is no common ancestor
% then superfolder returns [].

% Copyright 2024-2026 The MathWorks, Inc.

% Check inputs
narginchk( 1, Inf )
dd = string( varargin );

% Canonicalize using dir
for ii = 1:numel( dd )
d = dd(ii);
assert( isfolder( d ), "docmaker:NotFound", "Folder ""%s"" not found.", d )
sd = dir( d );
dd(ii) = sd(1).folder; % first entry is "."
end

% Loop, split, compare
s = dd(1); % initialize
for ii = 2:numel( dd )
d = dd(ii);
ts = split( s, filesep ); % split
td = split( d, filesep ); % split
n = min( numel( ts ), numel( td ) ); % comparable length
tf = ts(1:n) == td(1:n); % compare
i = find( tf == false, 1, "first" ); % first non-match
if i == 1 % immediate non-match
s = [];
return
elseif isempty( i ) % full match
s = join( ts(1:n), filesep );
else % partial match
s = join( ts(1:i-1), filesep );
end
end

% Return matching datatype
if iscellstr( varargin ), s = char( s ); end %#ok<ISCLSTR>

end % superfolder
2 changes: 1 addition & 1 deletion tbx/docmaker/Contents.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
% MATLAB DocMaker
% Version 0.7 (R2025b) 07-Feb-2026
% Version 0.8 (R2026a) 28-May-2026
%
% docconvert - convert Markdown documents to HTML
% docrun - run MATLAB code in HTML documents and insert output
Expand Down
116 changes: 116 additions & 0 deletions tbx/docmaker/DocMakerTask.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
classdef DocMakerTask < matlab.buildtool.Task
%DOCMAKERTASK Generate toolbox documentation using DocMaker.
%
% See also docconvert, docrun, docindex

properties
% Documentation theme.
Theme(1, 1) string {mustBeMember( Theme, ...
["light", "dark", "auto"] )} = "auto"
% Stylesheets to include.
Stylesheets(1, :) string {mustBeFile}
% Scripts to include.
Scripts(1, :) string {mustBeFile}
% Root folder for publishing.
Root(1, :) string {mustBeFolder, mustBeScalarOrEmpty}
% LaTeX interpreter.
Interpreter(1, 1) string {mustBeMember( Interpreter, ...
["latex", "none"] )} = "none"
% Batching level.
Level(1, 1) double {mustBeInteger, ...
mustBeInRange( Level, 0, 7 )} = 0
% Figure theme.
FigureTheme {docmaker.mustBeTheme( FigureTheme )} = "none"
% Figure size.
FigureSize(1, 2) double {mustBePositive, mustBeReal} = ...
docmaker.getDefaultFigureSize()
end % properties

properties ( TaskInput )
% Documentation files in Markdown format.
MarkdownFiles(1, :) cell
end % properties ( TaskInput )

methods

function task = DocMakerTask( markdownFiles, namedArgs )
%DOCMAKERTASK Construct the DocMaker build task.

arguments ( Input, Repeating )
markdownFiles
end % arguments ( Input, Repeating )

arguments ( Input )
namedArgs.?DocMakerTask
end % arguments ( Input )

% Assign the markdown files.
task.MarkdownFiles = markdownFiles;

% Add the task metadata.
task.Description = ...
"Generate toolbox documentation using DocMaker";

% Assign any user-specified properties.
props = string( fieldnames( namedArgs ).' );
for prop = props
task.(prop) = namedArgs.(prop);
end % for

end % constructor

end % methods

methods ( TaskAction )

function buildDoc( task, ~ )
%BUILDDOC Build the toolbox documentation.
%
% * Convert Markdown documents to HTML
% * Run MATLAB code in HTML documents and insert output
% * Create info.xml and helptoc.xml from helptoc.md

% Prepare docconvert argument list.
convertArgs = {};
if ~isempty( task.Stylesheets )
convertArgs = {"Stylesheets", task.Stylesheets};
end % if

if ~isempty( task.Scripts )
convertArgs = [convertArgs, {"Scripts", task.Scripts}];
end % if

if ~isempty( task.Root )
convertArgs = [convertArgs, {"Root", task.Root}];
end % if

% Convert Markdown to HTML.
html = docconvert( task.MarkdownFiles{:}, ...
"Theme", task.Theme, ...
"Interpreter", task.Interpreter, ...
convertArgs{:} );
fprintf( 1, "** Converted Markdown doc to HTML\n" )

% Execute MATLAB code and insert output into the HTML.
docrun( html, ...
"Level", task.Level, ...
"Theme", task.FigureTheme, ...
"FigureSize", task.FigureSize )
fprintf( 1, "** Inserted MATLAB output into doc\n" )

% Build the documentation search index.
if ~isempty( task.Root )
docindex( task.Root )
else
sMd = docmaker.dir( task.MarkdownFiles{:} );
pMd = reshape( {sMd.folder}, size( sMd ) );
pRoot = docmaker.superfolder( pMd{:} );
docindex( pRoot )
end % if
fprintf( 1, "** Indexed doc\n" )

end % buildDoc

end % methods ( TaskAction )

end % classdef
Loading
Loading