Skip to content

Commit 9733597

Browse files
committed
feat(API-1864): php-client-availability markdown: allow for using only 'versions' or 'editions' tag
API-1863
1 parent e3764d1 commit 9733597

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

tasks/build-doc.js

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -140,17 +140,22 @@ md.use(require('markdown-it-container'), 'php-client-availability', {
140140
return params.trim().match(/^php-client-availability(.*)$/);
141141
},
142142
render: function (tokens, idx) {
143-
var versionsAndEditions = tokens[idx].info.trim().match(/^php-client-availability\sversions=(.*)\seditions=(.*)$/);
144-
var html = '';
143+
let html = '';
145144
if(tokens[idx].nesting === 1) {
146-
var versions = versionsAndEditions[1].split(',');
147-
html += _.reduce(versions, function(res, version) {
148-
return res + ' <span class="label label-version">' + version + '</span>';
149-
}, '<p><em class="small text-primary">Available in the client versions:</em>');
150-
var editions = versionsAndEditions[2].split(',');
151-
html += _.reduce(editions, function(res, edition) {
152-
return res + ' <span class="label label-info">' + edition + '</span>';
153-
}, '<em class="small text-primary">&nbsp;&nbsp;|&nbsp;&nbsp;Available in the client editions:</em>');
145+
const matchedVersions = tokens[idx].info.trim().match(/^php-client-availability.*versions=(.*?)(\s|$)/);
146+
if (matchedVersions !== null) {
147+
const versions = matchedVersions[1].split(',');
148+
html += _.reduce(versions, function(res, version) {
149+
return res + ' <span class="label label-version">' + version + '</span>';
150+
}, '<p><em class="small text-primary">Available since PIM version:</em>');
151+
}
152+
const matchedEditions = tokens[idx].info.trim().match(/^php-client-availability.*editions=(.*?)(\s|$)/);
153+
if (matchedEditions !== null) {
154+
const editions = matchedEditions[1].split(',');
155+
html += _.reduce(editions, function(res, edition) {
156+
return res + ' <span class="label label-info">' + edition + '</span>';
157+
}, '<em class="small text-primary">&nbsp;&nbsp;|&nbsp;&nbsp;Available only in PIM edition:</em>');
158+
}
154159
} else {
155160
html = '</p>';
156161
}

0 commit comments

Comments
 (0)