将 doxygen 样式注释转换为 HTML 的 Javascript 片段
-
12-09-2019 - |
题
和---关联 这个问题, ,我想知道是否有人知道将单个 doxygen 注释转换为 HTML 的 javascript 代码片段/库?
例如,
/** This is a comment block
*
* \b bold text
* \i italic text
*/
会被转换为类似的东西:
<p>This is a comment block</p>
<p><b>bold</b> text</p>
<p><i>italic</i> text</p>
与 doxygen 的所有其他格式相关的标签类似。
我发现了 这 已经,如果我必须自己实现它,这似乎是一个很好的起点,但可能我错过了一个完整的项目:-)
所以,欢迎提出建议!
其他提示
function commentToTag(comment) {
var header = null;
var commentHtml = '';
comment.split('\n').forEach(function (i) {
var array = i.split(' ');
do {
var index = array.indexOf('');
if (index !== -1) array.splice(index, 1);
index = array.indexOf('');
} while (index !== -1);
do {
var index = array.indexOf('*');
if (index !== -1) array.splice(index, 1);
index = array.indexOf('*');
} while (index !== -1);
do {
var index = array.indexOf('/**');
if (index !== -1) array.splice(index, 3);
index = array.indexOf('/**');
} while (index !== -1);
do {
var index = array.indexOf('*/');
if (index !== -1) array.splice(index, 2);
index = array.indexOf('*/');
} while (index !== -1);
if (array.length === 0) return;
if (header === null) {
header = "<p>" + array.join(' ') + "</p>\n";
return;
}
const tag = array.splice(0, 1);
commentHtml += "<p><"+tag + ">"+array.splice(0,1)+"</" +tag+ ">" + array.join(' ') + '</p>\n';
});
return header + commentHtml;
}
var comment = `/** This is a comment block
*
* \i bold text
* \i italic text
*/`;
console.log(commentToTag(comment));
不隶属于 StackOverflow