我正在寻找从Javascript和C#(原则上为任何语言)将文档生成一个数据集并从中生成网站的方法。我想以XML格式存储从JS / C#代码中提取的信息,并立即在(定制的)网站生成器中使用该信息,或将其存储以供以后使用/存档:
code comments in programming languages --> XML documents --> website
如果XML格式受模式限制并被接受为标准,则它们更有用,所以我的问题是;
是否有关于代码的XML文档的标准或DTD / XSD / RNG模式?
合适的XML格式应该能够描述代码概念,例如函数,类,类型常量(可以是原始类型或对另一个XML文档的引用),公共/私有/静态成员,参数和返回值值。拥有诸如手写的描述,示例,导入/依赖项/版本等之类的额外信息会很不错。
过去,我想出了以下示例来解决我的问题。它描述了一个带有两个参数的函数,其中第一个可以是字符串或字符串数组:
<type>
<name>askQuestionOnStackOverflow</name>
<source>src/help/askQuestionOnStackOverflow.js</source>
<restrict>
<type base="function" />
</restrict>
<description>
<paragraph>Ask a question on SO, and hope you're not embarressing yourself.</paragraph>
</description>
<arguments>
<type>
<name>question</name>
<restrict join='or'>
<type base='string' />
<type base='array'>
<restrict>
<type base='string' />
</restrict>
</type>
</restrict>
<description>
<paragraph>The question, or the questions you would like to ask</paragraph>
</description>
</type>
<type>
<name>user</name>
<restrict>
<type reference="../classes/User.xml" />
</restrict>
<description>
<paragraph>The user that asks the question</paragraph>
</description>
</type>
</arguments>
</type>
可能从中生成上述内容的Javascript源代码如下:
/**
* Ask a question on SO, and hope you're not embarressing yourself.
* @param {string|string[]} question The question, or the questions you would like to ask
* @param {User} user The user that asks the question
*/
function askQuestionOnStackOverflow (question, user) {
}