Search code examples
markdowndocumentation-generationxml-documentationdocfx

DocFx reference markdown different project


We are working on a multi-Project *.sln Solution and can successfully generate an API Documentation with *.md Articles for it using DocFx in a separate Asp.Net Web csproj only for documentation.

But we want to maintain and reference local Markdown *.md Articles and images in the individual *.csproj projects and reference and re-use those in the global documentation site, but somehow we only get the *.md files from the /articles folder in the Web.csproj.

Here is the current docfx.json. As you can see we are trying to reference images and markdown files from a different project

"../Generator/MyDocService.Contracts/**.png", and

"../Generator/MyDocService.Contracts/*.md",

but neither of them show up in our "obj" or the "_site" Folder.

{
  "metadata": [
    {
      "src": [
        {
          "files": [
            "*.csproj"
          ],
          "src": "../Generator/GenBasics",
          "exclude": [
            "**/obj/**",
            "**/bin/**",
            "_site/**"
          ]
        },
        {
          "files": [
            "*.csproj"
          ],
          "src": "../DocFrameworkCore/GenCore",
          "exclude": [
            "**/obj/**",
            "**/bin/**",
            "_site/**"
          ]
        },
        {
          "files": [
            "*.csproj"
          ],
          "src": "../Generator/GenImpl",
          "exclude": [
            "**/obj/**",
            "**/bin/**",
            "_site/**"
          ]
        },
        {
          "files": [
            "*.csproj"
          ],
          "src": "../DocFrameworkCore/GenCoreBasics",
          "exclude": [
            "**/obj/**",
            "**/bin/**",
            "_site/**"
          ]
        },
        {
          "files": [
            "*.csproj",
            "**.md",
            "**.png"
          ],
          "src": "../Generator/MyDocService.Contracts",
          "exclude": [
            "**/obj/**",
            "**/bin/**",
            "_site/**"
          ]
        }
      ],
      "filter": "filterConfig.yml",
      "dest": "obj/api"
    }
  ],
  "build": {
    "content": [
      {
        "files": [
          "api/**.yml"
        ],
        "cwd": "obj"
      },
      {
        "files": [
          "api/*.md",
          "articles/**.md",
          "../Generator/MyDocService.Contracts/*.md",
          "toc.yml",
          "*.md"
        ],
        "exclude": [
          "obj/**",
          "_site/**"
        ]
      }
    ],
    "resource": [
      {
        "files": [
          "../Generator/MyDocService.Contracts/**.png",
          "images/**"
        ],
        "exclude": [
          "obj/**",
          "_site/**"
        ]
      }
    ],
    "overwrite": [
      {
        "files": [
          "apidoc/**.md"
        ],
        "exclude": [
          "obj/**",
          "_site/**"
        ]
      }
    ],
    "dest": "_site",
    "globalMetadata": {
      "_appTitle": "MyDoc API",
      "_appFooter": "",
      "_appLogoPath": "images/My.png",
      "_appFaviconPath": "favicon.ico",
      "_enableSearch": true,
      "_disableContribution": true
    },
    "template": [
      "default",
      "docfx-tmpl/src"
    ]
  }
}

Solution

  • The only way I could make the distributed *.md Files from all Sub-Projects available was to place the docfx.json in the root of the solution.