Skip to content

Commit 801efa5

Browse files
committed
publish: index in separate function
1 parent 3a351a1 commit 801efa5

File tree

2 files changed

+25
-22
lines changed

2 files changed

+25
-22
lines changed

private/index_html.m

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
function [head, body] = index_html(styleName, pkg_name, tagline, git_txt, project_url)
2+
3+
head = ["<!DOCTYPE html>", ...
4+
'<head lang="en">',...
5+
'<meta charset="UTF-8">', ...
6+
'<meta name="color-scheme" content="dark light">', ...
7+
'<meta name="viewport" content="width=device-width, initial-scale=1">', ...
8+
sprintf('<meta name="generator" content="Matlab %s">', matlabRelease().Release), ...
9+
sprintf('<link rel="stylesheet" href="%s">', styleName), ...
10+
"<title>" + pkg_name + " API</title>", ...
11+
"</head>"];
12+
13+
body = [
14+
"<body>", ...
15+
sprintf('<h1>%s API</h1>', pkg_name), ...
16+
sprintf('<p>%s</p>', tagline), ...
17+
sprintf('<p>%s</p>', git_txt)];
18+
19+
body = [body, ...
20+
'<p id="userAgent"></p>', ...
21+
'<script>document.getElementById("userAgent").textContent = navigator.userAgent;</script>', ...
22+
"<p>Project URL: <a href=" + project_url + ">" + project_url + "</a></p>", ...
23+
"<h2>API Reference</h2>"];
24+
end

private/publish_gen_index_html.m

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -38,28 +38,7 @@
3838

3939
[~, n, s] = fileparts(styleFile);
4040
styleName = strcat(n, s);
41-
42-
head = ["<!DOCTYPE html>", ...
43-
'<head lang="en">',...
44-
'<meta charset="UTF-8">', ...
45-
'<meta name="color-scheme" content="dark light">', ...
46-
'<meta name="viewport" content="width=device-width, initial-scale=1">', ...
47-
sprintf('<meta name="generator" content="Matlab %s">', matlabRelease().Release), ...
48-
sprintf('<link rel="stylesheet" href="%s">', styleName), ...
49-
"<title>" + pkg_name + " API</title>", ...
50-
"</head>"];
51-
52-
body = [
53-
"<body>", ...
54-
sprintf('<h1>%s API</h1>', pkg_name), ...
55-
sprintf('<p>%s</p>', tagline), ...
56-
sprintf('<p>%s</p>', git_txt)];
57-
58-
body = [body, ...
59-
'<p id="userAgent"></p>', ...
60-
'<script>document.getElementById("userAgent").textContent = navigator.userAgent;</script>', ...
61-
"<p>Project URL: <a href=" + project_url + ">" + project_url + "</a></p>", ...
62-
"<h2>API Reference</h2>"];
41+
[head, body] = index_html(styleName, pkg_name, tagline, git_txt, project_url);
6342

6443
fid = fopen(readme, 'w');
6544
fprintf(fid, join([head, body], newline));

0 commit comments

Comments
 (0)