使用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 文档

相关推荐
路多辛9 分钟前
全能型 Go Agent 框架 covonaut v1.0.8 发布:新增行内补全与多后端可观测性
开发语言·golang·agent
大模型丫丫11 分钟前
FastAPI 入门指南:从零开始构建高性能 Python API
开发语言·python·fastapi
wuyk55522 分钟前
《WiFi 嵌入式物联网开发全套实战》| 第01章 WiFi整体架构详解:BSS/ESS/AP/STA模式彻底区分
开发语言·stm32·单片机·嵌入式硬件·mcu·物联网·51单片机
界面开发小八哥26 分钟前
界面控件DevExpress WinForms中文帮助文档 - 入门指南
ai·c#·.net·devexpress·ui开发·winforms
wuyk55528 分钟前
第六章:CAN 调试工具、抓包分析、全套故障排查 + CAN-FD 进阶拓展
开发语言·stm32·单片机
2501_915106321 小时前
Swift 开发环境搭建指南:三条路径按目标对号入座
开发语言·vscode·ios·objective-c·个人开发·swift·敏捷流程
清风与日月1 小时前
Yitter.IdGenerator:高性能分布式唯一ID生成器详解
分布式·c#·.net·.netcore
Mr. zhihao1 小时前
线上卡顿排查决策手册:场景 × 命令 × 现象 × 调整方案
java·开发语言·jvm
一直C2 小时前
【Linux应用编程】深入理解Linux多任务机制:进程原理、状态转换与进程控制实战
linux·开发语言·算法·ubuntu·vim·visual studio code
影寂ldy2 小时前
C# WinForm TCP-Socket
网络·tcp/ip·c#