Skip to content

Move snippets into the docs  #17297

Closed
MicrosoftDocs/Contribute
#394

Description

@BillWagner

We've found that keeping snippet (code) projects in a different repository than the articles where they are includes introduces unnecessary friction in updating articles.

So, we plan to move snippets into the dotnet/docs and dotnet/dotnet-api-docs repositorites.

The dotnet/samples repository will be the home of larger scenario-based samples that may be referenced from tutorials or other long-form explorations. In addition, the samples in the dotnet/samples repository are likely candidates for the samples repository.

Task plan

  1. Make sure all included snippets are in the /snippets folder in the dotnet/samples repository.
  2. Update all snippet references to the /samples/snippets folder, while referencing the snippets in the dotnet/samples repository.
  3. Move all snippets into dotnet/docs/samples/snippets and dotnet/dotnet-api-docs/samples/snippets as one massive PR (each repo).
  4. Remove the samples repo dependency, and fix build errors.
  5. Remove the /snippets content in the dotnet/samples repo.
  6. Update the contributor guide with the snippet and sample guidelines below.
  7. Remove unreferenced snippets in dotnet/dotnet-api-docs/snippets. (Leverage the clean-repo tool for this task)
  8. Remove unreferenced snippets in dotnet/docs/snippets. (Leverage the clean-repo tool for this task)
  9. We configure samples CI on the conceptual and API reference repositories.
  10. Add dependabot to the docs and dotnet-api-docs repositories.
  11. After that task is completed, any new significant edits should move snippets into the correct folder structure in the content repo (see below).
  12. All samples remaining in the samples repository could be configured for the samples browser.

Note that we will be concurrently enabling .NET Interactive (formerly known as Try.NET) for samples. That work should be done in separate PRs from moving samples and snippets into a new repo or folder structure.

Guidelines for snippet projects

  • They are projects (not solutions), and the .sln file is not checked in. (There are exceptions for multi-project tutorials.)
  • Language specific projects are in sibling folders using names following our inline code convention: csharp, fsharp, and vb. These folders are not needed in the language guide area, where only one language is assumed.
  • When multiple versions of a project are needed to represent different steps in a tutorial, inline code can (maybe should) be used for interim steps. Only the final version is included using the include syntax.

For API reference, the repository will have a snippets folder at the root of the repository. Each project will be in a sub-folder that matches the sub-folder path for the associated XML file where the snippet is included. For example, snippets used in ~/xml/System.Collections.Generic/List`1.xml would be stored in ~/snippets/System.Collections.Generic/List`1 folder. This makes it easy to map between code and article.

For conceptual, we would put the project(s) in a snippets subfolder. The snippets subfolder should be in the same folder as the article by default. Where a snippets project contains code used in multiple articles, the snippets folder should be in the nearest parent folder of all relevant articles. This makes it easy for us to navigate from an article to a snippet. Where snippet projects map to a single article, the reverse mapping is easy. Where snippet projects contain code from multiple articles, search functions in VS code can be used to find all locations where snippets are used.

Guidelines for samples projects

Samples should be stored in folders that represent the area where a sample is referenced in articles. In most cases, this will map to the top 2 or 3 folder levels in the conceptual repo.

The next level folder should map to the sample name. Under that folder, different versions can be stored as needed for different steps of the source article.

Activity

  1. added this to the March 2020 milestone on Mar 3, 2020
  2. added
    discussion
    and removed
    ⌚ Not Triaged
    on Mar 3, 2020
  3. tdykstra commented on Mar 3, 2020

    @tdykstra
    Contributor

    The plan for the new folder structure that we’re moving to after the initial move-everything-at-once stage says put snippets folder in the same folder as the article. Some folders have lots of articles, and we wouldn’t want one folder for all of the snippet projects. E.g. standard/base-types has a couple dozen articles.

    Suggestion -- under snippets use a folder named after the article:

    • Base-types
      • Snippets
        • Character-encoding
          • Csharp
            • Projname.csproj
            • … project files
        • Manipulating-strings
          • Csharp
            • Projname.csproj
            • …project files
      • Character-encoding.md
      • Manipulating-strings.md
      • Index.md
      • Etc.md
  4. BillWagner commented on May 4, 2020

    @BillWagner
    MemberAuthor

    Update from meeting with @Thraka on 5/4:

    • Folders that were not referenced in either dotnet-api-docs or docs have been removed. More folders may become "not referenced" as we
    • We are rethinking the use of dependabot on the docs and dotnet-api-docs repos. Since we don't expect customers to download the snippet-based samples, we are less concerned that they use the latest versions.

    Next steps:

    • Update the contributor guide with the plan from above. assigned to @BillWagner
      • Note: We can safely remove // <snippet> comments and #region snippet_ areas from all samples.
    • We think the migration of snippet code can happen organically.
  5. BillWagner commented on May 12, 2020

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

Metadata

Metadata

Labels

discussion

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions