Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DocFX: Generate API documentation for multiple projects

I'm working on a project that has multiple projects in a solution. I would like to be able to generate the documentation from an outside directory to keep the application code folders clean. When I try to set the src directory in my docfx.json, it doesn't seem to like absolute paths, nor does it like relative paths.

{
  "metadata": 
  [{
         "src": 
         [{
               "files": ["../../../Repos/Wsi.Extranet.CommonServices/Wsi.Extranet.CommonServices/**/*.csproj"]
               "exclude": 
               [
                    "**/obj/**",
                    "**/bin/**",
                    "_site/**"
               ]
        }],
        "dest": "api"
}],
"build": {
"content": [
  {
    "files": [
      "api/**.yml",
      "api/index.md"
    ]
  },
  {
    "files": [
      "articles/**.md",
      "articles/**/toc.yml",
      "toc.yml",
      "*.md"
    ],
    "exclude": [
      "obj/**",
      "_site/**"
    ]
  }
],
"resource": [
  {
    "files": [
      "images/**"
    ],
    "exclude": [
      "obj/**",
      "_site/**"
    ]
  }
],
"overwrite": [
  {
    "files": [
      "apidoc/**.md"
    ],
    "exclude": [
      "obj/**",
      "_site/**"
    ]
  }
],
"src":    "../../../Repos/Wsi.Extranet.CommonServices/Wsi.Extranet.CommonServices",
"dest": "_site",
"globalMetadataFiles": [],
"fileMetadataFiles": [],
"template": [
  "default"
],
"postProcessors": [],
"noLangKeyword": false
 }
}

It says it built fine but didn't find any files and the directory that it searches for is staying in the current directory.

D:\temp\WsiApiDocs\docfx_project>docfx metadata
Info: Config file docfx.json found, start generating metadata...
Info: No files are found with glob pattern **/*.csproj, excluding
    **/obj/**,**/bin/**,_site/**, under directory "D:\temp\WsiApiDocs\docfx_project"
Info: Completed executing in 54.0087 milliseconds.


Build succeeded.
    0 Warning(s)
    0 Error(s)

When I attempt to put the relative path in the files property, I get the following:

D:\temp\WsiApiDocs\docfx_project>docfx metadata
Info: Config file docfx.json found, start generating metadata...
Info: No files are found with glob pattern
 ../../../Repos/Wsi.Extranet.CommonServices/Wsi.Extranet.CommonServices/**/*.csproj, 
excluding **/obj/**,**/bin/**,_site/**, under directory
 "D:\temp\WsiApiDocs\docfx_project"
**Warning: NOTE that `../` is currently not supported in glob pattern, please use `../` in `src` option instead.**
Info: Completed executing in 48.9621 milliseconds.


Build succeeded with warning.
Warning: NOTE that `../` is currently not supported in glob pattern, please use `../` in `src` option instead.
    1 Warning(s)
    0 Error(s)

So my confusion seems to be in how to use the src option instead. If use the src in metadata, then it seems that I can't specify the file and exclusion info. I tried to use a src property on the same level as metadata but that seemed to do nothing.

like image 882
Terry Palmer Avatar asked Dec 02 '16 16:12

Terry Palmer


1 Answers

Just as the error states

../ is currently not supported in glob pattern

files, exclude etc. use glob patterns. Set a base directory instead via src:

{
  "metadata": [
    {
      "src": [
        {
          "files": "Repos/Wsi.Extranet.CommonServices/Wsi.Extranet.CommonServices/**.csproj",
          "exclude": [
            "**/obj/**",
            "**/bin/**"
          ],
          "src": "../../.." // <---- base directory
        }
      ],
      "dest": "api"
    }
  ],
  "content": [
    {
      "files": [
        "api/**.yml",
        "api/index.md"
      ]
    }
    // ...
  ]
}

Here is an exmaple of structuring multiple projects

like image 60
Marcus S. Avatar answered Oct 19 '22 07:10

Marcus S.