How to generate documentation for other projects within solution using DocFx
Asked Answered
J

2

12

I am using DocFx to automatically generate documentation in Visual Studio 2015.

Per the Getting Started instructions, I added an empty ASP.NET 4 Web Application and used the Nuget Console to install the DocFx build package (e.g. Install-Package docfx.msbuild). I built the site and it it generated documentation for code within the project.

I was wondering how to configure docfx.json to get DocFx to document code in other projects within the solution.

Jacquline answered 23/2, 2016 at 22:2 Comment(0)
J
15

In docfx.json, there is an array of metadata. The example metadata has a src object with files and exclude properties.

To point to another project in your solution, add a cwd property to metadata and change folders (i.e. "../Another.Project").

{
  "metadata": [
    {
      "src": [
        {
          "files": [ "**/*.csproj" ],
          "exclude": [ "**/bin/**", "**/obj/**", "_site/**" ],
          "cwd": "../Another.Project"
        }
      ],
      "dest": "obj/api"
    }
  ],
  "build": ...
}
Jacquline answered 24/2, 2016 at 14:2 Comment(2)
I just referenced my solution file, and it found all the projets included. easyTonsillectomy
It's worth noting that the cwd property has been deprecated since this was written, and should now be replaced with src. (Yes, src: [ { src: "../" } ]; it's a bit confusing.)Smallman
T
1

This worked for me.

directory structure

+---ClassLibrary
|   \---ClassLibrary.csproj
\---DocFxProject
    \---docfx.json

docfx.json contents cwd and src are synonyms for the same property

{
  "metadata":
  [ 
    {
      "src":
      [
        {
          "files": [ "**/ClassLibrary.csproj" ],
          "src": "..",
          "exclude": [ "**/obj/**", "**/bin/**" ]
        } 
      ],
      "dest": "obj/api"
    }
  ],
  "build": { ... }
}
Thomasina answered 11/9, 2018 at 18:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.