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

相关推荐
jarreyer5 分钟前
python离线包安装方法总结
开发语言·python
李辰洋7 分钟前
go tools安装
开发语言·后端·golang
wanfeng_0912 分钟前
go lang
开发语言·后端·golang
绛洞花主敏明15 分钟前
go build -tags的其他用法
开发语言·后端·golang
ByteCraze19 分钟前
秋招被问到的常见问题
开发语言·javascript·原型模式
码银23 分钟前
【python】基于 生活方式与健康数据预测数据集(Lifestyle and Health Risk Prediction)的可视化练习,附数据集源文件。
开发语言·python·生活
Pluchon25 分钟前
硅基计划5.0 MySQL 叁 E-R关系图&联合/多表查询&三大连接&子查询&合并查询
开发语言·数据库·学习·mysql
kyle~31 分钟前
C++---嵌套类型(Nested Types)封装与泛型的基石
开发语言·c++·算法
sali-tec34 分钟前
C# 基于halcon的视觉工作流-章48-短路断路
开发语言·图像处理·人工智能·算法·计算机视觉
张人玉1 小时前
C#WPF如何实现登录页面跳转
ui·c#·wpf