2016-12-02 46 views
4

我正在研究一個解決方案中有多個項目的項目。我希望能夠從外部目錄生成文檔以保持應用程序代碼文件夾的清潔。當我嘗試在我的docfx.json中設置src目錄時,它似乎不喜歡絕對路徑,也不喜歡相對路徑。DocFX:爲多個項目生成API文檔

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

它說它構建的很好,但沒有找到任何文件,它搜索的目錄停留在當前目錄中。

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) 

當我試圖把相對路徑中的文件屬性,我得到如下:

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) 

所以我的困惑似乎是在如何使用src選項,而不是。如果在元數據中使用src,那麼似乎我無法指定文件和排除信息。我試圖使用與元數據相同級別的src屬性,但似乎什麼都不做。

回答

10

正如錯誤狀態

../目前沒有glob模式

filesexclude等使用glob模式的支持。設置基本目錄中,而不是通過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是構建多個項目

+1

真棒...感謝馬庫斯
的一個實例!我不知道爲什麼我比它更難。當它說通過src設置基本目錄時,我想這是在談論父src節點。它甚至沒有進入我的想法把一個孩子src放在父src節點中。 您構建多個項目的鏈接也非常有幫助。 –