Create single HTML / markdown file using Sandcastle Documentation - c#

simple question here.
I'm using Sandcastle Help File Builder to generate documentation of a C# project in Markdown or HTML format. My issue is it's creating a separate .md / .html file for every item that's documented. Is there any way to force it to generate a single large file containing all the documentation similar to how Visual Studio outputs one single XML file, or at minimum using a directory system to at least structure the output a little better rather than have one folder with ~200 markdown / html files.
Thanks.

For the HTML part of the question, it is possible to open the generated index.html file in a browser (may need to enable scripting for the page to work correctly), then save it as a single file in MHTML format. According to the linked page, the current versions of most major browsers support MHTML nowadays.

Related

Convert Html to PDF with link to a specific location in another PDF

I'm converting a group of HTML files to PDF in C#.
Wkhtmltopdf did the job perfectly, but now I need to add a link to a location in another pdf and wkhtmltopdf doesn't seem to be able to do that.
Creating links to point to another location in the same document is easy:
Link
Also, linking to another document works well:
Link
However, I need to link to a specific location in a different document.
The simple method with wkhtmltopdf fails here:
This link doesn't work
This is supported in PDF specification with Remote Go-To actions.
PDF Reference, p. 520:
How can this be achieved in C#?
I need the converter to support CSS 3, so I think the way to go would be to first convert the HTML to PDF with wkhtmltopdf and then use a library to edit the PDF to correct the links.
How to do this practically? Which library to use and how to use it?
UPDATE:
I've created a feature request for wkhtmltopdf on GitHub. However, this question is still relevant.

Can I generate .MD files from XML Documentation?

I have used Sandcastle to document my class libraries recently. However, I have recently discovered that Sandcastle is no longer developed by Microsoft: https://archive.codeplex.com/?p=sandcastle.
I have had a look online on GitHub and I see that lots of open source projects use .MD (MarkDown) files these days. I see that .MD files are supported by GitHub and TFS. How can I generate .MD files from XML Documentation files?
I have spent the last few hours Googling this. For example, I have found this with only a few hundred downloads: https://github.com/lijunle/Vsxmd/tree/master/Vsxmd I am not asking for tool recommendations. I am asking if it is possible to convert .XML Documentation to .MD files.
Yes, it is possible.
There are a number of projects to do so out there. The one you found Vsxmd for example but also simpler ones like lontivero/593fc51f1208555112e0.
The process is basically reading and converting each XML element (or some of them) to their equivalent in markdown. The equivalent is something you must choose when writing the converter, it depends on the style you want for your resulting file.
Things get complex when dealing with tags like <inheritdoc/> if you don't want to just print "Inherit from parent." like Vsxmd does or ignoring it like lontivero does.
I'm still searching for a better tool or time for improving one.
In my scenario, I wanted code documentation for my project in the GitHub Wiki, and it takes markdown files not html.
Visual Studio (Mac, in my case) has a project options > build > compiler checkbox to generate the xml documentation file for the project. Vsxmd generates one md file from this one xml file. It is very well and extensively laid out when looking at it in most markdown previewers, but GitHub seems to have low timeouts and cannot render a large markdown page.
It is not laid out as well, but something I found that GitHub can render is the single md file generated by the web tool, vsdoc-2-md.
What I ended up using for my project is Default Documentation. It is a nuget that runs during buildtime just like Vsxmd, but generates multiple md files that are small enough for GitHub to not complain.
Just note that GitHub Wiki renames files in its urls so that all .md extensions get stripped. I had to do a search/replace to strip .md from all the links in order to get clicking around documentation from the GitHub Wiki to work.
Yes, it is possible.
The available solutions did not suit my needs, so (disclaimer) I've started developing my own: MarkDoc.Core.
This is a standalone application, so no NuGet packages are involved. Moreover, the application is fully customizable allowing you to export to other sources than Markdown and more.
Again, this is my project and at the time of writing this answer, it is still in progress.
Of course it is possible to generate markdown from XML comments. The obvious question is: Why? The best answer is: to generate a website from the markdown content.
DocFX is essentially the replacement to Sandcastle. I'm using it to generate a documentation website from XML comments in C# code.

Does Google Accept Only Sitemap With .txt Extention?

I have finalized working on my Asp.Net 4.0 website. Now that i am to publish it by next few days, i am finding resources that can help me better rank my site on popular search engines. My site displays both static and dynamic contents. For dynamic contents i will be generating dynamic sitemap each week. My problem is that i read on google webmaster website that google accepts sitemaps only with .txt extension. (https://support.google.com/webmasters/answer/183668?hl=en). Orignal instructions quoted as:
* For best results, use the following guidelines for creating text file sitemaps:
You must fully specify all URLs in your sitemap as Google attempts to crawl them exactly as you list them.
Your text file must use UTF-8 encoding.
Your text file should contain nothing but the list of URLs.
You can name the text file anything you wish, provided it has a .txt extension (for instance, sitemap.txt).
As i have mentioned, i will be using c# code to dynamically generate xml sitemap for my site but i am not sure i will be able to write xml (by using C#) into .txt files. I have very little knowledge of writing xml by using C# (Such as by utilizing XmlWriter Class). I have found this website which uses it's sitemap file which is in .xml extension (http://www.mikesdotnetting.com/sitemap). Can anybody tell me what do i need to do to complete this final step of my project. Another thing that i am interested to know is should i submit my sitemap every time to google when a link is modified? Google says to submit your sitemap to google that contains no more than 50000 urls or less than 50mb.
Submitting every dynamic URL isn't necessarily going to improve your ranking. A lot of your ranking will depend on your pagerank, not the number of URLs you have. You need good content, and people who link to your site that think your content is good.
You read the document wrong. The very first line says
In addition to the standard XML format, Google also accepts the following file types as sitemaps:
The .txt file extension is only required when you have a text file that lists only the urls. Notice how even their submission example has a .xml extension since it's using the XML sitemap format.
It would be much simpler instead of generating a new sitemap file weekly to simply write a handler to generate it upon request, and cache the data for a period of time so you're not constantly generating it at every request for the sitemap file.
If google knows where the sitemap is, it will check it out periodically anyways so re-submitting it might not get you anything. You also don't want to submit too often as Google and other search engines may think you are trying to spam them. That's why the xml sitemap definition has elements for change frequency so they know how often to re-spider the page.
FYI, don't expect to see good ranking right away. It takes a while, months even, depending on the popularity of your site and the quality of the content. The volume of links won't help and Google will find them anyways when it spiders. It is possible to do too much.

Compress existing XPS document

I would like to load an existing XPS document and compress it additionally. Looking into MSDN it seems that .NET allows for setting the compression and interleaving however i was unable to find out how to apply those settings to an existing document.
Here's the simplest answer: XPS is simply a zip.
Manually you can rename your file from something.xps to something.zip, extract the contents, recompress the contents at a higher compression level, rename the file back again - you just need to make sure that the zip tool you are using doesn't end up putting everything within a sub-directory within the zip.
Or you could do with scripting or code.
If you want to reduce the file even more then have a look at my codeproject article.
The code attached to it is built around manipulating the output from the "XPS printer driver", however most of the ideas in it should yield a lot of useful options for you to use to compress a file.

What is the best way to populate a Word 2007 template in C#?

I have a need to populate a Word 2007 document from code, including repeating table sections - currently I use an XML transform on the document.xml portion of the docx, but this is extremely time consuming to setup (each time you edit the template document, you have to recreate the transform.xsl file, which can take up to a day to do for complex documents).
Is there any better way, preferably one that doesn't require you to run Word 2007 during the process?
Regards
Richard
I tried myself to write some code for that purpose, but gave up. Now I use a 3rd party product: Aspose Words and am quite happy with that component.
It doesn't need Microsoft Word on the machine.
"Aspose.Words enables .NET and Java applications to read, modify and write Word® documents without utilizing Microsoft Word®."
"Aspose.Words supports a wide array of features including document creation, content and formatting manipulation, powerful mail merge abilities, comprehensive support of DOC, OOXML, RTF, WordprocessingML, HTML, OpenDocument and PDF formats. Aspose.Words is truly the most affordable, fastest and feature rich Word component on the market."
DISCLAIMER: I am not affiliated with that company.
Since a DOCX file is simply a ZIP file containing a folder structure with images and XML files, you should be able to manipulate those XML files using our favorite XML manipulation API. The specification of the format is known as WordprocessingML, part of the Office Open XML standard.
I thought I'd mention it in case the 3rd party tool suggested by splattne is not an option.
Have you considered using the Open XML SDK from Microsoft? The only dependency is on .NET 3.5.
Documentation: http://msdn.microsoft.com/en-us/library/bb448854%28office.14%29.aspx
Download: http://www.microsoft.com/downloads/details.aspx?familyid=C6E744E5-36E9-45F5-8D8C-331DF206E0D0&displaylang=en
Use invoke docx lib. it supports table data (http://invoke.co.nz/products/help/docx_tables.aspx). More info at http://invoke.co.nz/products/docx.aspx
Have you considered using VB? You could create a separate assembly to populate your document.
I know you are looking for a C# solution, but the XML literal support is one area where XML literal support could help you populate the document. Create a document in Word to server as a template, unzip the docx, paste the relevant XML section you want to change into you VB code, and add code to fill in the parts you wish to change. It's difficult to say from your description if this would meet your requirements but I would suggest looking into it.

Categories

Resources