Skip to content

Commit

Permalink
rename Markdown to Render
Browse files Browse the repository at this point in the history
  • Loading branch information
WillAbides committed Sep 21, 2023
1 parent 8442e31 commit c86f81e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions github/examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ import (
"github.com/google/go-github/v55/github"
)

func ExampleMarkdownService_Markdown() {
func ExampleMarkdownService_Render() {
client := github.NewClient(nil)

input := "# heading #\n\nLink to issue #1"
opt := &github.MarkdownOptions{Mode: "gfm", Context: "google/go-github"}

ctx := context.Background()
output, _, err := client.Markdown.Markdown(ctx, input, opt)
output, _, err := client.Markdown.Render(ctx, input, opt)
if err != nil {
fmt.Println(err)
}
Expand Down
12 changes: 6 additions & 6 deletions github/markdown.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import (
// MarkdownService provides access to markdown-related functions in the GitHub API.
type MarkdownService service

// MarkdownOptions specifies optional parameters to the Markdown method.
// MarkdownOptions specifies optional parameters to the Render method.
type MarkdownOptions struct {
// Mode identifies the rendering mode. Possible values are:
// markdown - render a document as plain Markdown, just like
// markdown - render a document as plain Render, just like
// README files are rendered.
//
// gfm - to render a document as user-content, e.g. like user
Expand All @@ -32,17 +32,17 @@ type MarkdownOptions struct {
Context string
}

type markdownRequest struct {
type markdownRenderRequest struct {
Text *string `json:"text,omitempty"`
Mode *string `json:"mode,omitempty"`
Context *string `json:"context,omitempty"`
}

// Markdown renders an arbitrary Markdown document.
// Render renders an arbitrary Render document.
//
// GitHub API docs: https://docs.github.com/rest/markdown/markdown#render-a-markdown-document
func (s *MarkdownService) Markdown(ctx context.Context, text string, opts *MarkdownOptions) (string, *Response, error) {
request := &markdownRequest{Text: String(text)}
func (s *MarkdownService) Render(ctx context.Context, text string, opts *MarkdownOptions) (string, *Response, error) {
request := &markdownRenderRequest{Text: String(text)}
if opts != nil {
if opts.Mode != "" {
request.Mode = String(opts.Mode)
Expand Down
20 changes: 10 additions & 10 deletions github/markdown_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ func TestMarkdownService_Markdown(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()

input := &markdownRequest{
input := &markdownRenderRequest{
Text: String("# text #"),
Mode: String("gfm"),
Context: String("google/go-github"),
}
mux.HandleFunc("/markdown", func(w http.ResponseWriter, r *http.Request) {
v := new(markdownRequest)
v := new(markdownRenderRequest)
assertNilError(t, json.NewDecoder(r.Body).Decode(v))

testMethod(t, r, "POST")
Expand All @@ -36,21 +36,21 @@ func TestMarkdownService_Markdown(t *testing.T) {
})

ctx := context.Background()
md, _, err := client.Markdown.Markdown(ctx, "# text #", &MarkdownOptions{
md, _, err := client.Markdown.Render(ctx, "# text #", &MarkdownOptions{
Mode: "gfm",
Context: "google/go-github",
})
if err != nil {
t.Errorf("Markdown returned error: %v", err)
t.Errorf("Render returned error: %v", err)
}

if want := "<h1>text</h1>"; want != md {
t.Errorf("Markdown returned %+v, want %+v", md, want)
t.Errorf("Render returned %+v, want %+v", md, want)
}

const methodName = "Markdown"
const methodName = "Render"
testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
got, resp, err := client.Markdown.Markdown(ctx, "# text #", &MarkdownOptions{
got, resp, err := client.Markdown.Render(ctx, "# text #", &MarkdownOptions{
Mode: "gfm",
Context: "google/go-github",
})
Expand All @@ -61,10 +61,10 @@ func TestMarkdownService_Markdown(t *testing.T) {
})
}

func TestMarkdownRequest_Marshal(t *testing.T) {
testJSONMarshal(t, &markdownRequest{}, "{}")
func TestMarkdownRenderRequest_Marshal(t *testing.T) {
testJSONMarshal(t, &markdownRenderRequest{}, "{}")

a := &markdownRequest{
a := &markdownRenderRequest{
Text: String("txt"),
Mode: String("mode"),
Context: String("ctx"),
Expand Down

0 comments on commit c86f81e

Please sign in to comment.