Document only methods and/or classes with a certain attribute
I would like to be able to have a filter of some sort that would allow me to only include classes and/or methods that have the attribute [TestClass] or [TestMethod]. We are using Team Foundation Server test automation and would like to create a Sandcastle help file that only contains the documentation content that is applied to Test Classes and Test Methods headers. I would like to ignore all other documentation headers. I had tried to use the XPath filter, but it seems to only work on exclusion rules, and I am having trouble getting it to do what I want.
There isn't a way to include types and members only by attribute. You can probably create a plug-in to do it. A short term solution would be to set the API filter to exclude everything but the stuff you are interested in though you'd need to update it as new types and methods were added.
You could also make sure that all your test classes and methods are public and all others that you don't want documented make them internal. Then you could exclude all non-public items from your generated documentation.
I am taking the route of building my own custom plug-in, however I am having trouble understanding how to implement some things. I've created the plug-in and it is being called by Sandcastle. The approach that I wanted to take was to parse the reflection.xml file for the attributes that I am wanting to filter. At first I thought about stripping the apis out of the reflection.xml file, but then I thought it would be better to build apiFilters on the GenerateApiFilter BuildStep. There are a couple of problems with this that I am having. The first problem is that the reflection.xml file is not generated yet on this BuildStep. The second problem is understanding if and/or how I would add the apifilters based on the elements that I find that have the attribute I am looking for. Can someone give me a little guidance on the proper approach I should be using?
If you need reflection data to determine what to keep, I'd suggest running your plug-in after the reflection data has been generated and stripping out the unwanted content. Using the API filter approach you'd run into the same issue as using the standard API filter. That is, you'd have to manually keep it up to date as new types and members are added. By stripping stuff that doesn't have the attribute, it works without any such maintenance.
I was hoping that I could generate the APIFilter pragmatically within my plug-in and then let Sandcastle handle the filtering of the reflection file. It seems like it would be much easier to do that rather than try to strip out all of the elements in the reflection file that do not have the C# attribute that I want to include. When I tried to do modify the refleciton file directly, I ended up stripping out some
I can't see a way to create an API filter without first having reflection information if you want it done dynamically. If you know up front what has to go into the API filter, you'd be better off using the existing one.
I finally got it to work by modifying the reflection file directly. I had a problem with one of my xpath searches that was causing some of my issues.