How to generate documentation for other projects within solution using DocFx

4.3k Views Asked by At

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.

2

There are 2 best solutions below

2
On BEST ANSWER

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": ...
}
0
On

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": { ... }
}