Skip to content

Commit 32a84d1

Browse files
committed
move example inline where possible
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.
1 parent e85183c commit 32a84d1

File tree

4 files changed

+28
-57
lines changed

4 files changed

+28
-57
lines changed

examples/markdown/main.go

Lines changed: 0 additions & 24 deletions
This file was deleted.

examples/repos/main.go

Lines changed: 0 additions & 33 deletions
This file was deleted.

github/misc_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,20 @@ func TestMarkdown(t *testing.T) {
4646
}
4747
}
4848

49+
func ExampleClient_Markdown() {
50+
client := NewClient(nil)
51+
52+
input := "# heading #\n\nLink to issue #1"
53+
opt := &MarkdownOptions{Mode: "gfm", Context: "google/go-github"}
54+
55+
output, _, err := client.Markdown(input, opt)
56+
if err != nil {
57+
fmt.Println(err)
58+
}
59+
60+
fmt.Println(output)
61+
}
62+
4963
func TestListEmojis(t *testing.T) {
5064
setup()
5165
defer teardown()

github/repos_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,20 @@ func TestRepositoriesService_List_invalidUser(t *testing.T) {
6767
testURLParseError(t, err)
6868
}
6969

70+
func ExampleRepositoriesService_List() {
71+
client := NewClient(nil)
72+
73+
user := "willnorris"
74+
opt := &RepositoryListOptions{Type: "owner", Sort: "updated", Direction: "desc"}
75+
76+
repos, _, err := client.Repositories.List(user, opt)
77+
if err != nil {
78+
fmt.Println(err)
79+
}
80+
81+
fmt.Printf("Recently updated repositories by %q: %v", user, Stringify(repos))
82+
}
83+
7084
func TestRepositoriesService_ListByOrg(t *testing.T) {
7185
setup()
7286
defer teardown()

0 commit comments

Comments
 (0)