Dec 25, 2016

Using Doxygen command line to Generate HTML documentation for C# Application

We have covered document generate using Doxygen GUI in the previous post. As I have mentioned in the previous post to cover Doxygen command in next post.

So As we are going to cover Doxygen command using generate documentation. 

I assumed you have already downloaded and installed Doxygen in your system.

And your C# application very well commented on method, classes, and other objects.

So, after all, set we are going to generate a document using the command line.

Step 1: Press CTL+R and write cmd and hit the enter to open the command prompt.

Step 2: First a fall need to create Doxygen configuration file using command line with the following command
C:\Work>doxygen -g doxygenfile
Run above command and generate the configuration file.

Step 3: Once the configuration file is generated require few configuration as per your project and path requirements. So edit generated configuration file and update following options.
INCLUDE = Doxygen config_file_name
OUTPUT_DIRECTORY = Doxyment_directory
PROJECT_NAME = "My Project"
RECURSIVE = YES
OPTIMIZE_OUTPUT_JAVA = YES
Above configurations are good to generate the document. For more configurations visit on Doxygen website.

Step 4: Once you done with configuration file changes then run command for the document generate.
doxygen <config_file>
Above is the syntax for doxygen command.
Run the below command to generate the document.
doxygen doxygen
Once you run above command. Doxygen will process the generate document.

Step 5: Once above command successfully run then you will check your output directory and the document will be there.
That's it!! 

Hope you like it. Happy coding!.

Generate HTML documentation using doxygen for C#

This post is dedicated to developers because after reading this post developers life will easy to create the document directly from the code.

For creating the document, we are going to cover the Doxygen utility.

Using Doxygen, a developer can create the document using Doxygen GUI or Doxygen command. We are going to cover both ways generate the document. The first post we are cover GUI only and next post will cover Doxygen command.

Before we going further one thing is very important to generate document is the comment of the code without comment document will not generate properly.

I assume you know, how to write XML comment on the code of every method, classes, and other objects.

Once you have written comments on code and ready to generate the document.

For generate the document follow the below steps.

Step 1: Download Doxygen from the Doxygen website.

Step 2: Once download, install into your system.

Step 3: After installation, open the Doxywizard

Step 4: Once open Doxywizard GUI then follow below image with steps.
In Doxygen GUI, check the yellow highlighted text with the following explanation. 
Above image step 1: Specify the working directory from which doxygen will run. For that, you need to create a blank folder and select that path. In our demo, we have created DOXY folder under the D drive.

Above image step 2: Select the Wizard tab and select Project from Topics. Right-hand side fills form details as per your project related to Project Name, Source code Directory Path, Destination Directory and Scan recursively.

For Scan recursively checkbox use for the subfolder scanning.
Now click on Mode Topics and select your project language, We have selected "Optimise for Java or C# output"


Step 5: Once done with Wizard tab click on Expert tab

Under Expert tab select Build Topics and select as per your requirement configuration options from the right-hand side. For the understanding of the configuration options, visit on Doxygen site.

Here we have select few options which are good to generate the document.

Step 6: Last step for the generate document. Click on Run tab
Once you click on Run tab, you will see the Run doxygen button underneath the tab. Now we are ready to generate the document.

Click on Run doxygen button and you will see the progress on the output produced by doxygen box.

After successful completion, you will check your output directory folder and your document will be ready. 

Open the index.html page on the browser and check document.

Hope you like it. Happy Codding!!

Dec 3, 2016

Create HTML document from the swagger generated JSON file using Asp.Net Core

Today, We will create HTML document from the Swagger generated JSON file using Asp.net.

Let's create document step by steps.

Step 1 : Create Asp.Net Core Web API project using visual studio.

Step 2 : Once the solution is ready then follow below link to configure Swagger in Asp.Net Core.

https://docs.microsoft.com/en-us/aspnet/core/tutorials/web-api-help-pages-using-swagger

First Install Swashbuckle NuGet Package.
Install-Package Swashbuckle -Pre

Once NuGet Package successfully installed then add the following code on startup.cs for Swagger integration with the solution.
// This method gets called by the runtime. Use this method to add services to the container
        public void ConfigureServices(IServiceCollection services)
        {
            // Add framework services.
            services.AddApplicationInsightsTelemetry(Configuration);

            services.AddMvc();

            // Inject an implementation of ISwaggerProvider with defaulted settings applied
            services.AddSwaggerGen();
        }

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            app.UseApplicationInsightsRequestTelemetry();

            app.UseApplicationInsightsExceptionTelemetry();

            app.UseMvc();

            // Enable middleware to serve generated Swagger as a JSON endpoint
            app.UseSwagger();

            // Enable middleware to serve swagger-ui assets (HTML, JS, CSS etc.)
            app.UseSwaggerUi();
        }
Hope you get the better idea after visited link and above steps.

Step 3 : After completed above step your solution is ready and run and browse the swagger ui.

For the same configuration on application example, you can fine on my GitHub repository

Step 4 : Now time to run the application and browse the Swagger UI page.

It will be URL like http://localhost:XXXX/swagger/ui/index.html (XXXX is your port number).
Once navigate to this URL. It will look like below image.

Step 5 : You can see on the swagger screen there is a one JSON file link. It looks like http://localhost:XXXX/swagger/v1/swagger.json.

Step 6 : We have JSON file ready with all contain so time to browse http://editor.swagger.io/.

Step 7 : On Swagger editor click on file menu and choose "Import URL" and a popup will open and asking for URL.

Step 8 : Copy JSON URL and paste on above popup dialog. Make sure "Use CORS proxy" uncheck when your URL is from localhost.

Else you can paste JSON string directly to the "Paste JSON" (Select file menu and choose Paste JSON). Click on Import button to load the JSON file on Swagger editor.

Step 9: After clicking on Import button it will show two part of the screen. One side YAML and once side HTML document.


Step 10 : Last and important step once you see above the screen. Now we are ready to perform download document. 
For HTML document click on "Generate Client" from the menu and select "HTML" 

Once you download the file you will able to view beautiful HTML document generated.

Hope you are like it so please keep reading .