Skip to content

Commit 4adef75

Browse files
committed
explain the new json helper
1 parent 5ab0cd9 commit 4adef75

1 file changed

Lines changed: 17 additions & 8 deletions

File tree

README.md

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,24 @@ API docs should look like:
4242

4343
### Response
4444

45-
<pre class="highlight"><code class="language-javascript">
46-
[
47-
{
48-
...
49-
}
50-
}
51-
</code></pre>
45+
<%= json :resource_name %>
5246

5347
**Note**: We're using [Kramdown Markdown extensions](http://kramdown.rubyforge.org/syntax.html), such as definition lists.
5448

49+
### JSON Responses
50+
51+
We specify the JSON responses in ruby so that we don't have to write
52+
them by hand all over the docs. You can render the JSON for a resource
53+
like this:
54+
55+
<%= json :issue %>
56+
57+
This looks up `GitHub::Resources::ISSUE` in `lib/resources.rb`.
58+
59+
Some actions return arrays. You can modify the JSON by passing a block:
60+
61+
<%= json(:issue) { |hash| [hash] } %>
62+
5563
### Terminal blocks
5664

5765
You can specify terminal blocks with `pre.terminal` elements. It'd be
@@ -106,5 +114,6 @@ One thing: remember to add trailing slashes to all nanoc links!
106114

107115
* Need some way to deploy? Look into GitHub pages to start, until we
108116
can integrate through a simple hurl.it app for live API calls.
109-
* Flesh out the missing components of the requests.
110117
* Maybe add a nice TOC at the top of each page.
118+
* Write a task for verifying JSON Resource examples against the actual
119+
API.

0 commit comments

Comments
 (0)