-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Arbitrarymarkdown #947
Closed
Closed
Arbitrarymarkdown #947
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
55632ee
added "Merged" in searchissues which allows search repos by merged da…
poisonous-milk fc1b448
added tests for the merged qualifier
poisonous-milk e315a96
comment out new tests.
poisonous-milk 7e6fbd4
recovered tests
poisonous-milk bc8c502
Merged property will be set according to MergedAt now. It is not alwa…
poisonous-milk 09051a0
added assignee property to pull request.
poisonous-milk 67c310e
removed merged property in PR and related test
poisonous-milk cde7254
Added NewArbitraryMarkdown class, RenderArbitraryMakrdown method and …
poisonous-milk 7c1c86f
run build fixproject
poisonous-milk b084d9f
Fixed the problem in the constructor.
poisonous-milk b0f4ec0
Merge branch 'master' into arbitrarymarkdown
poisonous-milk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,27 @@ public async Task RequestsTheEmojiEndpoint() | |
"text/plain"); | ||
} | ||
} | ||
public class TheRenderArbitrryMarkdownMethod | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. typo: |
||
{ | ||
[Fact] | ||
public async Task RequestsTheEmojiEndpoint() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test description should mention that it's interested in the markdown endpoint. |
||
{ | ||
IApiResponse<string> response = new ApiResponse<string>(new Response(), "<strong>Test</strong>"); | ||
var connection = Substitute.For<IConnection>(); | ||
var forTest = new NewArbitraryMarkdown("testMarkdown", "gfm", "testContext"); | ||
connection.Post<string>(Args.Uri,forTest, "text/html", "text/plain") | ||
.Returns(Task.FromResult(response)); | ||
var client = new MiscellaneousClient(connection); | ||
|
||
var html = await client.RenderArbitraryMarkdown(forTest); | ||
Assert.Equal("<strong>Test</strong>", html); | ||
connection.Received() | ||
.Post<string>(Arg.Is<Uri>(u => u.ToString() == "markdown"), | ||
forTest, | ||
"text/html", | ||
"text/plain"); | ||
} | ||
} | ||
public class TheGetEmojisMethod | ||
{ | ||
[Fact] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.Globalization; | ||
using System.Linq; | ||
|
||
namespace Octokit | ||
{ | ||
/// <summary> | ||
/// Used to create anarbitrary markdown | ||
/// </summary> | ||
/// <remarks> | ||
/// API: https://developer.github.com/v3/markdown/#render-an-arbitrary-markdown-document | ||
/// </remarks> | ||
[DebuggerDisplay("{DebuggerDisplay,nq}")] | ||
public class NewArbitraryMarkdown | ||
{ | ||
const string _markdown = "markdown"; | ||
const string _gfm = "gfm"; | ||
|
||
/// <summary> | ||
/// Create an arbitrary markdown | ||
/// </summary> | ||
/// <param name="text">The Markdown text to render</param> | ||
/// <param name="mode">The rendering mode. Can be either markdown by default or gfm</param> | ||
/// <param name="context"> | ||
/// The repository context. Only taken into account when rendering as gfm | ||
/// </param> | ||
public NewArbitraryMarkdown(string text, string mode, string context) | ||
{ | ||
Text = text; | ||
Mode = GetMode(mode); | ||
Context = context; | ||
} | ||
|
||
/// <summary> | ||
/// Create an arbitrary markdown | ||
/// </summary> | ||
/// <param name="text">The Markdown text to render | ||
/// </param> | ||
|
||
public NewArbitraryMarkdown(string text) | ||
:this(text,_markdown,null) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Create an arbitrary markdown | ||
/// </summary> | ||
/// <param name="text">The Markdown text to render</param> | ||
/// <param name="mode">The rendering mode. Can be either markdown by default or gfm</param> | ||
/// </param> | ||
public NewArbitraryMarkdown(string text, string mode) | ||
: this(text, mode, null) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Gets the markdown text | ||
/// </summary> | ||
/// <value> | ||
/// The text. | ||
/// </value> | ||
public string Text { get; private set; } | ||
|
||
/// <summary> | ||
/// Gets the mode of the text | ||
/// </summary> | ||
/// <value> | ||
/// The mode. | ||
/// </value> | ||
public string Mode { get; private set; } | ||
|
||
/// <summary> | ||
/// Gets the context of the markdown | ||
/// </summary> | ||
/// <value> | ||
/// The context. | ||
/// </value> | ||
public string Context { get; private set; } | ||
|
||
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "gfm")] | ||
static string GetMode(string mode) | ||
{ | ||
if (mode != _markdown && mode != _gfm) | ||
{ | ||
throw (new FormatException("The mode must be either 'markdown' or 'gfm'")); | ||
} | ||
else | ||
return mode; | ||
} | ||
internal string DebuggerDisplay | ||
{ | ||
get | ||
{ | ||
return String.Format(CultureInfo.InvariantCulture, "Text: {0}", Text); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems unrelated to the other changes - could you add it back in?