使用docfx生成API文档【生成c#帮助文档】

使用docfx生成API文档

docfx

https://dotnet.github.io/docfx/

下载docfx

下载docfx:链接

配置环境变量

这里使用的是windows环境,解压对应文件后,将文件夹路径添加到电脑的Path环境变量中。

配置成功后,启动cmd窗口,输入docfx -v检验下。

安装.NET SDK

确保电脑已经安装过.NET SDK

Prerequisites

  • Familiarity with the command line
  • Install .NET SDK 6.0 or higher

创建docfx工程

打开cmd,执行docfx init -q,创建模版工程

继续执行docfx docfx.json --serve即可生成API文档,并发布服务。

通过http://localhost:8080 即可打开API文档

修改JSON

在上一个步骤创建了模版工程,为了给我们的目标代码(程序集)生成API文档,则需要修改docfx.json。

示例如下:

json 复制代码
{
  "metadata": [
    {
      "src": [
        {
          "src": "../AR_Project",
          "files": [
            "EQ.Runtime.csproj",
          ]
        }
      ],
      "dest": "api",
      "includePrivateMembers": false,
      "disableGitFeatures": false,
      "disableDefaultFilter": true,
      "noRestore": false,
      "namespaceLayout": "flattened",
      "memberLayout": "samePage",
      "allowCompilationErrors": false
    }
  ],
  "build": {
    "content": [
      {
        "files": [
          "api/**.yml",
          "api/index.md"
        ]
      },
      {
        "files": [
          "articles/**.md",
          "articles/**/toc.yml",
          "toc.yml",
          "*.md"
        ]
      }
    ],
    "resource": [
      {
        "files": [
          "images/**"
        ]
      }
    ],
    "output": "_site",
    "globalMetadataFiles": [],
    "fileMetadataFiles": [],
    "template": [
      "default",
      "common"
    ],
    "fileMetadata": {
      "pdf": {
        "api/**/toc.yml": true
      }
    },
    "globalMetadata": {
      "_appFaviconPath": "images/unity.ico",
      "_enableNewTab": "true"
    },
    "postProcessors": [],
    "keepFileLink": true,
    "disableGitFeatures": false
  }
}

更多使用方式,可参考官方文档 https://dotnet.github.io/docfx/docs/dotnet-api-docs.html

注意

默认的生成配置中,只会生成有 namespace 的 API 文档。

API 文档生成在 docfx_project/_site 文件夹下。

这个命令在生成文档的同时会启动一个本地的网页服务。

。在浏览器打开 http://localhost:8080/api/ 即可查看生成的 API 文档

相关推荐
用户298698530142 小时前
.NET 文档自动化:Spire.Doc 设置奇偶页页眉/页脚的最佳实践
后端·c#·.net
用户3667462526742 小时前
接口文档汇总 - 2.设备状态管理
c#
用户3667462526742 小时前
接口文档汇总 - 3.PLC通信管理
c#
Ray Liang1 天前
用六边形架构与整洁架构对比是伪命题?
java·python·c#·架构设计
Scout-leaf4 天前
WPF新手村教程(三)—— 路由事件
c#·wpf
用户298698530144 天前
程序员效率工具:Spire.Doc如何助你一键搞定Word表格排版
后端·c#·.net
mudtools5 天前
搭建一套.net下能落地的飞书考勤系统
后端·c#·.net
玩泥巴的6 天前
搭建一套.net下能落地的飞书考勤系统
c#·.net·二次开发·飞书
唐宋元明清21886 天前
.NET 本地Db数据库-技术方案选型
windows·c#
郑州光合科技余经理6 天前
代码展示:PHP搭建海外版外卖系统源码解析
java·开发语言·前端·后端·系统架构·uni-app·php