Code language tab ordering in the VS2010 style

May 2, 2012 at 8:30 PM
Edited May 2, 2012 at 8:34 PM

I haven't yet found the time to fully document this, but if you want a different set of standard code language tabs, or you want to change their order, here's what you need to do:

  1. Find the file called "ps-codesnippet.xslt" in Sandcastle's "Presentation\vs2010\branding" folder.
  2. Near the bottom, you'll find two variables: "groupedLanguages" and "separateLanguages".
  3. The groupedLanguages variable is an ordered list of the standard code language tabs.  Any code sample whose language is in the list will always be grouped with all other languages in the list, in the specified order. 
  4. The separateLanguages variable is a list of language tabs that are always formatted separately.  Any code sample whose language shows up in this list will not be grouped with adjacent code samples.

You can add, remove, and/or redorder the languages in either list. 

  1. Each language name is a <value> element (one-per-line, with no blank lines please).
  2. Language names are case-sensitive and spacing-sensitive.
  3. A complete list of language names can be found in "Presentation\vs2010\content\share_content.xml" or "Presentation\2010\content\shared_content_mshc.xml"
  4. A language should not appear in both lists (obviously).

If this doesn't work, please let me know.

Oct 2, 2012 at 1:46 PM
Edited Oct 2, 2012 at 1:47 PM

Hi Don.  This works great...however...

The order of the tabs change, but the default selection is still VB.

I would like C# to be the first tab (you solution works for this) and the default selection (VB is stilll selected by default).

Any thoughts?

Scott

Oct 2, 2012 at 4:00 PM

I have looked into this a bit and found the following in branding.js - onload():

var lang = GetCookie("CodeSnippetContainerLang", "Visual Basic");

The default is "Visual Basic" - I have search everywhere to see who sets "CodeSnippetContainerLang" and cannot find it (in SHFB and Sandcastle).

So, assuming it is not being set, the default will always be VB if the VB tab exists.

Questions - Where does branding.js come from? How can we override this?

Coordinator
Oct 2, 2012 at 4:04 PM

Unfortunately, Don isn't responding to e-mail and doesn't appear to have been on CodePlex since early June.  I made a number of changes to the presentation style this weekend in order to get it working properly with Help Viewer 2.  I haven't looked to closely yet to find out where it's setting that default but the language filter does appear to be sticky so once you select C# in a help file it sticks across invocations as well as across uninstalls and reinstalls of the same help file.

Eric

 

Oct 2, 2012 at 8:52 PM

Thanks, Eric.

I am using VS2010 presentation style...and my two issues are:

1) I have gotten C# to be the first tab in the examples tabset, but VB (second) is always selected.

2) This isn't sticky for me at all - if I click to another topic and back again...the VB tab is reselected.

I believe this part of onload() on the page and that line of code I posted.

If you know, how does Working\branding.js getting created?

I see it in the Working folder...referenced in Branding.xslt, dev10.manifest, and site.master...and included in the CHM file, but where does this come from?

Thanks,

Scott

Oct 2, 2012 at 8:54 PM

Thanks again, Eric.  I got your reply to another post.

For everyone...here is what Eric said...

***

In the current release, Branding.js is coming from the dev10.mshc file which is part of the Visual Studio 2010 content installed for Help Viewer. That makes it inaccessible for changes in the current release as the Help Viewer output will always load it from the default branding package. Due to the number of changes I had to make to get the presentation styles working with Help Viewer 2, that is no longer the case in the next release and the script will be part of the normal presentation style and will be easy to modify should the need arise. I'm hoping to get the next release out within a week or so.

Using the default branding package seemed like a good idea but it has proved to be otherwise so I'm getting rid of that method in favor of purely self-branded content like the other presentation styles. There are some remnants of the branding stuff in the next release but only as far as the XSL transformations. The images and scripts are available for modification as part of the general presentation style. A future release will probably get rid of the remaining branding transformations too in favor of merging the processing into the other presentation style transformations.

Eric

 

Oct 2, 2012 at 9:20 PM

I confirmed my theory about the default tab.

1) The "CodeSnippetContainerLang" cookie is not being set

2) The default of "Visual Basic" is being used

3) If you unzip dev10.mshc, edit branding.js, and set the following on line 13:

var lang = GetCookie("CodeSnippetContainerLang", "C#");

4) Save the ZIP and rebuild your help file

Then C# will be the default-selected tab on code examples.

Like you don't have enough to do, Eric...but can we implement the "CodeSnippetContainerLang" cookie so people don't have to edit a JS file for this feature?

I can create an issue if you want.

FYI and thanks!

Scott

Coordinator
Oct 3, 2012 at 8:30 PM

I replied here: http://sandcastle.codeplex.com/discussions/359722

Eric

 

Oct 3, 2012 at 8:33 PM

Got it....thanks.

From: EWoodruff [email removed]
Sent: Wednesday, October 03, 2012 3:30 PM
To: Scott Nickel
Subject: Re: Code language tab ordering in the VS2010 style [SHFB:354300]

From: EWoodruff