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

相关推荐
热爱专研AI的学妹26 分钟前
数眼搜索API与博查技术特性深度对比:实时性与数据完整性的核心差异
大数据·开发语言·数据库·人工智能·python
Mr_Chenph43 分钟前
Miniconda3在Windows11上和本地Python共生
开发语言·python·miniconda3
阿狸远翔44 分钟前
Protobuf 和 protoc-gen-go 详解
开发语言·后端·golang
永远前进不waiting44 分钟前
C复习——1
c语言·开发语言
伯明翰java1 小时前
Java数据类型与变量
java·开发语言
一路往蓝-Anbo1 小时前
【第13期】中断机制详解 :从向量表到ISR
c语言·开发语言·stm32·单片机·嵌入式硬件
渣渣盟1 小时前
Linux邮件服务器快速搭建指南
linux·服务器·开发语言
BD_Marathon1 小时前
Promise基础语法
开发语言·前端·javascript
Aotman_2 小时前
JavaScript MutationObserver用法( 监听DOM变化 )
开发语言·前端·javascript·vue.js·前端框架·es6
钰fly3 小时前
C#文件与数据操作核心概念手册
c#