Strange indent in code section under example

Topics: Bugs, General Questions
Feb 15, 2008 at 2:13 PM
Hi

Being very new to this product appologies if this is a stupid question but.....

I have created some code comments in my code with a code section (see below)

/// <summary>
/// Override this function if you new class needs more or less cache time then the default set up in the appConfig database table
/// </summary>
/// <example>
/// <para>Override the cache timeout settings</para>
/// <code language="c#">
/// public override int CacheTimeMins
/// {
/// get
/// {
/// return 10;
/// }
/// }
/// </code>
/// </example>

When i run this through DocProject using the latest version and a presentation style of Visual Studio 2005, the web page for this method shows the code section with the code in it not alligned to the left so it seems to be tabbed in by about 10 spaces

giving something like the following

The following example loads brand details into the database, this code is used in the brand class

C# Copy Code
public Datasets.Brand GetBrandsByDepartment(string DepartmentID)
{
// Create a new strongly typed dataset
Datasets.Brand brand = new Datasets.Brand();
// the SQL statement for the data
string SQL = "select * from M3LHHNBD.PDGROPP where GPCOMP=1 and GPDEPT='" + DepartmentID + "' order by GPDESC";
// returns the dataset back.
return (Datasets.Brand)base.GetCachableDataset(SQL, (DataSet)brand, "PDGROPP", "DepartmentID." + DepartmentID);
}


I hope you can point me in the right direction as the rest of the output is excellent and its just this last portion that is annoying me :D

Kind regards





Feb 15, 2008 at 2:15 PM
Edited Feb 15, 2008 at 2:25 PM
Sorry it seems that the post has removed the spaces

so i will try and fudge
C# Copy Code
"..........................."public Datasets.Brand GetBrandsByDepartment(string DepartmentID)
"..........................."{
".................................."// Create a new strongly typed dataset
".................................."Datasets.Brand brand = new Datasets.Brand();

quotes do not exist in reality
Coordinator
Feb 15, 2008 at 3:16 PM
Hi,

I've noticed that too. However, DocProject does not manipulate code blocks, so it's probably a Sandcastle issue (perhaps a bug in one of the XSL transformations.)

You may want to try installing Eric Woodruff's Sandcastle Presentation File Patches (it's a separate download) as it may fix the issue, but it's just a guess. Alternatively, you could try downloading his code format build component (same link, different download) to see if it fixes the problem - it'll also provide extra functionality for code blocks that you may find useful.

You can report the real issue in Sandcastle's Issue Tracker:

http://www.codeplex.com/Sandcastle/WorkItem/AdvancedList.aspx

- Dave
Feb 16, 2008 at 2:04 AM
Edited Feb 16, 2008 at 2:10 AM
This has come up before. It's actually the way the compiler outputs the comments in the <code> tag. The transformations keep the leading space when outputting them to the topic and I don't think there is a way of getting rid of it easily from within them. The only way to get rid of the leading space without any other components is to put the <code> tag in an external XML file where you can control the indent and then use <include> to pull it in.

The other alternative is to use the Code Block Component which will normalize the leading whitespace in the <code> block. It finds the line with the shortest amount of leading whitespace and strips an equal amount from each line thus left-aligning the code block. You can download the code block component from the Releases page at http://www.codeplex.com/SHFB. It's built into SHFB but you can download the Standalone Build Components to use it in DocProject or your own build scripts. See the documentation that comes with it as it does a lot of other stuff too such as syntax highlighting but you can disable that if you don't want it.

Eric
Coordinator
Feb 16, 2008 at 3:54 AM
Hi Eric,

Cool, thanks for the info. Have you reported this issue to Microsoft in the past? I'm curious to know why they haven't fixed the problem after so long.

- Dave
Feb 16, 2008 at 7:53 PM
I haven't reported it but I know it has been brought up a couple of times in the past. I believe it was also an issue with NDoc so it's been around a while.

Eric
Coordinator
Feb 17, 2008 at 3:12 PM
Interesting, because it seems like such an obvious thing to fix for a tool that controls the presentation and style of its output.

I guess it doesn't really matter though because your code block component can add value and doesn't have the same problem.

- Dave
Feb 18, 2008 at 8:11 AM
Thanks for all your help, comments and suggestions i will try installing the Presentation patch and report my findings here

- Murray
Feb 18, 2008 at 8:30 AM
The presentation patch does not solve the problem :( oh well i can carry on for the time being, the larger job is to comment the code rather than looking too much at the presentation

Thanks for all your help
Coordinator
Feb 18, 2008 at 1:19 PM
Edited Feb 18, 2008 at 1:20 PM
Hi Murray,

Thanks for the follow-up.

Though as Eric reported in this thread, the simplest approach to fixing this problem is to either pull in code samples from an external XML document or use his Code Block Component.

You can find some information and links about the <include> tag here:

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2744042&SiteID=1

For help using third-party build components with DocProject, see How To Use Third-Party Build Components In DocProject.

- Dave