diff --git a/Microsoft.DotNet.Try.ProjectTemplate.Tests/TutorialTemplateTests.cs b/Microsoft.DotNet.Try.ProjectTemplate.Tests/TutorialTemplateTests.cs index c47e64762..c873ec6b8 100644 --- a/Microsoft.DotNet.Try.ProjectTemplate.Tests/TutorialTemplateTests.cs +++ b/Microsoft.DotNet.Try.ProjectTemplate.Tests/TutorialTemplateTests.cs @@ -57,7 +57,7 @@ public async Task When_the_template_is_installed_verify_works() .Trim() .Should() .Match( - $"{outputDirectory}{Path.DirectorySeparatorChar}Readme.md*Line 24:*{outputDirectory}{Path.DirectorySeparatorChar}Program.cs (in project {outputDirectory}{Path.DirectorySeparatorChar}{outputDirectory.Name}.csproj)*".EnforceLF()); + $"{outputDirectory}{Path.DirectorySeparatorChar}Readme.md*Line *:*{outputDirectory}{Path.DirectorySeparatorChar}Program.cs (in project {outputDirectory}{Path.DirectorySeparatorChar}{outputDirectory.Name}.csproj)*".EnforceLF()); resultCode.Should().Be(0); diff --git a/Microsoft.DotNet.Try.ProjectTemplate/Tutorial/content/Program.cs b/Microsoft.DotNet.Try.ProjectTemplate/Tutorial/content/Program.cs index de81332fc..57610339f 100644 --- a/Microsoft.DotNet.Try.ProjectTemplate/Tutorial/content/Program.cs +++ b/Microsoft.DotNet.Try.ProjectTemplate/Tutorial/content/Program.cs @@ -3,13 +3,17 @@ namespace Microsoft.DotNet.Try.ProjectTemplate.Tutorial { - ///Takes in the --region option from the code fence options in markdown - ///Takes in the --session option from the code fence options in markdown - ///Takes in the --package option from the code fence options in markdown - ///Takes in the --project option from the code fence options in markdown - ///Takes in any additional arguments passed in the code fence options in markdown + ///This program uses System.CommandLine.DragonFruit to accept command line arguments from command line. + ///Execute: dotnet run --region "HelloWorld" to see the output + /// public class Program { + ///Takes in the --region option from the code fence options in markdown + ///Takes in the --session option from the code fence options in markdown + ///Takes in the --package option from the code fence options in markdown + ///Takes in the --project option from the code fence options in markdown + ///Takes in any additional arguments passed in the code fence options in markdown + ///To learn more see our documentation static int Main( string region = null, string session = null, @@ -21,11 +25,11 @@ static int Main( { "HelloWorld" => HelloWorld(), "DateTime" => DateTime(), - _ => EmptyRegion() + _ => throw new ArgumentException("A --region argument must be passed", nameof(region)) }; } - public static int HelloWorld() + internal static int HelloWorld() { #region HelloWorld Console.WriteLine("Hello World!"); @@ -33,19 +37,12 @@ public static int HelloWorld() return 0; } - public static int DateTime() + internal static int DateTime() { #region DateTime Console.WriteLine(System.DateTime.Now); #endregion return 0; } - - public static int EmptyRegion() - { - #region EmptyRegion - #endregion - return 0; - } } } \ No newline at end of file diff --git a/Microsoft.DotNet.Try.ProjectTemplate/Tutorial/content/Readme.md b/Microsoft.DotNet.Try.ProjectTemplate/Tutorial/content/Readme.md index 99c7e5780..10e847e5f 100644 --- a/Microsoft.DotNet.Try.ProjectTemplate/Tutorial/content/Readme.md +++ b/Microsoft.DotNet.Try.ProjectTemplate/Tutorial/content/Readme.md @@ -1,51 +1,20 @@ # Creating interactive documentation with Try .NET ## Setup -Before getting started with the sample above, you need to install the `dotnet try` global tool. In a terminal execute +If you haven't installed the `dotnet try` global tool, you can install it by following the instructions [here](https://github.com/dotnet/try#setup). -```console -dotnet tool install --global dotnet-try -``` - -Once installed you can execute -```console -dotnet try -h -``` -and see the list of available commands. - -## Executing your first sample - -In the directory of the project execute -```console -dotnet try -``` -This should launch a browser window. The following code fence will be replaced by the editor and you can execute the code by hitting the run button. +## This code fence will run the HelloWorld method from Program.cs ```cs --source-file ./Program.cs --project ./Microsoft.DotNet.Try.ProjectTemplate.Tutorial.csproj --region HelloWorld ``` -## What's happening behind the scenes - -Code fences are a standard way to include code in your markdown files. The only change you need to do is to add few options in the first line of your code snippet. If you notice the above code snippet, there are three options in action. - -| Option | What it does | -|----------------------------------------|-----------------------------------------------------------------------------------------------------------------------------| -| `--project ./Microsoft.DotNet.Try.ProjectTemplate.Tutorial.csproj` | Points to the project that the sample is part of. (Optional. Defaults to any .csproj in the same folder as the `.md` file.) | -| `--region HelloWorld` | Identifes a C# code `#region` to focus on. (Optional. If not specified, the whole file is displayed in the editor.) | -| `--source-file ./Program.cs` | Points to the file where the sample code is pulled from. - -If you navigate back to Program.cs you will be able to see the various regions and the context in which your code is being execute. As an exercise, try to change the region in the previous code snippet to `DateTime` and then refresh the browser. You should be able to see the text that is a part of the `DateTime` region now. - ## Learn More - -The above are the basic to get you started with creating your own interactive documentation. To learn more about the `dotnet try` features, at the command line execute +To learn more about the `dotnet try` features, at the command line execute ```console dotnet try demo ``` -This interactive demo will walk you through the various features in `dotnet try`. - ## Feedback We love to hear from you. If you have any suggestions or feedback please reach out to us on [GitHub](https://github.com/dotnet/try)