【问题标题】:Docfx custom triple slash tagDocfx 自定义三重斜线标签
【发布时间】:2022-12-15 05:34:36
【问题描述】:

我想指定将添加到生成的 .yml 文件的自定义 /// 标记(例如 EcsComponent)。然后为标记的类呈现一些附加信息(链接到外部站点)。有什么办法吗?我看到了一些用于处理 .yml 文件的插件示例,但没有关于元数据生成插件的信息。

【问题讨论】:

    标签: docfx


    【解决方案1】:

    【讨论】:

      【解决方案2】:

      您可以为此使用 preprocessor 和自定义模板。

      templates/yourTemplate/ManagedReference.extension.js 中的函数看起来像这样

      exports.postTransform = function (model) {
      
        transformModel(model);
      
        return model;
      }
      
      function transformModel(child) {
          if(child.children !== undefined) {
      
          for (let i = 0; i < child.children.length; i++) { //iterate through every child of the model (if you want to go troughg methods, properties, etc..
      
            transformModel(child.children[i]);
      
            for (let j = 0; j < fields.length; j++)
            {
              if (child.children[i].summary && child.children[i].summary.indexOf("<"+ TAG_NAME + ">") !== -1) {
                
                  child.children[i]["FIELD_NAME"] = "VALUE"; //value will be set into the model
              }
            }
          }
      }
      

      然后你可以像这样在 templates/yourTemplate/partials/class.tmpl.partial 中渲染它,例如:

      ...
      <h5 class="decalaration">{{__global.declaration}}</h5>
      ...
      {{FIELD_NAME}}
      ...
      

      不要忘记将模板添加到docfx.json

      "template": [
            "default",
            "templates/yourTemplate"
          ],
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-09-20
        • 2021-04-14
        • 2015-05-03
        • 2016-01-07
        相关资源
        最近更新 更多