From e44ca0a5c4f27d07e02e830c210aad1ccb0d73e1 Mon Sep 17 00:00:00 2001 From: Andrius Bentkus Date: Wed, 4 Apr 2018 12:23:27 +0300 Subject: [PATCH] Add csharp hint to code blocks --- docs/git-database.md | 4 ++-- docs/issues.md | 16 ++++++++-------- docs/labels.md | 8 +++++--- docs/oauth-flow.md | 12 ++++++------ docs/releases.md | 8 ++++---- 5 files changed, 25 insertions(+), 23 deletions(-) diff --git a/docs/git-database.md b/docs/git-database.md index ffb9f3247d..3a3a666c60 100644 --- a/docs/git-database.md +++ b/docs/git-database.md @@ -4,7 +4,7 @@ Tags can be created through the GitHub API -``` +```csharp var tag = new NewTag { Message = "Tagging a new release of Octokit", Tag = "v1.0.0", @@ -23,6 +23,6 @@ Console.WriteLine("Created a tag for {0} at {1}", result.Tag, result.Sha); Or you can fetch an existing tag from the API: -``` +```csharp var tag = await client.Git.Tags.Get("octokit", "octokit.net", "v1.0.0"); ``` diff --git a/docs/issues.md b/docs/issues.md index b1286b3a77..2cd76ba0e5 100644 --- a/docs/issues.md +++ b/docs/issues.md @@ -9,20 +9,20 @@ If you want to view all assigned, open issues against repositories you belong to (either you own them, or you belong to a team or organization), use this method: -``` +```csharp var issues = await client.Issue.GetAllForCurrent(); ``` If you want to skip organization repositories, you can instead use this rather verbose method: -``` +```csharp var issues = await client.Issue.GetAllForOwnedAndMemberRepositories(); ``` If you know the specific repository, just invoke that: -``` +```csharp var issuesForOctokit = await client.Issue.GetAllForRepository("octokit", "octokit.net"); ``` @@ -41,7 +41,7 @@ The simplest request is `IssueRequest` which has these options: For example, this is how you could find all issues updated in the past two weeks: -``` +```csharp var recently = new IssueRequest { Filter = IssueFilter.All, @@ -60,7 +60,7 @@ var issues = await client.Issue.GetAllForCurrent(recently); For example, to find all issues which need to be prioritized: -``` +```csharp var shouldPrioritize = new RepositoryIssueRequest { Assignee = "none", @@ -74,7 +74,7 @@ var issues = await client.Issue.GetAllForRepository("octokit", "octokit.net", sh At a minimum, you need to specify the title: -``` +```csharp var client = new GitHubClient(....); // More on GitHubClient can be found in "Getting Started" var createIssue = new NewIssue("this thing doesn't work"); var issue = await client.Issue.Create("owner", "name", createIssue); @@ -99,13 +99,13 @@ sections for more details. You can either hold the new issue in memory, or use the id to fetch the issue later: -``` +```csharp var issue = await client.Issue.Get("octokit", "octokit.net", 405); ``` With this issue, you can transform it into an `IssueUpdate` using the extension method: -``` +```csharp var update = issue.ToUpdate(); ``` diff --git a/docs/labels.md b/docs/labels.md index 1910eeca12..6fe5041f3b 100644 --- a/docs/labels.md +++ b/docs/labels.md @@ -4,9 +4,11 @@ Labels are appended using the method `NewIssue.Labels.Add(x)`. Example: - var myNewIssue = new NewIssue("Issue with dropdown menu"); - myNewIssue.Labels.Add("bug"); - +```csharp +var myNewIssue = new NewIssue("Issue with dropdown menu"); +myNewIssue.Labels.Add("bug"); +``` + The default labels that come with every repository are: - bug - duplicate diff --git a/docs/oauth-flow.md b/docs/oauth-flow.md index 5b29ce89ab..81a0927e66 100644 --- a/docs/oauth-flow.md +++ b/docs/oauth-flow.md @@ -20,7 +20,7 @@ Then click "Register application", and you'll get your client id and client secr We'll use these in a few places, so define these as private fields: -``` +```csharp var clientId = "some-id-here"; var clientSecret = "some-id-here"; var client = new GitHubClient(new ProductHeaderValue("my-cool-app")); @@ -28,7 +28,7 @@ var client = new GitHubClient(new ProductHeaderValue("my-cool-app")); To start the authentication flow, you need to craft a URL indicating your application needs to authenticate on behalf of the current user. -``` +```csharp // NOTE: this is not required, but highly recommended! // ask the ASP.NET Membership provider to generate a random value // and store it in the current user's session @@ -51,7 +51,7 @@ Scopes are keys which specify the permissions the application needs. If you don' Once the user has been navigated to the URL above and clicked "Authorize Application", you will receive a callback at the default Callback URL for your application. If you require a more flexible URL, you can override this by specifying a different URL when creating the request. -``` +```csharp var request = new OauthLoginRequest(clientId) { // other parameters @@ -63,7 +63,7 @@ The callback will have two parameters, the code generated by the GitHub API and With this code you can then request an access token by providing your client secret. This doesn't require any user interaction, so it can be done in the background. -``` +```csharp public async Task Authorize(string code, string state) { if (String.IsNullOrEmpty(code)) @@ -83,7 +83,7 @@ public async Task Authorize(string code, string state) And now you have an access token, you can set up your credentials to use this token: -``` +```csharp // repositories which include public and private repositories. public async Task Index() { @@ -97,4 +97,4 @@ public async Task Index() /* TODO: all the rest of the webapp */ } -``` \ No newline at end of file +``` diff --git a/docs/releases.md b/docs/releases.md index ab1fec923c..a7fd7d8911 100644 --- a/docs/releases.md +++ b/docs/releases.md @@ -4,7 +4,7 @@ To retrieve all releases for a repository: -``` +```csharp var releases = client.Repository.Release.GetAll("octokit", "octokit.net"); var latest = releases[0]; Console.WriteLine( @@ -17,7 +17,7 @@ Console.WriteLine( To create a new release you must have a corresponding tag in the repository. See the `git-database.md` docs for details. -``` +```csharp var newRelease = new NewRelease("v1.0.0"); newRelease.Name = "Version One Point Oh"; newRelease.Body = "**This** is some *Markdown*"; @@ -34,7 +34,7 @@ Note that the `Draft` flag is used to indicate when a release should be publishe Once the release is ready for the public, you can apply an update to the release: -``` +```csharp var release = client.Repository.Release.Get("octokit", "octokit.net", 1); var updateRelease = release.ToUpdate(); updateRelease.Draft = false; @@ -47,7 +47,7 @@ var result = await client.Repository.Release.Edit("octokit", "octokit.net", 1, u If you have any assets to include with the release, you can upload them after creating the release: -``` +```csharp var archiveContents = await File.OpenRead("output.zip"); // TODO: better sample var assetUpload = new ReleaseAssetUpload() {