Skip to content

Example code blocks are sometimes separated into 2 or more blocks #53

Open
@kosist

Description

@kosist

Example code is sometimes separated into 2 blocks, although could be displayed in the single block. This applies to multiple articles and multiple code languages. The publishing system can't merge two snippets into a single presented snippet block in the published article. The original authors tried to reuse portions of code which required them to use more than one code block, one after the other. Frankly, it looks terrible.

This issue is to track which articles have this problem and serve as a jumping off point for contributors to identify where to fix the issue.

image

Articles that need fixes:

Activity

adegeo

adegeo commented on Sep 22, 2020

@adegeo
Contributor

Thank you for reporting this.

This is a common issue throughout the WPF documentation. Various parts of the XAML are reused and split out. We've recently adopted a model where we're just going to duplicate the XAML for each article instead of trying to reuse them as it causes problems like this.

added
doc-bugProblem with the content; needs to be fixed [org][type][category]
Pri2Medium priority
and removed on Sep 22, 2020
kosist

kosist commented on Sep 24, 2020

@kosist
Author

Interesting that when I open page for editing on github, it has links to the code which are broken (or there is no access to them):
image
Is it possible to access them in order to make a fix by myself; or you have it somehow protected internally?

adegeo

adegeo commented on Sep 24, 2020

@adegeo
Contributor

Thanks for the desire to contribute 👍

This is a actually a bit more complicated. First, a lot of the links don't work via github because of the syntax used. The #Source link for example defines this in the source: ~/samples/snippets/csharp/VS_Snippets_Wpf/CollectionBinding/CSharp/Window1.xaml#source with the ~ (to indicate the root) being the problem. To view the file in github you would need to adjust the URL in your browser (here is the link):

- https://github.com/dotnet/docs-desktop/blob/live/dotnet-desktop-guide/framework/wpf/data/~/samples/snippets/csharp/VS_Snippets_Wpf/CollectionBinding/CSharp/Window1.xaml#source
+ https://github.com/dotnet/docs-desktop/blob/live/dotnet-desktop-guide/samples/snippets/csharp/VS_Snippets_Wpf/CollectionBinding/CSharp/Window1.xaml#source

Snippet blocks are indicated with an XML comment containing an xml node (named of the snippet you want to define) that is open or closed open/close to indicate the snippet area. (if no # is used in the snippet reference in the doc, the whole file is presented on the published article)

So you can see the #source snippet being defined here:

<!--<SnippetSource>-->
<Window x:Class="SDKSample.Window1"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:local="clr-namespace:SDKSample"
  Title="Binding to a Collection"
  SizeToContent="WidthAndHeight">
  <Window.Resources>
    <local:People x:Key="MyFriends"/>
    <!--</SnippetSource>-->

The publishing system can't merge two snippets into a single presented snippet block in the published article. This is why it ends up being two distinct blocks and frankly looks terrible. The reason it's being displayed this way is that the source file contains a datatemplate that is being omitted in this reference because it's talked about in the next section of the article.

Really this XAML needs to be duplicated into two files, one to present the datatemplate and another to present the Source/UI snippets as a single one.

kosist

kosist commented on Oct 6, 2020

@kosist
Author

Thank you for the detailed explanation!

adegeo

adegeo commented on Oct 12, 2020

@adegeo
Contributor

I think we should turn this into a project issue which is to identify and fix all of the individual articles that have this problem. I'm going to edit it to remove the metadata and then add links to each file identified via issues.

changed the title [-]Example XAML code is separated into 2 blocks[/-] [+]Example code blocks are sometimes separated into 2 or more blocks[/+] on Oct 12, 2020
added
discussionIndicates issues that are being discussed
on Oct 12, 2020

16 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Pri2Medium prioritydiscussionIndicates issues that are being discusseddoc-bugProblem with the content; needs to be fixed [org][type][category]dotnet-framework/svchelp wantedGood for community contributors to help [up-for-grabs]okr-healthContent-health KR: Concerns article defects/freshness or build warnings.okr-qualitywpf/subsvc

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @kosist@netdragonboberb@dotnet-bot@MSDN-WhiteKnight@adegeo

        Issue actions

          Example code blocks are sometimes separated into 2 or more blocks · Issue #53 · dotnet/docs-desktop