How to generate documentation for other projects within solution using DocFx - documentation-generation

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.

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

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

Related

Building Electron with Electron Builder without downloading packages from github

I'm trying to build an electron app with electron builder,
but I encountered a problem: my network blocks packages from GitHub on downloading.
Is there any other way to disable the look for the packages while online?
the script code:
"electron:admin": "electron-builder -c.extraMetadata.main=build/main.js",
the electron builder part of package.json:
"build": {
"extends": null,
"icon": "build/logo.ico",
"files": [
"build/**/*",
"package.json"
],
"extraFiles": [
{
"from": "../database-client.db",
"to": "./database-client.db",
"filter": [
"**/*"
]
},
{
"from": "../clientUploads/",
"to": "./uploads/",
"filter": [
"**/*"
]
}
],
"directories": {
"buildResources": "assets"
}
},
I'm building for windows only
I solved that by building the application outside the network and copying the AppData files of electron and electron builder.
When I'm building the app I turn down the connection to the internet so the electron builder will not look for the GitHub packages.
I still did not find a way to do that While I'm online.

Visual Studio 2019 - Use project specific ESLint config .eslintrc

I have followed this guide to set up .eslintrc configuration.
https://github.com/typescript-eslint/typescript-eslint/blob/master/docs/getting-started/linting/README.md
I have also enabled ESLint in Visual Studio by following this guide:
https://stackoverflow.com/a/44458832/3850405
My problem is that I want to use a project specific config instead of the Global ESLint Config.
The guide sets up a .eslintrc.js file so I tried to switch to a file that had the same structure as C:\Users\Oscar\.eslintrc.
Tried placing the .eslintrc in the root folder of the solution, project and in my ClientApp folder but nothing got picked up. Is it possible to use a project specific ESLint config in Visual Studio and receive build errors/warnings?
Running the command npx eslint . --ext .js,.jsx,.ts,.tsx gives me correct errors but Visual Studio shows no errors.
.eslintrc:
{
"root": true,
"parser": "#typescript-eslint/parser",
"plugins": [
"#typescript-eslint",
"jest"
],
"extends": [
"eslint:recommended",
"plugin:#typescript-eslint/recommended",
"plugin:jest/recommended",
"plugin:react/recommended"
],
"env": {
"browser": true,
"node": true,
"jest/globals": true
},
"rules": {
"no-console": [
"error",
{ "allow": [ "warn", "error" ] }
]
}
}
I was able to get ESLint in Visual Studio 2019 to use a configuration file that I had in the root of my project.
The file is called ".eslintrc.json". Here is the contents of the file so far:
{
"extends": "eslint:recommended",
"globals": {
"kendo": "readonly"
},
"env": {
"browser": true,
"commonjs": true,
"es6": true,
"jquery": true
},
"rules": {
"no-prototype-builtins": "off",
"no-unused-vars": [
"error",
{ "args": "none" }
]
}
}
One thing I noticed is that I had close and re-open Visual Studio after adding the file before it would start working. Once I did that changes I made to the file would take effect immediately.

After installing appx created with electron-builder setting default electron icon to my installed app

While installing the appx now i am able to see logo on launcher/install popup screen.
This worked when i made below changes:
1)Downgraded electron-builder version to: 20.39.0
2)Changed the directories entry in package.json as :
directories:{
"buildResources": "build",
"output": "build"}
3)Created appx named folder inside the build directory and created the build directory at package.json level
4)Added icon named "StoreLogo.png" inside build/appx directory that we have created earlier.
5)add the entry of the same in :
"win": {
"icon":"build/appx/StoreLogo.png"
}
6)After this just create the appx using electron-builder -w appx command
Now I have one more doubt after complete installation i am still seeing the default electron logo at the task-bar and also in the apps & features if i search for my application.
On the launcher/install popup i am able to see the app logo like below hidden with red color:
After installing and launching the app i am still able to see the default electron icon in the taskbar as below highlighted in red:
This is how my package.json build property looks:
{
"build": {
"extraFiles": [
"node_modules/ionic-enterprise-couchbase-lite-electron/**/*"
],
"publish": [
{
"provider": "generic",
"url": "***********"
}
],
"appId": "**************",
"nsis": {
"perMachine": true,
"oneClick": false,
"allowToChangeInstallationDirectory": true
},
"squirrelWindows": {},
"files": [
"electron.js",
"www/**/*",
"build/Square150x150Logo.png",
"build/Square44x44Logo.png"
],
"directories": {
"buildResources": "build",
"output": "build"
},
"appx": {
"identityName": "myApp",
"publisher": "CN=*************************",
"publisherDisplayName": "my Company",
"applicationId": "myApp",
"displayName": "myApp",
"backgroundColor": "#f2f4f7"
},
"win": {
"certificateFile": "./certs/CordovaApp.Windows10_StoreKey.pfx",
"publisherName": "my Company",
"icon": "build/appx/StoreLogo.png",
"target": [
{
"target": "nsis",
"arch": [
"ia32"
]
},
"appx",
"msi"
]
},
"nodeGypRebuild": "false",
"npmRebuild": "false"
}
}
I tried adding all related resources as mentioned in : https://www.electron.build/configuration/appx but it started giving error of invalid manifest when creating a appx.
So can anyone please help me to resolve this issue?
I solved the issue by doing below changes:
1) Added the assets mentioned in the appx link: https://www.electron.build/configuration/appx
2) created appx folder in the build directory, keep the package.json as mentioned above.
3)Make sure the app logos named should be specific as metioned in the link .PNG format.
4)Earlier I had icon names as e.g: Square44x44Logo.png format .PNG then after changing the name to Square44x44Logo kept format .PNG as it is I was able to solve installed app issue.
What i realized by this is naming convention does matter a lot in case of applying icons. So the main issue caused due to pont 4.

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.
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

Chutzpah running both .ts and .js tests (the tests are effectively the same so the test count is doubled)

In Visual Studio, right-click on a .ts file and "Run JS Tests", only the tests in the .ts file run and are counted in the total.
"Run JS Tests" at the folder level or project level and both the tests in the .ts and .js files are run and counted in the total.
Chutzpah.json settings:
{
"Framework": "jasmine",
"TypeScriptCodeGenTarget": "ES5",
"TestHarnessLocationMode": "SettingsFileAdjacent",
"RootReferencePathMode": "SettingsFileDirectory",
"Compile": {
"Mode": "External",
"Extensions": [ ".ts" ],
"ExtensionsWithNoOutput": [ ".d.ts" ]
},
"Tests": [
{ "Path": "Specs"}
]
}
I had the same issue. All my tests are written in TypeScript, so my *.ts files define what tests exist. I had solved it by including only *.ts files.
{
"Tests": [ { "Path": "Specs", "Includes": [ "*.ts" ] } ],
"Compile": {
"Mode": "External",
"Extensions": [ ".ts" ],
"ExtensionsWithNoOutput": [ ".d.ts" ]
}
}
Works like a charm.
Without seeing your full project it is hard to know for sure but something along the following should help achieve this. If you need to include some .js files you can change the exclude patterns accordingly.
```
{
"Framework": "jasmine",
"TestHarnessLocationMode": "SettingsFileAdjacent",
"RootReferencePathMode": "SettingsFileDirectory",
"Compile": {
"Mode": "External",
"Extensions": [ ".ts" ],
"ExtensionsWithNoOutput": [ ".d.ts" ]
},
"References": [
{ "Excludes": ["*.js"]}
],
"Tests": [
{ "Path": "Specs", "Excludes": ["*.js"]}
]
}
```

Resources