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.

bitbonk
  • 48,890
  • 37
  • 186
  • 278
dalenewman
  • 1,234
  • 14
  • 18

2 Answers2

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": ...
}
McNets
  • 10,352
  • 3
  • 32
  • 61
dalenewman
  • 1,234
  • 14
  • 18
  • 1
    I just referenced my solution file, and it found all the projets included. easy – Schwarzie2478 Oct 27 '17 at 08:36
  • 1
    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.) – Jeremy Caney Jan 06 '22 at 02:37
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": { ... }
}
JJS
  • 6,431
  • 1
  • 54
  • 70