📜 ⬆️ ⬇️

Sandcastle and SHFB

This article is an article about working with Sandcastle and SHFB , in order not to forget yourself and tell others.

4 years have passed since the last article on Sandcastle ( “Creating Documentation in .NET” ), so it's time to refresh some points of this documentation utility.

When there was a question about the documentation on our project, the choice was mostly between Doxygen (which was already used in the project) and Sandcastle (which was used before by the customer). In the end, the choice fell on Sandcastle, because It was recommended by the customer himself, generated similar documentation visually, unlike Doxygen, as well as integration with Help & Manual (integration was not used as a result).

For those who are too lazy to google, but it's interesting to see a list of other tools for documentation, here's a good list: stackoverflow.com/a/14420174
')
In a simplified form, the task itself was the generation of documentation in the form of a ".chm" file and help on the site. As an example, there will be a small project from the library with a pair of documented classes and the Sandcastle project itself (link to github: github.com/misiam/Sandcastle-Sample ).

Installation


First you need to install Sandcastle, or rather, Sandcastle Help File Builder (SHFB). This is a continuation of the project, which is viciously abandoned by the firm M $ and carefully forknut Eric Woodruff. Downloading from here: shfb.codeplex.com/releases/view/121365

The chm-compiler and the plug-in for VS2012 and VS2013 were important to me first of all. In addition, Sandcastle Help File Builder itself is actually installed, it is an application that allows you to use the interface, rather than writing everything into xml files. With the exception of the text editing toolbar (bold, italics, etc.), I didn’t find any differences between SHFB and the studio plugin, and the studio also offers auto-compiler with intelisens, so I gradually developed the development to it.

Project Setup


When everything is installed, you can add a project to the solution. A “Documentation / Sandcastle Help File Builder Project” appeared in the studio, select it, add “Documentation Sources” (a link to the project we are documenting), turn on the “XML documentation file” in the project, and launch the build. Go to the folder / bin ... and find nothing there. The thing is that by default Sandcastle creates files in the \ Help folder in the project folder.

To avoid this, go to the project properties -> Path -> “Help content output path” and change to something more familiar, for example, to “bin \ Help \”. After the build, you can see LastBuild.log (created by default in the output folder) and the chm file. Do not pay attention to the appearance and warnings.

Now the help is created in the folder in which we wanted, but the help should also be opened from the webcam, and chm fully supports only explorer, the rest of browsers will, at best, open such a help with the appropriate plugin. It's easier to generate the Website: project properties -> Build -> turn on the “Website (HTML / ASP.NET)" (in fact, there is also php there, you can delete it in the post build event. And one more remark: build events can not to work at assembly from studio and SHFB - collect through msbuild).

As soon as you add a Website, you will be able to detect the following problem: both helpers are in the same folder. Beloved, uncomfortable, and not comme il faut. Go to the project properties -> Plug-Ins -> Output Deployment -> Add. Here we indicate the relative paths for copying.
Output deployment plugin


It remains quite a bit to bring the project in order.

In the Website / html directory, all files of the [GUID] .htm type. To fix this, go to the project properties -> Help File and change the “Topic file naming method” property from “GUID” to a more readable “Member name”. Now the address in the browser will reflect the page on which the user is located.

In those places where there is no documentation, the red warning labels “Missing documentation for ...” appear in the help.



Such inscriptions are convenient in development, but completely unacceptable in the finished documentation. To remove them, go to the project properties -> Missing Tags and choose which elements should not display messages if they have no documentation. Also currently used languages ​​are C #, VB, C ++, F #. Project properties -> Help File -> Syntax Filters and select only those languages ​​that are necessary.

Create a couple of pages.


To begin, delete the Version History folder with all its contents and the Welcome.aml page from the project. The documentation structure is built in the ContentLayout.content file, so you have to clean this file as well.

In most cases, when creating a new documentation page, you have to choose the “Conceptual” type (there are many types and you can talk about them for a long time). When creating a new page, you need to add it to ContentLayout. The possibilities of configuring static pages with respect to the generated code and each other are very large, you can make a topic tree the way you want.

Documentation pages link to each other using a topic ID. It can be found at the top of the page in the corresponding attribute.

Example:

<link xlink:href="b2ac2359-2794-4644-b900-297937ffeaae" /> 

Problems begin when it is necessary to refer to the generated pages. In this case, Sandcastle disagrees with the syntax used in the <see /> meta tags and uses its own:

 <codeEntityReference qualifyHint="true">M:SandcastleSample.Samples.ConstructorsSamples.#ctor(System.String,System.Int32)</codeEntityReference> <codeEntityReference qualifyHint="true">M:SandcastleSample.Samples.MethodsSamples.MethodWithRefParameter(System.String,System.String@)</codeEntityReference> 


qualifyHint is set to “true” if you want to show the method signature.

List of references
Apply toRuleExample
Methods and properties with argumentsArgument list is required in bracketsM: Foo.Bar.Func (System.Boolean)
Methods and properties without argumentsBrackets should not be used.M: Foo.Bar.Func
Constructors#Ctor is used instead of name. If the constructor has parameters, the same rule is used as for the method with parametersM: Foo.Bar. # Ctor
Static constructors#Ctor is used instead of nameM: Foo.Bar. # Cctor
FinalizersThe method name is Finalize.M: Foo.Bar.Finalize
ArgumentsSeparated by commas, no spaces. Their name is used with namespace. Those. instead of int , System.Int32 is used, etc.M: Foo.Bar.Func (System.Int32, System.String, Foo.Widget)
out and ref parametersTheir type name ends with @M: Foo.Bar.Func (System.Int32 @)
Parameters marked as paramsNo special notation
Parameters that define a generic typeApostrophe character is added with a generic type number.T: Foo.Bar`1
Arrays as parametersThe dimension of the array can be omitted.M: Foo.Bar.Func (System.Int32 [0:, 0:])
Parameters that reference types such as List <>It uses comma-delimited generalized type arguments enclosed in bracesM: Foo.Bar.Func (System.Collections.Generic.List {System.String})

Original

The list is large, and such things just have to know, there's nothing you can do.
Although you can enable the warnings "Missing documentation ..." and there you can see in what form Sandcastle expects the name of the method.

Tips and tricks


Source: https://habr.com/ru/post/243039/


All Articles