Skip to content

Commit

Permalink
move example inline where possible
Browse files Browse the repository at this point in the history
The markdown and repo list examples are pretty simple and can easily be
moved to be inline samples so that they render as part of the packages
godocs.  This helps make them more visible even if they won't run in the
browser.  The basic auth example requires interacting with the user, so
leaving it where it is.  Future examples should be included inline
whenever possible.
  • Loading branch information
willnorris committed Mar 31, 2016
1 parent e85183c commit 32a84d1
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 57 deletions.
24 changes: 0 additions & 24 deletions examples/markdown/main.go

This file was deleted.

33 changes: 0 additions & 33 deletions examples/repos/main.go

This file was deleted.

14 changes: 14 additions & 0 deletions github/misc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,20 @@ func TestMarkdown(t *testing.T) {
}
}

func ExampleClient_Markdown() {
client := NewClient(nil)

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

output, _, err := client.Markdown(input, opt)
if err != nil {
fmt.Println(err)
}

fmt.Println(output)
}

func TestListEmojis(t *testing.T) {
setup()
defer teardown()
Expand Down
14 changes: 14 additions & 0 deletions github/repos_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,20 @@ func TestRepositoriesService_List_invalidUser(t *testing.T) {
testURLParseError(t, err)
}

func ExampleRepositoriesService_List() {
client := NewClient(nil)

user := "willnorris"
opt := &RepositoryListOptions{Type: "owner", Sort: "updated", Direction: "desc"}

repos, _, err := client.Repositories.List(user, opt)
if err != nil {
fmt.Println(err)
}

fmt.Printf("Recently updated repositories by %q: %v", user, Stringify(repos))
}

func TestRepositoriesService_ListByOrg(t *testing.T) {
setup()
defer teardown()
Expand Down

0 comments on commit 32a84d1

Please sign in to comment.