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

相关推荐
hez20106 小时前
Runtime Async - 步入高性能异步时代
c#·.net·.net core·clr
mudtools19 小时前
.NET驾驭Word之力:玩转文本与格式
c#·.net
唐青枫1 天前
C#.NET 数据库开发提速秘籍:SqlSugar 实战详解
c#·.net
mudtools2 天前
.NET驾驭Word之力:理解Word对象模型核心 (Application, Document, Range)
c#·.net
侃侃_天下2 天前
最终的信号类
开发语言·c++·算法
echoarts2 天前
Rayon Rust中的数据并行库入门教程
开发语言·其他·算法·rust
Aomnitrix2 天前
知识管理新范式——cpolar+Wiki.js打造企业级分布式知识库
开发语言·javascript·分布式
大飞pkz2 天前
【设计模式】C#反射实现抽象工厂模式
设计模式·c#·抽象工厂模式·c#反射·c#反射实现抽象工厂模式
每天回答3个问题2 天前
UE5C++编译遇到MSB3073
开发语言·c++·ue5
伍哥的传说2 天前
Vite Plugin PWA – 零配置构建现代渐进式Web应用
开发语言·前端·javascript·web app·pwa·service worker·workbox